/* =========================================================
   A PLUS ME — Design System
   Brand: Navy (#16284d) + Gold (#c79a3f) from Logo
   ========================================================= */

/* ── Design Tokens ── */
:root {
    /* Brand: Navy */
    --navy-50:  #eaecf2;
    --navy-100: #c9cfde;
    --navy-200: #a5b1c8;
    --navy-300: #8192b2;
    --navy-400: #667ba1;
    --navy-500: #4b6491;
    --navy-600: #435c89;
    --navy-700: #38507e;
    --navy-800: #2e4472;
    --navy-900: #16284d;

    /* Brand: Gold */
    --gold-50:  #fdf8ee;
    --gold-100: #f9ecd4;
    --gold-200: #f5dfb8;
    --gold-300: #f0d29c;
    --gold-400: #edc888;
    --gold-500: #e9be74;
    --gold-600: #c79a3f;
    --gold-700: #a57e38;
    --gold-800: #846331;
    --gold-900: #533c1f;

    /* Brand: Accent (Royal Blue) */
    --accent:       #2563eb;
    --accent-hover: #1d4ed8;

    /* Backgrounds & Surfaces */
    --bg:               #f9fafb; /* Extremely clean light gray */
    --surface-1:        #ffffff;
    --surface-2:        #f3f4f6;
    --surface-elevated: #ffffff;

    /* Text */
    --text:           #111827;
    --text-secondary: #4b5563;
    --muted:          #9ca3af;
    --faint:          #b3bac4;

    /* Semantic status tokens — เดิม "ถูกใช้" 30+ จุด (.status-ok, .alert, .flag ฯลฯ) แต่ไม่เคยนิยาม
       ทำให้ badge/alert สถานะฝั่งเจ้าหน้าที่เรนเดอร์จืด (พื้นโปร่ง/สีตกทอด) แบบเงียบๆ */
    --ok:         #16a34a;
    --ok-bg:      #f0fdf4;
    --warning:    #b45309;
    --warning-bg: #fffbeb;
    --danger:     #dc2626;
    --danger-bg:  #fef2f2;
    --info:       #1d4ed8;
    --info-bg:    #eff6ff;

    /* Borders */
    --border:         #e5e7eb;
    --border-hover:   #d1d5db;

    /* Shape */
    --radius:    8px;
    --radius-sm: 4px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadow (Crisp & Diffuse) */
    --shadow-sm:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow:     0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md:  0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-lg:  0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

    /* Spacing (8pt grid) */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Transitions */
    --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Sidebar */
    --sidebar-width: 256px;
    --sidebar-collapsed: 0px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.ambient-mesh {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    overflow: hidden;
    background: #fdfdfe;
}
.mesh-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: floatBlob 15s ease-in-out infinite alternate;
}
.blob-1 {
    width: 600px; height: 600px;
    background: #e0e7ff;
    top: -200px; left: -200px;
}
.blob-2 {
    width: 500px; height: 500px;
    background: #dcfce7;
    bottom: -100px; right: -100px;
    animation-delay: -5s;
}
.blob-3 {
    width: 400px; height: 400px;
    background: #ffedd5;
    top: 30%; left: 40%;
    animation-delay: -10s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

@keyframes tableRowEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

a { color: var(--navy-600); }
a:hover { color: var(--navy-800); }

h1, h2, h3 {
    letter-spacing: -0.025em;
    line-height: 1.25;
    color: var(--navy-900);
}

/* ── Page Entry Animation ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes goldShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

@keyframes cascadeUp {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(199, 154, 63, 0.3); }
    50%      { box-shadow: 0 0 0 8px rgba(199, 154, 63, 0); }
}

/* ── Utility ── */
.spin { animation: spin 1s linear infinite; display: inline-block; }
.skeleton {
    background: linear-gradient(90deg, var(--navy-50) 25%, #f4f6fb 50%, var(--navy-50) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

/* =========================================================
   BRAND
   ========================================================= */
.brand-mark {
    font-weight: 800;
    color: var(--navy-900);
    letter-spacing: -1px;
}
.brand-mark.big { font-size: 56px; }
.brand-plus { color: var(--gold-600); }

.brand-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}
.brand-logo.big {
    height: 90px;
}

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--navy-900);
    padding: 0 var(--space-xl);
    height: 64px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    position: sticky;
    top: 0;
    z-index: 100;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.topbar .brand-mark { color: var(--navy-900); font-size: 24px; }
.brand-name {
    color: var(--navy-900);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topnav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.topnav a:hover {
    color: var(--navy-900);
    background: rgba(0,0,0,0.03);
}
.who {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-right: 1px solid var(--border);
    margin-right: 8px;
    font-weight: 500;
}
.role { color: var(--gold-600); font-weight: 700; }
.logout-form { margin: 0; }
.btn-link {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s var(--ease-out);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-link:hover {
    background: var(--surface-2);
    border-color: rgba(0,0,0,0.15);
    color: var(--danger);
}

/* =========================================================
   SIDEBAR NAVIGATION
   ========================================================= */
.app-layout {
    display: flex;
    min-height: calc(100vh - 64px);
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg);
    gap: var(--space-lg);
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-xl);
    padding: var(--space-md);
    flex-shrink: 0;
    position: sticky;
    top: calc(64px + var(--space-lg));
    height: calc(100vh - 64px - var(--space-lg) * 2);
    overflow-y: auto;
    z-index: 10;
}

.sidebar-section {
    padding: var(--space-sm) var(--space-xs);
    margin-top: var(--space-xs);
}
.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 0 var(--space-sm);
    margin-bottom: 8px;
    margin-top: 24px;
}

