/* ============================================================
   ระบบแจ้งซ่อมออนไลน์ - Main Stylesheet
   ============================================================ */

/* ============================================================
   CSS Variables (Light Mode)
   ============================================================ */
:root {
    --bg:           #f1f5f9;
    --bg-card:      #ffffff;
    --bg-sidebar:   #1e293b;
    --bg-navbar:    #ffffff;
    --bg-input:     #f8fafc;
    --bg-hover:     #f1f5f9;

    --text:         #1e293b;
    --text-muted:   #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;

    --border:       #e2e8f0;
    --border-input: #cbd5e1;

    --primary:      #3b82f6;
    --primary-dark: #2563eb;
    --primary-light:#eff6ff;

    --success:      #22c55e;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --info:         #06b6d4;

    --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-lg:    0 10px 15px -3px rgba(0,0,0,.1);

    --radius-sm:    4px;
    --radius:       8px;
    --radius-lg:    12px;
    --radius-xl:    16px;

    --sidebar-w:    240px;
    --navbar-h:     60px;

    --font:         'Sarabun', sans-serif;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg:           #0f172a;
    --bg-card:      #1e293b;
    --bg-sidebar:   #0f172a;
    --bg-navbar:    #1e293b;
    --bg-input:     #1e293b;
    --bg-hover:     #334155;

    --text:         #e2e8f0;
    --text-muted:   #94a3b8;
    --border:       #334155;
    --border-input: #475569;

    --primary-light:#1e3a5f;
    --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
    --shadow:       0 1px 3px rgba(0,0,0,.4);
    --shadow-md:    0 4px 6px rgba(0,0,0,.3);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background .3s, color .3s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; color: var(--text); }

/* ============================================================
   Layout
   ============================================================ */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-h);
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.app-layout {
    display: flex;
    padding-top: var(--navbar-h);
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--navbar-h));
    background: var(--bg-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .3s;
    z-index: 90;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px;
    min-height: calc(100vh - var(--navbar-h));
    max-width: calc(100vw - var(--sidebar-w));
}

/* Sidebar collapsed */
.sidebar-collapsed .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
.sidebar-collapsed .main-content { margin-left: 0; max-width: 100vw; }

/* ============================================================
   Navbar
   ============================================================ */
.navbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-logo   { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-icon   { font-size: 24px; }
.brand-name   { font-size: 16px; font-weight: 700; color: var(--text); display: block; }
.brand-sub    { font-size: 11px; color: var(--text-muted); display: block; }

.sidebar-toggle {
    background: none; border: none; cursor: pointer;
    padding: 8px; border-radius: var(--radius);
    color: var(--text);
}
.hamburger, .hamburger::before, .hamburger::after {
    display: block; width: 22px; height: 2px;
    background: var(--text); border-radius: 2px;
    transition: all .3s;
    position: relative;
}
.hamburger::before, .hamburger::after {
    content: ''; position: absolute; left: 0;
}
.hamburger::before { top: -7px; }
.hamburger::after  { top:  7px; }

.navbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
    background: none; border: none; cursor: pointer;
    padding: 8px; border-radius: var(--radius);
    color: var(--text); font-size: 18px;
    position: relative;
    transition: background .2s;
}
.btn-icon:hover { background: var(--bg-hover); }

/* ============================================================
   Notification Bell
   ============================================================ */
.notification-wrapper { position: relative; }

.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-navbar);
}
.notif-badge-hidden { display: none !important; }

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}
.notif-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .2s;
}
.notif-item:hover       { background: var(--bg-hover); }
.notif-item.unread      { background: var(--primary-light); }
.notif-item-text        { font-size: 13px; line-height: 1.5; }
.notif-item-time        { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-loading          { padding: 20px; text-align: center; color: var(--text-muted); }
.notif-footer           { padding: 10px 16px; text-align: center; border-top: 1px solid var(--border); }
.notif-empty            { padding: 30px; text-align: center; color: var(--text-muted); }

/* ============================================================
   User Menu
   ============================================================ */
.user-menu-wrapper { position: relative; }
.user-menu-btn {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none; cursor: pointer;
    padding: 6px 10px; border-radius: var(--radius);
    color: var(--text); transition: background .2s;
}
.user-menu-btn:hover { background: var(--bg-hover); }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
.user-info   { text-align: left; }
.user-name   { display: block; font-weight: 600; font-size: 14px; }
.user-role   { display: block; font-size: 11px; color: var(--text-muted); }
.chevron     { color: var(--text-muted); font-size: 12px; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}
.user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 2px;
}
.user-dropdown-header strong { font-size: 15px; }
.user-dropdown-header small  { color: var(--text-muted); font-size: 12px; }
.dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 14px;
    transition: background .2s;
    cursor: pointer;
}
.dropdown-item:hover             { background: var(--bg-hover); }
.dropdown-item-danger            { color: var(--danger); }
.dropdown-item-danger:hover      { background: #fee2e2; }

/* ============================================================
   Sidebar Navigation
   ============================================================ */
.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { padding: 8px 0; }
.nav-section-title {
    display: block;
    padding: 4px 16px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    color: var(--text-sidebar);
    font-size: 14px;
    border-radius: 0;
    transition: all .2s;
    text-decoration: none;
    position: relative;
}
.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.nav-item.active {
    background: var(--primary);
    color: #fff;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #93c5fd;
    border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-label { font-size: 14px; }

.nav-item-danger       { color: #f87171; }
.nav-item-danger:hover { background: rgba(239,68,68,.15); color: #ef4444; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 12px 0;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title h1 { font-size: 22px; font-weight: 700; }
.page-title p  { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.page-actions  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}
.btn-sm   { padding: 5px 11px; font-size: 13px; }
.btn-lg   { padding: 11px 22px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; text-decoration: none; }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; text-decoration: none; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); text-decoration: none; }

.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.btn-link:hover { text-decoration: underline; }

.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.form-section-full { grid-column: 1 / -1; }
.form-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row  { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 14px; font-weight: 500; color: var(--text); }
.form-label.required::after, .required { color: var(--danger); }
.form-label.required::after { content: ' *'; }
.form-hint  { font-size: 12px; color: var(--text-muted); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-input-sm, .form-select-sm { padding: 6px 10px; font-size: 13px; }
.form-textarea-sm { padding: 6px 10px; font-size: 13px; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

.input-wrapper { position: relative; }
.input-wrapper .input-icon {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}
.input-wrapper .form-input { padding-left: 38px; }
.btn-password-toggle {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none; cursor: pointer; padding: 4px;
}

/* ============================================================
   Stats Cards
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon  { font-size: 28px; }
.stat-number { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.stat-card-blue   { border-left: 4px solid var(--primary); }
.stat-card-green  { border-left: 4px solid var(--success); }
.stat-card-yellow { border-left: 4px solid var(--warning); }
.stat-card-orange { border-left: 4px solid #f97316; }
.stat-card-red    { border-left: 4px solid var(--danger); }
.stat-card-pulse  { animation: pulse-border 2s infinite; }
@keyframes pulse-border { 0%,100% { border-left-color: var(--danger); } 50% { border-left-color: #fca5a5; } }

/* ============================================================
   Dashboard Grid
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.dashboard-card-wide { grid-column: 1 / -1; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-title  { font-size: 15px; font-weight: 600; }
.card-action { font-size: 13px; color: var(--primary); }
.card-body   { padding: 16px 20px; }

/* Urgent card */
.urgent-card { border-top: 3px solid var(--danger); }
.urgent-item {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid;
}
.urgent-critical { background: #fef2f2; border-color: #fecaca; }
.urgent-high     { background: #fff7ed; border-color: #fed7aa; }
.urgent-item.escalated { border-style: dashed; }
.urgent-title  { font-size: 14px; font-weight: 500; margin: 4px 0; }
.urgent-meta   { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.urgent-right  { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.urgent-ticket-num { font-weight: 600; font-size: 13px; font-family: monospace; }

/* Activity Feed */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
    display: flex; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 10px; height: 10px;
    background: var(--primary);
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-action { font-size: 13px; font-weight: 500; }
.activity-ticket { font-size: 13px; color: var(--text-muted); }
.activity-note   { font-style: italic; }
.activity-time   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Type stat rows */
.type-stat-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.type-stat-label  { width: 140px; flex-shrink: 0; }
.type-stat-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.type-stat-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .5s;
}
.type-stat-num { width: 60px; text-align: right; font-size: 13px; }

/* Quick Actions */
.quick-actions { margin-top: 24px; }
.quick-actions h3 { margin-bottom: 12px; font-size: 16px; }
.quick-actions-grid {
    display: flex; gap: 12px; flex-wrap: wrap;
}
.quick-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: all .2s;
    min-width: 100px;
    box-shadow: var(--shadow-sm);
}
.quick-action-btn:hover { background: var(--primary); color: #fff; transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.qa-icon  { font-size: 24px; }
.qa-label { font-size: 13px; font-weight: 500; text-align: center; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Status badges */
.status-pending  { background: #fef9c3; color: #854d0e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-working  { background: #dbeafe; color: #1e40af; }
.status-qc       { background: #f3e8ff; color: #6b21a8; }
.status-review   { background: #e0f2fe; color: #075985; }
.status-parts    { background: #fff7ed; color: #9a3412; }
.status-rework   { background: #fef2f2; color: #991b1b; }
.status-rejected { background: #fef2f2; color: #991b1b; }
.status-closed   { background: #f0fdf4; color: #14532d; }
.status-default  { background: var(--bg-hover); color: var(--text-muted); }

/* Type badges */
.type-jig     { background: #dbeafe; color: #1e40af; }
.type-die     { background: #f3e8ff; color: #6b21a8; }
.type-machine { background: #ffedd5; color: #9a3412; }
.type-welding { background: #fef2f2; color: #991b1b; }
.type-factory { background: #dcfce7; color: #166534; }

/* Urgency badges */
.badge-low      { background: #dcfce7; color: #166534; }
.badge-medium   { background: #fef9c3; color: #854d0e; }
.badge-high     { background: #fee2e2; color: #dc2626; }
.badge-critical { background: #ede9fe; color: #7c3aed; }

/* Special badges */
.badge-escalated { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.badge-rework    { background: #f3e8ff; color: #7c3aed; }
.badge-role      { background: var(--bg-hover); color: var(--text-muted); }

/* ============================================================
   Tables
   ============================================================ */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.row-critical { background: #fff5f5 !important; }
.row-escalated { background: #fff9f0 !important; border-left: 3px solid #f97316 !important; }
.row-inactive  { opacity: .6; }
.row-new-flash     { animation: rowFlashNew 2s ease-out; }
.row-updated-flash { animation: rowFlashUpdated 2s ease-out; }
@keyframes rowFlashNew     { 0%,20% { background:#d1fae5!important; } 100% { background:transparent; } }
@keyframes rowFlashUpdated { 0%,20% { background:#fef3c7!important; } 100% { background:transparent; } }
.stat-updated { animation: statPop .6s ease; }
@keyframes statPop { 0% { transform:scale(1); } 50% { transform:scale(1.08); } 100% { transform:scale(1); } }
.ticket-link   { font-weight: 600; font-family: monospace; color: var(--primary); }
.ticket-title-cell { display: flex; align-items: center; gap: 6px; }
.rework-badge  { font-size: 11px; background: #f3e8ff; color: #7c3aed; padding: 1px 6px; border-radius: 10px; }
.escalated-icon { font-size: 14px; }
.sla-time  { font-size: 12px; color: var(--text-muted); }
.sla-open  { color: #f97316; }
.sla-closed { color: var(--success); }

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 14px; color: var(--text-muted); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 20px;
    text-align: center;
}
.empty-card .empty-icon { font-size: 60px; }

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.filter-group     { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.filter-dates     { flex-direction: row; align-items: center; gap: 8px; }
.filter-actions   { flex-direction: row; align-items: flex-end; gap: 6px; }

/* ============================================================
   Type Selector (Create Ticket)
   ============================================================ */
.type-selector {
    display: flex; gap: 12px; flex-wrap: wrap;
}
.type-option {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all .2s;
    min-width: 100px;
    text-align: center;
}
.type-option input[type=radio] { display: none; }
.type-option:hover    { border-color: var(--primary); background: var(--primary-light); }
.type-option.selected { border-color: var(--primary); background: var(--primary-light); }
.type-option-icon     { font-size: 28px; }
.type-option-name     { font-weight: 600; font-size: 14px; }
.type-option-desc     { font-size: 11px; color: var(--text-muted); }

/* Workflow preview */
.workflow-preview {
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--primary-light);
    border-radius: var(--radius);
    border: 1px solid #bfdbfe;
}
.workflow-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.workflow-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.workflow-step  { font-size: 12px; padding: 3px 8px; background: #fff; border-radius: 4px; }
.workflow-arrow { color: var(--primary); font-size: 12px; }

/* Urgency Selector */
.urgency-selector { display: flex; gap: 10px; flex-wrap: wrap; }
.urgency-option {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .2s;
    flex: 1; min-width: 110px; text-align: center;
}
.urgency-option input[type=radio] { display: none; }
.urgency-option:hover    { border-color: currentColor; }
.urgency-option.selected { border-width: 2px; }
.urgency-icon   { font-size: 22px; }
.urgency-name   { font-weight: 600; font-size: 14px; }
.urgency-desc   { font-size: 11px; color: var(--text-muted); }
.urgency-low.selected      { border-color: #22c55e; background: #f0fdf4; }
.urgency-medium.selected   { border-color: #f59e0b; background: #fefce8; }
.urgency-high.selected     { border-color: #dc2626; background: #fee2e2; }
.urgency-critical.selected { border-color: #7c3aed; background: #ede9fe; }
.urgency-selector-sm .urgency-option { padding: 8px 12px; flex-direction: row; }

/* Zone Map */
.zone-map {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.zone-cell {
    padding: 10px 8px;
    border: 2px solid;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: all .2s;
}
.zone-cell:hover   { transform: scale(1.05); box-shadow: var(--shadow); }
.zone-selected     { transform: scale(1.05); box-shadow: 0 0 0 3px var(--primary); }
.zone-code         { display: block; font-weight: 700; font-size: 14px; }
.zone-name         { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* File Upload */
.upload-area {
    border: 2px dashed var(--border-input);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--bg);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-icon { font-size: 36px; display: block; margin-bottom: 8px; }
.file-input-hidden { display: none; }
.file-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-preview-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}
.file-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.file-name  { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size  { color: var(--text-muted); font-size: 11px; }

/* ============================================================
   Ticket Detail
   ============================================================ */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}
.detail-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px; flex-wrap: wrap;
}
.detail-card-header h3 { font-size: 15px; font-weight: 600; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-info-grid { padding: 16px 20px; }
.info-row {
    display: grid; grid-template-columns: 160px 1fr;
    gap: 8px; padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-weight: 500; color: var(--text-muted); }
.info-value { color: var(--text); }
.detail-description { padding: 0 20px 16px; }
.detail-description h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; margin-top: 12px; }

/* Progress Stepper */
.progress-stepper {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.stepper-step {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    min-width: 80px;
}
.stepper-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    border: 2px solid var(--border);
}
.stepper-step.done .stepper-dot    { background: var(--success); color: #fff; border-color: var(--success); }
.stepper-step.current .stepper-dot { background: var(--primary); color: #fff; border-color: var(--primary); }
.stepper-label { font-size: 11px; text-align: center; color: var(--text-muted); }
.stepper-step.done .stepper-label, .stepper-step.current .stepper-label { color: var(--text); font-weight: 500; }
.stepper-line { flex: 1; height: 2px; background: var(--border); min-width: 30px; }
.stepper-line.done { background: var(--success); }

/* Action Panel */
.action-panel {
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.action-panel-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.action-form { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.action-form:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Timeline */
.timeline { padding: 16px 20px; }
.timeline-item {
    display: flex; gap: 12px;
    padding-bottom: 16px;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 9px; top: 24px; bottom: -4px;
    width: 2px;
    background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    width: 20px; height: 20px;
    background: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
    border: 3px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary);
}
.timeline-content { flex: 1; padding-bottom: 4px; }
.timeline-action { font-size: 14px; font-weight: 500; }
.timeline-role   { font-size: 12px; color: var(--text-muted); }
.timeline-text   { font-size: 13px; margin-top: 2px; }
.timeline-status { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.timeline-notes  { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.timeline-time   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Approval items */
.approval-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid;
}
.approval-item.approved { background: #f0fdf4; border-color: #bbf7d0; }
.approval-item.rejected { background: #fef2f2; border-color: #fecaca; }
.approval-header { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.approval-result { font-weight: 700; }
.approval-reason { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Repair logs */
.repair-logs { padding: 16px 20px; }
.repair-log-item {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.log-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.log-time   { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.log-desc   { font-size: 13px; }

/* Inspection items */
.inspection-item {
    padding: 12px 20px;
    border-radius: var(--radius);
    margin: 8px 16px;
    border: 1px solid;
}
.insp-pass { background: #f0fdf4; border-color: #bbf7d0; }
.insp-fail { background: #fef2f2; border-color: #fecaca; }
.insp-header { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-wrap: wrap; }
.insp-result { font-weight: 700; font-size: 15px; }
.insp-notes  { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* Attachments */
.attachment-list { padding: 12px 16px; }
.attachment-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    background: var(--bg);
}
.attachment-icon  { font-size: 24px; }
.attachment-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.attachment-info  { flex: 1; }
.attachment-name  { display: block; font-size: 13px; font-weight: 500; color: var(--primary); }
.attach-form      { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ============================================================
   Approval List (Approve Page)
   ============================================================ */
.approval-list { display: flex; flex-direction: column; gap: 20px; }
.approval-ticket-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-critical { border-left: 4px solid var(--danger); }
.card-escalated { border-left: 4px solid #f97316; }
.approval-card-header {
    padding: 12px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.approval-card-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ticket-num-link { font-weight: 700; font-family: monospace; color: var(--primary); font-size: 15px; }
.approval-wait-time  { font-size: 13px; color: var(--text-muted); }
.approval-card-body  { display: grid; grid-template-columns: 1fr 280px; gap: 0; }
.approval-ticket-info { padding: 20px; border-right: 1px solid var(--border); }
.approval-ticket-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.approval-ticket-desc  { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.approval-meta-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.meta-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.meta-icon { font-size: 18px; }
.approval-actions  { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.approval-form     { display: flex; flex-direction: column; gap: 8px; }
.approval-divider  { text-align: center; color: var(--text-muted); font-size: 12px; padding: 4px 0; }

/* ============================================================
   Kanban Board
   ============================================================ */
.kanban-board {
    display: flex; gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}
.kanban-col {
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex-shrink: 0;
}
.kanban-col-header {
    padding: 10px 14px;
    font-size: 13px; font-weight: 600;
    display: flex; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.kanban-count {
    background: rgba(255,255,255,.3);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 12px;
}
.kanban-cards    { padding: 8px; min-height: 100px; }
.kanban-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .2s, transform .2s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.kanban-card-critical { border-left: 3px solid var(--danger); }
.kanban-ticket-num { font-size: 11px; font-family: monospace; color: var(--primary); font-weight: 600; }
.kanban-title  { font-size: 13px; font-weight: 500; margin: 4px 0; line-height: 1.4; }
.kanban-meta   { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.kanban-zone   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kanban-date   { font-size: 11px; color: var(--text-muted); }
.kanban-empty  { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* View Toggle */
.view-toggle   { display: flex; gap: 4px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
}
.modal-box-lg { max-width: 720px; }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--text-muted);
    padding: 4px; border-radius: var(--radius-sm);
    text-decoration: none;
}
.modal-close:hover { color: var(--danger); text-decoration: none; }
.modal-body { padding: 20px; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 4px solid;
}
.alert ul { margin: 6px 0 0 18px; }
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-danger  { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-warning { background: #fefce8; border-color: var(--warning); color: #854d0e; }
.alert-info    { background: #eff6ff; border-color: var(--primary); color: #1e40af; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px; right: 20px;
    z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    max-width: 340px;
    font-size: 14px;
    display: flex; align-items: center; gap: 10px;
    animation: slideInRight .3s ease;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ============================================================
   Login Page
   ============================================================ */
.login-body {
    background: linear-gradient(135deg, #1e293b, #334155);
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-logo {
    text-align: center;
    margin-bottom: 24px;
    color: #fff;
}
.logo-icon    { font-size: 52px; display: block; margin-bottom: 8px; }
.logo-title   { font-size: 22px; font-weight: 700; color: #fff; margin: 0; }
.logo-subtitle { font-size: 13px; color: #94a3b8; }
.login-card {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .login-card { background: var(--bg-card); }
.login-card-header { margin-bottom: 24px; text-align: center; }
.login-card-header h2 { font-size: 20px; margin-bottom: 4px; }
.login-card-header p  { color: var(--text-muted); font-size: 14px; }
.login-demo {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.login-demo summary { cursor: pointer; color: var(--primary); }
.demo-accounts { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.demo-account {
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
}
.demo-account:hover { background: var(--primary-light); }
.login-footer { margin-top: 16px; text-align: center; }

/* ============================================================
   Reports / Charts
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.chart-card-wide { grid-column: 1 / -1; }
.chart-card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.chart-card-header h3 { font-size: 15px; font-weight: 600; }
.chart-wrapper { padding: 16px; max-height: 300px; }

.progress-bar-wrap {
    display: flex; align-items: center; gap: 8px;
    height: 20px;
}
.progress-bar-fill {
    height: 8px; border-radius: 4px;
    background: var(--primary);
    transition: width .5s;
}

.top-issue-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.top-issue-rank  { font-weight: 700; color: var(--text-muted); width: 20px; }
.top-issue-title { flex: 1; }
.top-issue-count { color: var(--text-muted); }

/* ============================================================
   Admin / Settings
   ============================================================ */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    transition: all .2s;
}
.tab-btn:hover  { background: var(--bg-hover); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-content    { display: block; }

.settings-grid   { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; align-items: start; }
.settings-card   {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.settings-card-wide { grid-column: 1 / -1; }
.settings-card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.zone-visual-map { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.zone-visual-cell {
    padding: 8px 12px;
    border: 2px solid;
    border-radius: var(--radius);
    text-align: center;
    min-width: 80px;
}
.zone-inactive { opacity: .5; }
.zone-name-small { display: block; font-size: 11px; color: var(--text-muted); }

.info-table-simple { width: 100%; font-size: 14px; }
.info-table-simple td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-table-simple tr:last-child td { border-bottom: none; }
.quick-links { display: flex; flex-direction: column; gap: 8px; }
.quick-link-btn {
    display: block; padding: 10px 14px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px;
    color: var(--text); text-decoration: none;
    transition: all .2s;
}
.quick-link-btn:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
    background: var(--bg-navbar);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    margin-left: var(--sidebar-w);
    font-size: 12px;
    color: var(--text-muted);
}
.footer-content { display: flex; justify-content: space-between; }

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1000;
    align-items: center; justify-content: center;
}
.loading-overlay.is-active {
    display: flex;
}
.loading-spinner { text-align: center; color: #fff; }
.spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Utility Classes
   ============================================================ */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.hidden       { display: none !important; }
hr            { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .detail-layout { grid-template-columns: 1fr; }
    .approval-card-body { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); --sidebar-w: 240px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; max-width: 100vw; padding: 12px; }
    .app-footer   { margin-left: 0; }
    .form-grid    { grid-template-columns: 1fr; }
    .user-name, .user-role, .brand-sub { display: none; }
    .type-selector { justify-content: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .kanban-board { flex-direction: column; }
    .kanban-col   { min-width: auto; }
    .filter-bar   { flex-direction: column; }

    /* ---- Mobile card-table: แปลง data-table เป็น card rows ---- */
    .data-table thead        { display: none; }
    .data-table,
    .data-table tbody        { display: block; width: 100%; }
    .data-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 10px;
        background: var(--bg-card);
        overflow: hidden;
    }
    .data-table tbody tr.row-escalated { border-left: 3px solid #f97316; }
    .data-table tbody tr.row-critical  { background: #fff5f5; }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 14px;
        border-bottom: 1px solid var(--border);
        font-size: 13px;
        gap: 8px;
        min-height: 0;
        white-space: normal;
    }
    .data-table tbody td:last-child  { border-bottom: none; }
    .data-table tbody td[data-label=""] { justify-content: flex-end; }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        color: var(--text-muted);
        flex-shrink: 0;
        min-width: 72px;
    }
    .data-table tbody td[data-label=""]::before { display: none; }
    /* ตัวเลข/ลิงก์หัวใจความ align ขวา */
    .data-table tbody td .ticket-link { text-align: right; }
    /* ปิด overflow scroll เพราะ card แล้ว */
    .table-responsive { overflow-x: visible; }
    .table-card       { overflow: visible; }

    /* ---- filter bar ---- */
    .filter-group      { min-width: 0; flex: 1 1 100%; }
    .filter-dates      { flex: 1 1 100%; }
    .filter-actions    { flex: 1 1 100%; }

    /* ---- info-row ใน detail page ---- */
    .info-row { grid-template-columns: 1fr; gap: 2px; padding: 9px 0; }
    .info-label { font-size: 12px; }

    /* ---- page title ---- */
    .page-title h1 { font-size: 18px; }

    /* ---- view-toggle ซ่อนบน mobile (card เพียงพอ) ---- */
    .view-toggle { display: none; }

    /* ---- approval card body ---- */
    .approval-card-body { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-actions { width: 100%; }
    .page-actions .btn { width: 100%; text-align: center; }
    .main-content { padding: 10px; }
    .charts-grid { grid-template-columns: 1fr; }
}

/* Notification dropdown: ไม่ล้น mobile */
@media (max-width: 400px) {
    .notif-dropdown { width: calc(100vw - 32px); right: -60px; }
    .user-dropdown  { width: calc(100vw - 32px); right: -16px; }
}

/* Touch-friendly: minimum 44px hit targets */
.btn, .btn-sm, .btn-link, .nav-item, .notif-item, .dropdown-item,
.tab-btn, .notif-page-item { min-height: 44px; }

/* Table horizontal scroll hint */
.table-responsive { position: relative; }
.table-responsive::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,.04));
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s;
}
@media (max-width: 768px) {
    .table-responsive::after { opacity: 1; }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    .navbar, .sidebar, .app-footer, .no-print,
    .page-actions, .filter-bar, .action-panel,
    .btn, .quick-actions { display: none !important; }

    .main-content { margin: 0; padding: 0; max-width: 100%; }
    .app-layout   { display: block; padding-top: 0; }
    body          { background: #fff; color: #000; font-size: 12px; }
    .detail-layout { grid-template-columns: 1fr; }
    .detail-card, .table-card, .dashboard-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
    a { color: #000; text-decoration: none; }
    .badge { border: 1px solid #ccc; }
}