.sidebar a, .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #475569;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.4s var(--ease-bounce);
    margin-bottom: 2px;
    position: relative;
}
.sidebar a:hover {
    background: rgba(255, 255, 255, 0.8);
    color: var(--accent);
    transform: translateX(6px) scale(1.02);
}
.sidebar a:active:not(.active) {
    transform: scale(0.95);
}
.sidebar a.active {
    background: #ffffff;
    color: var(--accent);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
}
.sidebar a.active::before {
    display: none;
}
.sidebar a .sidebar-icon {
    width: 18px;
    height: 18px;
    color: #64748b;
    flex-shrink: 0;
    transition: color 0.15s ease;
}
.sidebar a:hover .sidebar-icon {
    color: var(--accent);
}
.sidebar a.active .sidebar-icon {
    color: var(--accent);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: var(--space-lg) var(--space-sm);
}

/* =========================================================
   LAYOUT
   ========================================================= */
.page {
    flex: 1;
    max-width: 1120px;
    margin: var(--space-xl) auto;
    padding: 0 var(--space-xl);
    animation: fadeInUp 0.35s var(--ease-out);
    width: 100%;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    margin-bottom: var(--space-lg);
    transition: all 0.4s var(--ease-bounce);
}
.glass-panel:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 30px rgba(0,0,0,0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 40%, #2d4672 100%);
    position: relative;
    overflow: hidden;
}
/* Subtle decorative pattern on login */
.page-center::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(199,154,63,.12) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    pointer-events: none;
}
.page-center::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(199,154,63,.08) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
    pointer-events: none;
}

/* breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: var(--space-md);
}
.breadcrumb a {
    color: var(--navy-500);
    text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); }

/* =========================================================
   LOGIN
   ========================================================= */
.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 400px;
    padding: 40px 36px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 80px rgba(22, 40, 77, .08);
    border-top: 4px solid var(--gold-600);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.5s var(--ease-out);
}
.login-logo {
    text-align: center;
    margin-bottom: var(--space-lg);
}
.login-title {
    font-weight: 700;
    color: var(--navy-900);
    margin-top: 8px;
    font-size: 18px;
}
.login-sub {
    color: var(--gold-600);
    letter-spacing: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-form label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}
.pin-input {
    font-size: 26px;
    text-align: center;
    letter-spacing: 10px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    transition: all 0.3s ease;
    background: var(--surface-2);
}
.pin-input:focus {
    border-color: var(--navy-500);
    box-shadow: 0 0 0 4px rgba(22, 40, 77, .1), 0 0 20px rgba(199, 154, 63, .08);
    background: #fff;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.4s var(--ease-bounce);
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}
.btn:active:not(:disabled) {
    transform: scale(0.92) translateY(2px);
}
.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    border: 1px solid var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    color: #ffffff;
    transform: translateY(-3px) scale(1.03);
}
.btn-secondary {
    background: linear-gradient(180deg, var(--gold-400) 0%, var(--gold-500) 100%);
    color: #3a2b0e;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(199, 154, 63, .2), inset 0 1px 1px rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(199, 154, 63, 0.8);
}
.btn-secondary:hover {
    background: linear-gradient(180deg, var(--gold-300) 0%, var(--gold-400) 100%);
    box-shadow: 0 4px 12px rgba(199, 154, 63, .3), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    color: #3a2b0e;
    transform: translateY(-3px) scale(1.03);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.btn-outline:hover {
    border-color: rgba(0,0,0,0.15);
    background: var(--surface-2);
    color: var(--navy-900);
}
.btn-danger {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none !important;
}
.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: var(--space-md);
    animation: slideDown 0.3s var(--ease-out);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}
.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}
.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
}
.alert-ok {
    background: var(--ok-bg);
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}
.alert-info {
    background: var(--info-bg);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* =========================================================
   DASHBOARD
   ========================================================= */
.welcome h1 {
    margin: 0 0 6px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-600) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); }

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: var(--space-lg);
    margin: var(--space-lg) 0;
}

.bento-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: var(--space-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
    transition: all 0.4s var(--ease-bounce);
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}
.bento-card:nth-child(1) { animation-delay: 0.05s; }
.bento-card:nth-child(2) { animation-delay: 0.10s; }
.bento-card:nth-child(3) { animation-delay: 0.15s; }
.bento-card:nth-child(4) { animation-delay: 0.20s; }
.bento-card:nth-child(5) { animation-delay: 0.25s; }
.bento-card:nth-child(6) { animation-delay: 0.30s; }

a.bento-card:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.85);
    border-color: #ffffff;
}
a.bento-card:active {
    transform: scale(0.96);
}

.bento-hero { grid-column: span 8; grid-row: span 2; padding: 40px; justify-content: space-between; }
.bento-soon { grid-column: span 4; grid-row: span 2; background: linear-gradient(135deg, rgba(248, 250, 252, 0.7), rgba(241, 245, 249, 0.7)); }
.bento-std  { grid-column: span 3; grid-row: span 1; }

.bento-card .fc-icon {
    width: 48px; height: 48px; font-size: 24px; margin-bottom: 16px;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s ease;
}
.bento-hero .fc-icon { width: 64px; height: 64px; font-size: 32px; border-radius: 16px; margin-bottom: 24px; }
a.bento-card:hover .fc-icon { transform: scale(1.1) rotate(-5deg); }

.bc-content { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; }
.bc-text h2 { margin: 0 0 8px 0; font-size: 28px; color: var(--navy-900); letter-spacing: -0.02em; }
.bc-text h3 { margin: 0 0 4px 0; font-size: 18px; color: var(--navy-900); font-weight: 600; }
.bc-text p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.4; }

.bc-bg-glow {
    position: absolute;
    top: -50%; right: -20%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(37,99,235,0.1) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 1;
}
.bc-arrow {
    position: absolute; bottom: 40px; right: 40px;
    color: var(--accent); opacity: 0; transform: translateX(-10px);
    transition: all 0.3s ease;
}
.bento-hero:hover .bc-arrow { opacity: 1; transform: translateX(0); }

.fc-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 20px;
    transition: all 0.2s ease;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.fc-icon-navy    { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.fc-icon-gold    { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.fc-icon-ok      { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.fc-icon-warning { background: #fff7ed; color: #ea580c; border-color: #fed7aa; }
.fc-icon-info    { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.fc-icon-danger  { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

.fc-title {
    font-weight: 600;
    color: var(--navy-900);
    font-size: 15px;
}
.fc-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.4;
}

.badge-soon {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid #fde68a;
    margin-top: 8px;
}

/* =========================================================
   STAT CARDS
   ========================================================= */
.stat {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy-900);
    margin-top: 4px;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    overflow-wrap: break-word;
    word-break: break-word;
}
.ok-text { color: var(--ok); font-weight: 600; }
.card-ok { border-color: var(--ok); border-left: 4px solid var(--ok); }
.card-ok .stat { color: var(--ok); }
.card-bad { border-color: var(--danger); border-left: 4px solid var(--danger); }
.card-bad .stat { color: var(--danger); }

/* =========================================================
   FORMS
   ========================================================= */
.form-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow);
    max-width: 680px;
}
.field { margin-bottom: 20px; }
.field > label {
    display: block;
    font-weight: 600;
    color: var(--navy-800);
    margin-bottom: 6px;
    font-size: 14px;
}
.req { color: var(--danger); }
.input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(22, 40, 77, 0.15);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.4s var(--ease-bounce);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    background: #ffffff;
    transform: translateY(-2px) scale(1.01);
}
.input::placeholder { color: var(--muted); opacity: 0.6; }
select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 80px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.err { font-size: 13px; color: var(--danger); margin-top: 5px; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
    border: 1.5px solid var(--border);
    border-radius: 999px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    transition: all 0.2s ease;
    font-weight: 500;
}
.radio-pill:hover { border-color: var(--navy-300); background: var(--navy-50); }
.radio-pill.on {
    background: linear-gradient(135deg, var(--navy-800), var(--navy-900));
    color: #fff;
    border-color: var(--navy-800);
}
.radio-pill input { display: none; }
.form-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* File upload area */
input[type="file"].input {
    padding: 10px;
    cursor: pointer;
}
input[type="file"].input::file-selector-button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--navy-200);
    background: var(--navy-50);
    color: var(--navy-800);
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.15s ease;
}
input[type="file"].input::file-selector-button:hover {
    background: var(--navy-100);
}

/* =========================================================
   UPLOAD / TB
   ========================================================= */
.upload-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
}
.upload-form .field { margin-bottom: 12px; }

/* =========================================================
   DATA TABLES
   ========================================================= */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: visible; /* เดิม hidden — เปลี่ยนให้ sticky thead ทำงาน (มุมโค้งใช้ radius ราย cell แทน) */
}
.data-table th, .data-table td {
    text-align: left;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(22, 40, 77, 0.06);
    font-size: 13.5px;
    vertical-align: middle;
}
.data-table th {
    color: var(--navy-800);
    background: #ffffff; /* Solid background */
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;  /* หัวตารางติดบนเวลาเลื่อนดูตารางยาว (TB 100+ บัญชี); reset เป็น static บนมือถือแล้ว (1290) */
    top: 64px;         /* ใต้ .topbar (sticky สูง 64px) */
    z-index: 5;        /* เหนือ cell ใน body แต่ใต้ topbar (z-index 100) */
}
.data-table th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.data-table th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.data-table tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
.data-table tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }
.data-table tbody tr {
    transition: all 0.15s ease;
    opacity: 0;
    animation: tableRowEnter 0.4s ease forwards;
}
.data-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.data-table tbody tr:nth-child(2) { animation-delay: 0.10s; }
.data-table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.data-table tbody tr:nth-child(4) { animation-delay: 0.20s; }
.data-table tbody tr:nth-child(5) { animation-delay: 0.25s; }

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: inset 3px 0 0 var(--accent);
}
.data-table tr:last-child th,
.data-table tr:last-child td { border-bottom: none; }
.data-table a {
    color: var(--navy-600);
    font-weight: 500;
}
.data-table a:hover { color: var(--navy-900); }

.tb-table td, .tb-table th {
    padding: 8px 12px;
    font-size: 13px;
}
.tb-table .num, .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    white-space: nowrap;
}

/* =========================================================
   FINANCIAL STATEMENTS
   ========================================================= */
.stmt-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-xl) var(--space-xl);
    margin: var(--space-md) 0;
}
.stmt-head { text-align: center; margin-bottom: 18px; }
.stmt-co { font-weight: 700; color: var(--navy-900); font-size: 16px; }
.stmt-title { font-weight: 700; color: var(--navy-900); font-size: 20px; margin-top: 4px; }
.stmt-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.stmt { width: 100%; border-collapse: collapse; font-size: 14px; }
.stmt td { padding: 6px 8px; }
.stmt td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    white-space: nowrap;
    width: 180px;
}
.stmt tr.sec > td:first-child {
    font-weight: 600;
    color: var(--navy-800);
    padding-top: 12px;
}
.stmt td.ind {
    padding-left: 28px;
    color: var(--text-secondary);
}
.stmt tr.bold td {
    font-weight: 700;
    color: var(--navy-900);
}
.stmt tr.topline td.num {
    border-top: 1.5px solid var(--navy-200);
}
.stmt tr.grp td {
    font-weight: 700;
    color: var(--gold-700);
    border-bottom: 2px solid var(--gold-500);
    padding-top: 16px;
    font-size: 16px;
}
.stmt tbody tr {
    transition: background-color 0.1s ease;
}
.stmt tbody tr:hover {
    background: var(--navy-50);
}
/* บรรทัดกลุ่มที่กดขยายดูรายการย่อยได้ */
.stmt tr.grp-row { cursor: pointer; }
.stmt tr.grp-row td.ind { color: var(--navy-800); font-weight: 600; }
.stmt .grp-caret {
    display: inline-block;
    margin-left: -16px;
    margin-right: 6px;
    font-size: 11px;
    color: var(--navy-500);
    transition: transform 0.15s ease;
}
.stmt tr.grp-row.open .grp-caret { transform: rotate(90deg); }
.stmt td.ind2 {
    padding-left: 44px;
    color: var(--muted);
    font-size: 13px;
}
.stmt tr.sub-row { background: var(--navy-50); }

/* =========================================================
   AI PROVIDER SWITCH (settings)
   ========================================================= */
.provider-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}
.provider-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--surface-2);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.provider-card.active {
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(199, 154, 63, 0.15);
    background: var(--surface-1);
}
.provider-head {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.provider-head input[type=radio] { width: 16px; height: 16px; accent-color: var(--gold-600); }
.provider-name { font-weight: 700; color: var(--navy-900); font-size: 16px; }
.provider-badge {
    display: none;
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--gold-700);
}
.provider-card.active .provider-badge { display: inline; }

/* =========================================================
   ANOMALY FLAGS
   ========================================================= */
.flag {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}
.flag:hover { box-shadow: var(--shadow-sm); }
.flag-red { background: var(--danger-bg); border-color: #fecaca; }
.flag-yellow { background: var(--warning-bg); border-color: #fde68a; }
.flag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex: 0 0 auto;
}
.flag-red .flag-dot { background: var(--danger); }
.flag-yellow .flag-dot { background: var(--warning); }
.flag input[type="checkbox"] {
    margin-top: 4px;
    accent-color: var(--navy-700);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* =========================================================
   SECTION CARD (selftest → section-card)
   ========================================================= */
.selftest, .section-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    margin-top: var(--space-md);
}
.selftest h2, .section-card h2 {
    margin: 0 0 8px;
    font-size: 17px;
    color: var(--navy-900);
    display: flex;
    align-items: center;
    gap: 8px;
}
.job-status {
    margin-top: 12px;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    font-size: 13px;
    color: var(--text);
    min-height: 18px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

code {
    background: var(--navy-50);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    color: var(--navy-800);
}

/* =========================================================
   STATUS BADGES
   ========================================================= */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
}
.status-ok      { background: var(--ok-bg);      color: var(--ok);     border: 1px solid #bbf7d0; }
.status-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.status-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; }
.status-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #bfdbfe; }
.status-muted   { background: var(--surface-2);  color: var(--muted);   border: 1px solid var(--border); }

/* =========================================================
   PROCESSING / LOADING STATE
   ========================================================= */
.processing-card {
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
}
.processing-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--navy-100);
    border-top-color: var(--gold-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-md);
}
.processing-text {
    color: var(--navy-700);
    font-weight: 600;
    font-size: 16px;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    color: var(--muted);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.4;
}

/* =========================================================
   PAGE HEADER (flex title + actions)
   ========================================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; }
.page-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* =========================================================
   BACK LINK
   ========================================================= */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    margin-top: var(--space-lg);
    transition: color 0.15s ease;
    font-weight: 500;
}
.back-link:hover {
    color: var(--navy-700);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* --- Large tablet --- */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .page { padding: 0 var(--space-lg); }
}

/* --- Tablet --- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .page {
        padding: 0 var(--space-md);
        margin: var(--space-md) auto;
    }
    .topbar {
        padding: 0 var(--space-md);
        height: 54px;
    }
    .topnav { gap: 4px; }
    .who { display: none; }
    .upload-grid { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .stmt-card { padding: var(--space-md); }

    .data-table th { position: static; }
}

/* --- Mobile --- */
@media (max-width: 480px) {
    .card-grid { grid-template-columns: 1fr; }
    .topbar {
        height: auto;
        padding: 10px var(--space-md);
        flex-wrap: wrap;
        gap: 8px;
    }
    .topnav { width: 100%; justify-content: flex-end; }
    .brand-name { font-size: 13px; }
    .brand-logo { height: 28px; }

    /* Table horizontal scroll */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 calc(-1 * var(--space-md));
        padding: 0 var(--space-md);
    }

    .stmt-card { padding: var(--space-md) 12px; }
    .stmt td.num { width: 130px; font-size: 13px; }

    .page-header { flex-direction: column; }
    .login-card { padding: 28px 24px; margin: 0 var(--space-sm); }

    .feature-card { padding: var(--space-md); }
}

/* =========================================================
   PRINT
   ========================================================= */
@media print {
    @page { margin: 14mm; }
    .topbar, .sidebar, .btn, form, .back-link, .selftest, .breadcrumb,
    .ambient-mesh, .page-actions, .alert, .ver-trail, .work-banner,
    .co-toolbar, .map-filterbar, .cf-warn { display: none !important; }
    .page, .page-center { max-width: 100%; margin: 0; padding: 0; box-shadow: none; }
    body { background: #fff; font-size: 11.5pt; color: #000; }
    a { color: #000; text-decoration: none; }
    .stmt-card { box-shadow: none; border: 1px solid #999; break-inside: avoid; page-break-inside: avoid; margin-bottom: 12px; }
    .stmt-card + .stmt-card { break-before: page; page-break-before: always; } /* แต่ละงบขึ้นหน้าใหม่ เก็บแฟ้มสะอาด */
    table.stmt td, .stmt-head .stmt-co, .stmt-head .stmt-title { color: #000; }
    tr.sub-row[hidden] { display: table-row !important; } /* กางบรรทัดย่อยที่ยุบไว้ ให้พิมพ์ครบ */
}

/* สถานะงานบริษัท (หน้ารายการ) — มี micro-animation */
.status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
    white-space: nowrap; line-height: 1;
    transition: transform 0.25s var(--ease-bounce), box-shadow 0.25s ease;
}
.status-pill:hover { transform: translateY(-1px) scale(1.04); }
.status-pill i { animation: none; }
.status-pulse { animation: statusPulse 2.2s ease-in-out infinite; }
.status-pulse i { animation: statusNudge 2.2s ease-in-out infinite; }
@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.0); }
    50%      { box-shadow: 0 0 0 4px rgba(245,158,11,0.16); }
}
@keyframes statusNudge {
    0%, 92%, 100% { transform: rotate(0deg); }
    96% { transform: rotate(-12deg); }
}

/* หน้าแมปบัญชี — filter + ไฮไลต์ fallback (ux) */
.map-filterbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
    background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius); padding:10px 16px; margin:14px 0; }
.map-toggle { display:inline-flex; align-items:center; gap:7px; font-size:13px; font-weight:600; color:var(--navy-700);
    cursor:pointer; user-select:none; padding:6px 12px; border-radius:999px; background:var(--surface-1); border:1px solid var(--border);
    transition:all 0.25s var(--ease-bounce); }
.map-toggle:hover { transform:translateY(-1px) scale(1.03); box-shadow:var(--shadow-sm); }
.map-toggle input { accent-color:var(--gold-600); }
tr.map-row { transition:background 0.3s ease, opacity 0.3s ease, transform 0.3s var(--ease-out); }
tr.map-fallback { background:rgba(220,38,38,0.05); }
tr.map-fallback:hover { background:rgba(220,38,38,0.09); }
tr.map-fallback td:first-child { box-shadow:inset 3px 0 0 #dc2626; }
tr.map-lowconf { background:rgba(217,119,6,0.06); }
tr.map-lowconf:hover { background:rgba(217,119,6,0.10); }
tr.map-lowconf td:first-child { box-shadow:inset 3px 0 0 #d97706; }
body.show-fb-only tr.map-ai { display:none; }
body.show-fb-only tr.map-row:not(.map-review) { display:none; }
.map-hidden { display:none !important; }

/* รายการปรับปรุง — ตัวเลขสมดุลเรียลไทม์ (ux) */
.adj-live { font-size:13.5px; padding:9px 14px; border-radius:var(--radius); transition:all 0.3s var(--ease-out);
    border:1px solid transparent; }
.adj-live.on-bal { background:#f0fdf4; color:#15803d; border-color:#bbf7d0; }
.adj-live.off-bal { background:#fffbeb; color:#92400e; border-color:#fde68a; }
.adj-live b { font-family:'IBM Plex Mono',monospace; }
.adj-live .t { font-weight:700; }
.adj-live.on-bal .t { animation: statusNudge 0.6s var(--ease-bounce); }

/* checklist ขั้นตอนก่อนอนุมัติ (ux) */
.appr-steps { list-style:none; margin:10px 0 16px; padding:0; display:flex; flex-direction:column; gap:8px; }
.appr-steps li { display:flex; align-items:center; gap:10px; font-size:14px; opacity:0; animation:fadeInUp 0.4s var(--ease-out) forwards; }
.appr-steps li:nth-child(1){animation-delay:.04s} .appr-steps li:nth-child(2){animation-delay:.10s}
.appr-steps li:nth-child(3){animation-delay:.16s} .appr-steps li:nth-child(4){animation-delay:.22s}
.appr-ico { width:24px; height:24px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex-shrink:0;
    transition:all 0.3s var(--ease-bounce); }
.appr-steps li.done { color:var(--navy-800); }
.appr-steps li.done .appr-ico { background:#dcfce7; color:#16a34a; animation:checkPop 0.4s var(--ease-bounce); }
.appr-steps li.pending { color:var(--muted); }
.appr-steps li.pending .appr-ico { background:var(--surface-2); color:var(--faint); }
@keyframes checkPop { 0%{transform:scale(0.4)} 60%{transform:scale(1.25)} 100%{transform:scale(1)} }

/* ด่านตรวจก่อนอนุมัติ (pre-flight gate) — hard checks ที่ต้องผ่านก่อนส่งงบถึงลูกค้า */
.preflight { margin:10px 0 16px; border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.pfl-head { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:600; color:var(--navy-800);
    background:var(--surface-2); padding:9px 14px; border-bottom:1px solid var(--border); }
.pfl-item { display:flex; align-items:flex-start; gap:11px; padding:11px 14px; font-size:14px; }
.pfl-item + .pfl-item { border-top:1px solid var(--border); }
.pfl-ico { flex-shrink:0; margin-top:1px; }
.pfl-txt { flex:1; line-height:1.5; }
.pfl-item.pfl-ok .pfl-ico { color:#16a34a; }
.pfl-item.pfl-ok .pfl-txt strong { color:var(--navy-800); }
.pfl-item.pfl-bad { background:#fef2f2; }
.pfl-item.pfl-bad .pfl-ico { color:#dc2626; }
.pfl-item.pfl-bad .pfl-txt strong { color:#b91c1c; }
.pfl-fix { flex-shrink:0; align-self:center; display:inline-flex; align-items:center; gap:5px; white-space:nowrap;
    font-size:12.5px; font-weight:600; color:#dc2626; text-decoration:none; border:1px solid #fca5a5;
    border-radius:8px; padding:5px 11px; transition:all .2s var(--ease-bounce); }
.pfl-fix:hover { background:#fee2e2; transform:translateY(-1px); }

/* ===== Reusable UI primitives (design system) — ใช้แทนการนิยาม card/panel/bar ซ้ำในแต่ละหน้า =====
   .panel = กล่องเนื้อหาขาว · .stat-card = การ์ดตัวเลข KPI · .meter = แท่งสัดส่วนแนวนอน
   หน้า portal ใช้ระบบแยก (--pt-* ไม่โหลด style.css นี้) — ไม่รวมในนี้ */
.panel { background:var(--surface-1); border:1px solid var(--border); border-radius:var(--radius-xl);
    padding:18px 20px; margin-bottom:16px; box-shadow:var(--shadow-sm); }
.panel > h2, .panel-title { font-size:15px; font-weight:700; color:var(--navy-900); margin:0 0 14px;
    display:flex; align-items:center; gap:8px; }
.panel > h2 i, .panel-title i { color:var(--gold-600); width:17px; height:17px; }

.stat-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:18px; }
@media (max-width:720px){ .stat-grid { grid-template-columns:repeat(2,1fr); } }
.stat-card { background:var(--surface-1); border:1px solid var(--border); border-radius:14px;
    padding:15px 17px; box-shadow:var(--shadow-sm); }
.stat-card .l { font-size:12.5px; color:var(--muted); font-weight:500; }
.stat-card .v { font-size:24px; font-weight:700; color:var(--navy-900); margin-top:4px; font-variant-numeric:tabular-nums; }
.stat-card .v.neg { color:#dc2626; }
.stat-card .s { font-size:11.5px; color:var(--faint); margin-top:2px; }

/* แท่งสัดส่วนแนวนอน: <div class="meter"><i style="width:NN%"></i></div> */
.meter { height:7px; background:var(--surface-2); border-radius:99px; overflow:hidden; }
.meter > i { display:block; height:100%; border-radius:99px;
    background:linear-gradient(90deg, var(--navy-700), var(--navy-500)); }
/* แถวป้าย + แท่ง + ตัวเลข (เช่น อันดับการใช้งาน) */
.meter-row { display:grid; grid-template-columns:1fr 84px; align-items:center; gap:12px; padding:9px 0; }
.meter-row + .meter-row { border-top:1px solid var(--border); }
.meter-row .nm { font-size:13.5px; color:var(--navy-900); font-weight:500; }
.meter-row .meter { margin-top:6px; }
.meter-row .met { text-align:right; font-family:'IBM Plex Mono',monospace; font-size:13px; color:var(--navy-800); font-weight:600; }
.meter-row .met small { display:block; font-size:10.5px; color:var(--faint); font-weight:400; font-family:inherit; }

/* ค้นหา/กรองรายชื่อบริษัท (ux) */
.co-toolbar { display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:14px; }
.co-search { display:flex; align-items:center; gap:9px; background:var(--surface-1); border:1px solid var(--border);
    border-radius:999px; padding:9px 16px; flex:1; min-width:240px; max-width:420px; color:var(--muted);
    transition:box-shadow .25s ease, border-color .25s ease; }
.co-search:focus-within { border-color:var(--gold-500); box-shadow:0 0 0 3px rgba(199,154,63,.15); }
.co-search input { border:none; outline:none; background:transparent; flex:1; font-size:14px; font-family:inherit; color:var(--navy-900); }
.co-chips { display:flex; gap:8px; flex-wrap:wrap; }
.co-chip { --chip:#2563eb; display:inline-flex; align-items:center; gap:7px; cursor:pointer; font-family:inherit;
    font-size:13px; font-weight:600; color:var(--text-secondary); background:var(--surface-1); border:1px solid var(--border);
    padding:7px 14px; border-radius:999px; transition:all .25s var(--ease-bounce); }
.co-chip span { font-size:11.5px; background:var(--surface-2); color:var(--muted); padding:1px 8px; border-radius:999px; min-width:20px; text-align:center; }
.co-chip:hover { transform:translateY(-1px); box-shadow:var(--shadow-sm); }
.co-chip.on { color:#fff; background:var(--chip); border-color:var(--chip); }
.co-chip.on span { background:rgba(255,255,255,.25); color:#fff; }
tr.co-row { transition:background .2s ease; }
.co-empty { text-align:center; padding:32px 20px; color:var(--muted); display:flex; flex-direction:column; align-items:center; gap:8px; }

/* แบนเนอร์งานค้าง หน้าแรกเจ้าหน้าที่ (ux) */
.work-banner { display:flex; align-items:center; gap:16px; text-decoration:none; border-radius:var(--radius-lg);
    padding:18px 22px; margin-bottom:18px; border:1px solid var(--border); box-shadow:var(--shadow-sm);
    transition:transform .25s var(--ease-bounce), box-shadow .25s ease; }
.work-banner:hover { transform:translateY(-2px); box-shadow:var(--shadow-md); }
.work-banner.has-work { background:linear-gradient(100deg,#fffbeb,#fff); border-color:#fde68a; }
.work-banner.all-clear { background:linear-gradient(100deg,#f0fdf4,#fff); border-color:#bbf7d0; }
.work-banner .wb-icon { width:48px; height:48px; border-radius:14px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.work-banner.has-work .wb-icon { background:#fef3c7; color:#b45309; animation:statusPulse 2.2s ease-in-out infinite; }
.work-banner.all-clear .wb-icon { background:#dcfce7; color:#16a34a; }
.work-banner .wb-icon i { width:24px; height:24px; }
.work-banner .wb-text { flex:1; }
.work-banner .wb-text h2 { font-size:19px; font-weight:700; color:var(--navy-900); margin:0; }
.work-banner .wb-text p { font-size:13px; color:var(--text-secondary); margin:3px 0 0; }
.work-banner .bc-arrow { color:var(--muted); }

/* ประวัติการอนุมัติงบ (audit trail) */
.ver-trail { margin-top:10px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius); padding:10px 14px; }
.ver-trail summary { cursor:pointer; font-size:13.5px; font-weight:600; color:var(--navy-700); }
.ver-trail ul { list-style:none; margin:10px 0 0; padding:0; display:flex; flex-direction:column; gap:6px; }
.ver-trail li { font-size:13px; color:var(--text-secondary); padding-left:6px; border-left:2px solid var(--gold-400); }
.ver-trail .vt-no { font-weight:700; color:var(--navy-800); margin-right:6px; }

/* ตรวจผิดปกติ deterministic (safety net) บนหน้างบ */
.det-flags { background:var(--surface-1); border:1px solid var(--border); border-left:4px solid #dc2626; border-radius:var(--radius); padding:12px 16px; margin-bottom:14px; }
.det-flags .df-head { font-weight:600; font-size:13.5px; color:var(--navy-800); display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.df-item { display:flex; align-items:flex-start; gap:9px; font-size:13px; color:var(--text); line-height:1.5; padding:3px 0; }
.df-item .df-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; margin-top:5px; }
.df-red .df-dot { background:#dc2626; } .df-yellow .df-dot { background:#f59e0b; }
.det-flags { animation: fadeInUp 0.4s var(--ease-out); }

/* บันทึกกิจกรรม (audit log) */
.act-filter { display:flex; gap:14px; align-items:flex-end; flex-wrap:wrap; margin-bottom:16px; }
.act-filter label { display:flex; flex-direction:column; gap:5px; font-size:12.5px; color:var(--text-secondary); font-weight:500; }
.act-filter select { min-width:170px; }
.act-tag { display:inline-block; font-size:12px; font-weight:600; color:var(--navy-700); background:var(--surface-2); padding:3px 11px; border-radius:999px; white-space:nowrap; }

/* คีย์ลัด / โฟกัสค้นหา */
.co-kbd { font-family:'IBM Plex Mono',monospace; font-size:12px; color:var(--muted); background:var(--surface-2);
    border:1px solid var(--border); border-radius:5px; padding:1px 7px; line-height:1.4; flex-shrink:0; }
.co-search:focus-within .co-kbd { opacity:0; }

/* Confirm modal ธีมกลาง (แทน native confirm() สำหรับ action ที่ย้อนกลับไม่ได้) */
.app-confirm-overlay {
    position:fixed; inset:0; background:rgba(22,40,77,.45); backdrop-filter:blur(2px);
    display:flex; align-items:center; justify-content:center; z-index:1000;
    opacity:0; transition:opacity .15s var(--ease-out);
}
.app-confirm-overlay.show { opacity:1; }
.app-confirm-box {
    background:#fff; border-radius:var(--radius-xl); box-shadow:var(--shadow-lg);
    max-width:420px; width:calc(100% - 32px); padding:22px 24px;
    transform:translateY(8px) scale(.98); transition:transform .15s var(--ease-out);
}
.app-confirm-overlay.show .app-confirm-box { transform:translateY(0) scale(1); }
.app-confirm-icon { width:38px; height:38px; border-radius:50%; background:rgba(220,38,38,.1); color:#dc2626;
    display:flex; align-items:center; justify-content:center; margin-bottom:12px; }
.app-confirm-msg { font-size:14.5px; color:var(--text); line-height:1.6; white-space:pre-line; margin:0 0 18px; }
.app-confirm-actions { display:flex; justify-content:flex-end; gap:10px; }
