  :root {
    color-scheme: light dark;
    --bg: #FBF4EA;
    --surface: #FFFDF9;
    --surface-alt: #F3E6D6;
    --border: #E4CFB0;
    --border-soft: #ECDCC0;
    --ink: #2B2118;
    --ink-muted: #6B5A48;
    --ink-faint: #9A8672;
    --accent: #FF7A1A;
    --accent-strong: #E85D0A;
    --accent-soft: #F3D9B8;
    --accent-ink: #6B360F;
    --good: #3F7A45;
    --good-bg: #E3EEDD;
    --warn: #9C7A1E;
    --warn-bg: #F6E9C8;
    --info: #3E6E8E;
    --info-bg: #DCEAF2;
    --danger: #B0402C;
    --danger-bg: #F5DAD1;
    --chart-thisyear: #FF7A1A;
    --chart-lastyear: #3987e5;
    --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 8px 24px -12px rgba(60, 40, 20, 0.18);
    --radius: 16px;
    --nav-bg: #271C13;
    --nav-bg-2: #1D140D;
    --nav-border: #3B2A1B;
    --nav-ink: #F3E7D8;
    --nav-ink-muted: rgba(243, 231, 216, 0.6);
    --nav-active-bg: rgba(255, 255, 255, 0.12);
    --nav-active-ink: #FFD9A8;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #1C140D;
      --surface: #241A11;
      --surface-alt: #34271A;
      --border: #4A3A28;
      --border-soft: #3B2E20;
      --ink: #F3E7D8;
      --ink-muted: #C2AC94;
      --ink-faint: #8C7860;
      --accent: #FF9142;
      --accent-strong: #FFB35C;
      --accent-soft: #4A331C;
      --accent-ink: #FBD8AC;
      --good: #7EBB80;
      --good-bg: #2A3B27;
      --warn: #E0BB5E;
      --warn-bg: #443419;
      --info: #8FC2DE;
      --info-bg: #24384A;
      --danger: #E19483;
      --danger-bg: #4A2A22;
      --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
      --nav-bg: #17100A;
      --nav-bg-2: #0E0904;
      --nav-border: #2E2013;
      --nav-ink: #F3E7D8;
      --nav-ink-muted: rgba(243, 231, 216, 0.55);
      --nav-active-bg: rgba(239, 138, 61, 0.18);
      --nav-active-ink: #FFB870;
    }
  }
  :root[data-theme="dark"] {
    --bg: #1C140D;
    --surface: #241A11;
    --surface-alt: #34271A;
    --border: #4A3A28;
    --border-soft: #3B2E20;
    --ink: #F3E7D8;
    --ink-muted: #C2AC94;
    --ink-faint: #8C7860;
    --accent: #FF9142;
    --accent-strong: #FFB35C;
    --accent-soft: #4A331C;
    --accent-ink: #FBD8AC;
    --good: #7EBB80;
    --good-bg: #2A3B27;
    --warn: #E0BB5E;
    --warn-bg: #443419;
    --info: #8FC2DE;
    --info-bg: #24384A;
    --danger: #E19483;
    --danger-bg: #4A2A22;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --nav-bg: #17100A;
    --nav-bg-2: #0E0904;
    --nav-border: #2E2013;
    --nav-ink: #F3E7D8;
    --nav-ink-muted: rgba(243, 231, 216, 0.55);
    --nav-active-bg: rgba(239, 138, 61, 0.18);
    --nav-active-ink: #FFB870;
  }
  :root[data-theme="light"] {
    --bg: #FBF4EA;
    --surface: #FFFDF9;
    --surface-alt: #F3E6D6;
    --border: #E4CFB0;
    --border-soft: #ECDCC0;
    --ink: #2B2118;
    --ink-muted: #6B5A48;
    --ink-faint: #9A8672;
    --accent: #FF7A1A;
    --accent-strong: #E85D0A;
    --accent-soft: #F3D9B8;
    --accent-ink: #6B360F;
    --good: #3F7A45;
    --good-bg: #E3EEDD;
    --warn: #9C7A1E;
    --warn-bg: #F6E9C8;
    --info: #3E6E8E;
    --info-bg: #DCEAF2;
    --danger: #B0402C;
    --danger-bg: #F5DAD1;
    --nav-bg: #271C13;
    --nav-bg-2: #1D140D;
    --nav-border: #3B2A1B;
    --nav-ink: #F3E7D8;
    --nav-ink-muted: rgba(243, 231, 216, 0.6);
    --nav-active-bg: rgba(255, 255, 255, 0.12);
    --nav-active-ink: #FFD9A8;
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Sarabun", "Leelawadee UI", "Noto Sans Thai", "TH Sarabun New", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  body {
    min-height: 100vh;
  }
  a { color: inherit; }
  ::selection { background: var(--accent-soft); color: var(--accent-ink); }

  /* ---------- Login screen ---------- */
  .login-screen[hidden] { display: none !important; }
  .login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
  }
  .login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 26px;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  .login-brand { display: flex; align-items: center; gap: 12px; }
  .login-brand .brand-mark {
    width: 46px; height: 46px; flex: none;
    display: grid; place-items: center;
    background: var(--accent);
    border-radius: 12px;
  }
  .login-brand h1 { margin: 0; font-size: 1.1rem; font-weight: 700; }
  .login-brand p { margin: 2px 0 0; font-size: 0.78rem; color: var(--ink-muted); }

  .loading-overlay[hidden] { display: none !important; }
  .loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--ink-muted);
    font-size: 0.86rem;
  }
  .loading-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--border-soft);
    border-top-color: var(--accent);
    animation: loading-spin 0.8s linear infinite;
  }
  @keyframes loading-spin { to { transform: rotate(360deg); } }

  /* ---------- App shell / sidebar ---------- */
  .app-shell[hidden] { display: none !important; }
  .app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
  }
  .sidebar {
    width: 190px;
    flex: none;
    background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2));
    border-right: 1px solid var(--nav-border);
    color: var(--nav-ink);
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 18px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 20;
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
  .sidebar-brand .brand-mark {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.1);
  }
  .sidebar-brand-text { line-height: 1.2; }
  .sidebar-brand-text strong { display: block; font-size: 0.95rem; font-weight: 700; }
  .sidebar-brand-text span { font-size: 0.72rem; color: var(--nav-ink-muted); }

  .sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 9px;
  }
  .sidebar-user-info { line-height: 1.25; min-width: 0; }
  .sidebar-user-label { display: block; font-size: 0.68rem; color: var(--nav-ink-muted); }
  .sidebar-user-info strong { display: block; font-size: 0.85rem; color: var(--nav-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-user .btn { flex: none; color: var(--nav-ink-muted); border-color: var(--nav-border); }
  .sidebar-user .btn:hover { background: rgba(255,255,255,0.08); color: var(--nav-ink); }

  .nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nav-ink-muted);
    padding: 0 10px;
  }
  .nav-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
  .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: 9px;
    padding: 10px 11px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--nav-ink-muted);
    cursor: pointer;
  }
  .nav-link svg { flex: none; opacity: 0.85; }
  .nav-link:hover { background: rgba(255,255,255,0.06); color: var(--nav-ink); }
  .nav-link.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-ink);
  }
  .nav-link.active svg { opacity: 1; }
  .nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .nav-link:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

  .nav-group { border: none; }
  .nav-group summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border-radius: 9px;
    padding: 10px 11px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--nav-ink-muted);
    cursor: pointer;
  }
  .nav-group summary::-webkit-details-marker { display: none; }
  .nav-group summary::marker { content: ""; }
  .nav-group summary:hover { background: rgba(255,255,255,0.06); color: var(--nav-ink); }
  .nav-group summary svg.chev { margin-left: auto; flex: none; transition: transform 0.15s ease; opacity: 0.7; }
  .nav-group[open] summary svg.chev { transform: rotate(90deg); }
  .nav-group.has-active-child summary { color: var(--nav-active-ink); }
  .nav-group summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .nav-sublist { list-style: none; margin: 2px 0 4px; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 2px; }
  .nav-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-left: 2px solid var(--nav-border);
    border-radius: 0 8px 8px 0;
    padding: 8px 10px;
    font: inherit;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--nav-ink-muted);
    cursor: pointer;
  }
  .nav-sublink:hover { background: rgba(255,255,255,0.06); color: var(--nav-ink); }
  .nav-sublink.active { background: var(--nav-active-bg); color: var(--nav-active-ink); border-left-color: var(--accent); }
  .nav-sublink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .nav-sublink:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

  .page-view[hidden] { display: none !important; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 13, 8, 0.5);
    z-index: 19;
  }
  .menu-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    color: var(--ink);
    border-radius: 9px;
    padding: 9px 13px;
    font: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    margin-bottom: 16px;
  }

  .main-area {
    flex: 1;
    min-width: 0;
    padding: 28px 20px 64px;
  }

  @media (max-width: 880px) {
    .sidebar {
      position: fixed;
      left: 0; top: 0;
      transform: translateX(-100%);
      transition: transform 0.22s ease;
      box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    .app-shell.nav-open .sidebar { transform: translateX(0); box-shadow: 12px 0 30px -10px rgba(0,0,0,0.35); }
    .app-shell.nav-open .sidebar-backdrop { display: block; }
    .menu-toggle { display: inline-flex; }
  }

  .wrap {
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 26px;
  }

  /* ---------- Header ---------- */
  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    border-radius: var(--radius);
    padding: 22px 26px;
    color: #FFF6EC;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
  }
  .brand { display: flex; align-items: center; gap: 14px; }
  .brand-mark {
    width: 46px; height: 46px; flex: none;
    display: grid; place-items: center;
    background: rgba(255,255,255,0.16);
    border-radius: 12px;
  }
  .brand h1 {
    margin: 0;
    font-size: 1.32rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-wrap: balance;
  }
  .brand p {
    margin: 2px 0 0;
    font-size: 0.86rem;
    color: rgba(255, 246, 236, 0.85);
    font-weight: 500;
  }
  .header-date {
    text-align: right;
    font-size: 0.86rem;
    color: rgba(255, 246, 236, 0.92);
    font-weight: 500;
  }
  .header-date strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
  }

  /* ---------- Stats ---------- */
  .stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .stat {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 9px 18px 9px 14px;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  }
  .stat:hover {
    transform: translateY(-1px);
    border-color: var(--stat-color, var(--accent));
    box-shadow: 0 6px 16px -8px rgba(60, 40, 20, 0.3);
  }
  .stat-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--stat-color, var(--accent));
    flex: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--stat-color, var(--accent)) 20%, transparent);
  }
  .stat-n {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--ink);
  }
  .stat-l {
    font-size: 0.8rem;
    color: var(--ink-muted);
    font-weight: 600;
    white-space: nowrap;
  }
  @media (max-width: 480px) {
    .stats { gap: 8px; }
    .stat { flex: 1 1 auto; justify-content: center; }
  }

  /* ---------- Layout ---------- */
  .grid {
    display: grid;
    grid-template-columns: minmax(240px, 270px) 1fr;
    gap: 18px;
    align-items: start;
  }
  @media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
  }
  .card h2 {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .card .sub {
    margin: 0 0 18px;
    font-size: 0.82rem;
    color: var(--ink-muted);
  }

  /* ---------- Form ---------- */
  .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 9px; position: relative; }
  input[readonly] { cursor: pointer; }
  .locked-input {
    cursor: default !important;
    background: var(--surface-alt) !important;
    color: var(--ink-muted);
    font-weight: 600;
  }

  .datepicker-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    width: 264px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
  }

  .job-option-pop[hidden] { display: none !important; }
  .job-option-pop {
    margin-top: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .job-option-pop .field { margin-bottom: 0; }
  .dp-header { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
  .dp-title { flex: 1; text-align: center; font-weight: 700; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
  .dp-nav {
    background: none; border: none; cursor: pointer;
    width: 24px; height: 24px; border-radius: 6px; flex: none;
    color: var(--ink-muted); font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
  }
  .dp-nav:hover { background: var(--surface-alt); color: var(--ink); }
  .dp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.68rem; color: var(--ink-faint); margin-bottom: 4px; }
  .dp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
  .dp-day {
    background: none; border: none; cursor: pointer;
    height: 30px; border-radius: 8px;
    font: inherit; font-size: 0.8rem; color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .dp-day:hover { background: var(--surface-alt); }
  .dp-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
  .dp-day.selected { background: var(--accent); color: #FFF8F0; font-weight: 700; }
  .dp-day.dp-day-disabled { color: var(--ink-faint); opacity: 0.4; cursor: not-allowed; }
  .dp-day.dp-day-disabled:hover { background: none; }
  .dp-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
  .field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
  }
  .field label .req { color: var(--accent-strong); margin-left: 2px; }
  .input-suffix-wrap { position: relative; }
  .input-suffix-wrap input { padding-right: 44px; text-align: right; }
  .input-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-muted);
    pointer-events: none;
  }
  .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

  .password-field-wrap { position: relative; display: flex; align-items: center; }
  .password-field-wrap input { padding-right: 44px; }
  .password-toggle-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 7px;
    color: var(--ink-faint);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
  }
  .password-toggle-btn svg { display: block; width: 21px; height: 21px; }
  .password-toggle-btn:hover { background: var(--surface-alt); color: var(--ink-muted); }
  .password-toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

  .fee-items { display: flex; flex-direction: column; gap: 6px; }
  .fee-item-row { display: grid; grid-template-columns: 1fr 68px auto; gap: 6px; align-items: center; }
  .fee-item-row input { text-align: left; }
  .fee-item-row .fee-item-price { text-align: right; padding-left: 4px; padding-right: 6px; }
  .fee-item-remove {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--danger);
  }
  .fee-total {
    margin-top: 2px;
    font-size: 0.84rem;
    color: var(--ink-muted);
  }
  .fee-total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

  .permission-field { gap: 8px; }
  .permission-toolbar { display: flex; gap: 8px; }
  .permission-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
  }
  .permission-group {
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .permission-group-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-muted);
    margin-bottom: 2px;
  }
  .permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    cursor: pointer;
  }
  .permission-item input[type="checkbox"] { width: auto; flex: none; }
  .permission-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .permission-item-row .permission-item { flex: 1; min-width: 0; }
  .perm-sub-btn { flex: none; white-space: nowrap; display: none !important; }

  .modal-overlay[hidden] { display: none !important; }
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 13, 8, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal-box {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 86vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .modal-title { margin: 0; font-size: 1.02rem; font-weight: 700; }
  .modal-sub { margin: -4px 0 0; font-size: 0.82rem; color: var(--ink-muted); }
  .modal-box-sm { max-width: 360px; }
  .modal-message { margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--ink); }
  .modal-icon {
    width: 44px; height: 44px; flex: none;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--warn-bg);
    color: var(--warn);
    font-size: 1.3rem;
    margin: 0 auto 2px;
  }
  .modal-fields { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); display: grid; gap: 6px; }

  .field-blocks { display: flex; flex-direction: column; }

  input, select, textarea {
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 11px;
    width: 100%;
  }
  textarea { resize: vertical; min-height: 56px; }
  input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
  }
  input.err, select.err { border-color: var(--danger); outline-color: var(--danger); }
  input:disabled, select:disabled, textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface-alt);
  }
  .errmsg { font-size: 0.76rem; color: var(--danger); min-height: 1em; }

  .btn {
    font: inherit;
    font-weight: 700;
    font-size: 0.88rem;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 10px 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.1s ease, filter 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
  .btn-primary {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    color: #FFF8F0;
    width: 100%;
    box-shadow: 0 4px 14px -6px rgba(184, 83, 26, 0.55);
  }
  .btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 6px 18px -6px rgba(184, 83, 26, 0.6); }
  .btn-primary:active { transform: translateY(0); }
  .btn-ghost {
    background: transparent;
    color: var(--ink-muted);
    border-color: var(--border);
  }
  .btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }
  .btn-small { padding: 5px 10px; font-size: 0.76rem; border-radius: 8px; }
  .btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
  .btn-danger-outline:hover { background: var(--danger-bg); }
  .btn-danger { background: var(--danger); color: #fff; }
  .form-actions { display: flex; gap: 8px; margin-top: 4px; }

  .editing-banner[hidden] { display: none !important; }
  .editing-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 14px;
  }
  .editing-banner button {
    background: none; border: none; cursor: pointer;
    color: var(--accent-ink); text-decoration: underline;
    font: inherit; font-weight: 700; padding: 0;
  }

  /* ---------- Table panel ---------- */
  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
  }
  .toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
  }
  .toolbar input[type="text"] { min-width: 200px; flex: 1; }
  .toolbar select { width: auto; min-width: 150px; }
  .toolbar-date-field { margin-bottom: 0; flex: none; }
  .toolbar-date-field input[type="text"] { min-width: 160px; width: 160px; flex: none; }
  .file-actions { display: flex; gap: 8px; }

  .job-option-filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 6px 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
  }

  .table-scroll { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 12px; }
  #bookingTableScroll { overflow-y: auto; }
  table { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 0.85rem; }
  table.booking-table { width: auto; min-width: 1435px; table-layout: fixed; }
  thead th {
    text-align: left;
    background: var(--surface-alt);
    color: var(--ink-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  tbody td {
    padding: 9px 12px;
    vertical-align: middle;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  tbody tr { transition: background-color 0.1s ease; box-shadow: inset 0 -1px 0 var(--border-soft); }
  tbody tr:last-child { box-shadow: none; }
  tbody tr:hover { background: var(--surface-alt); }
  .code { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-strong); white-space: nowrap; }
  .route { display: flex; align-items: center; gap: 6px; overflow: hidden; }
  .route .arrow { color: var(--ink-faint); flex: none; }
  .muted { color: var(--ink-muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cell-driver { max-width: 140px; }
  .cell-actions { display: flex; flex-wrap: wrap; gap: 5px; white-space: nowrap; overflow: visible; max-width: none; }

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
  }
  .chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .chip-pending { background: var(--warn-bg); color: var(--warn); }
  .chip-confirmed { background: var(--info-bg); color: var(--info); }
  .chip-delivered { background: var(--good-bg); color: var(--good); }
  .chip-cancelled { background: var(--danger-bg); color: var(--danger); }

  .table-summary[hidden] { display: none !important; }
  .table-summary {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .table-summary strong { font-size: 0.98rem; font-variant-numeric: tabular-nums; }

  .empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--ink-muted);
  }
  .empty .big { font-size: 2rem; margin-bottom: 6px; }

  .master-group { margin-bottom: 20px; }
  .master-group:last-child { margin-bottom: 0; }
  .master-group-title {
    margin: 0 0 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
  }
  .master-group-count { font-weight: 600; color: var(--ink-muted); font-size: 0.82rem; }
  .master-group-empty {
    margin: 0;
    padding: 16px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--ink-muted);
    background: var(--surface-alt);
    border-radius: 10px;
  }

  .footer-note {
    text-align: center;
    font-size: 0.76rem;
    color: var(--ink-faint);
    margin-top: 4px;
  }

  .master-list-note[hidden], .master-form-note[hidden] { display: none !important; }
  .master-list-note, .master-form-note {
    margin: 14px 0 0;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: var(--warn);
    background: var(--warn-bg);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  /* ---------- Dashboard ---------- */
  .kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
  }
  .kpi-tile {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-top: 3px solid var(--kpi-color, var(--accent));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
  .kpi-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -10px rgba(60, 40, 20, 0.28);
  }
  .kpi-icon {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--kpi-color, var(--accent)) 16%, var(--surface));
    color: var(--kpi-color, var(--accent));
  }
  .kpi-body { min-width: 0; }
  .kpi-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.15;
  }
  .kpi-label {
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--ink-muted);
    font-weight: 600;
  }

  .dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    align-items: start;
  }
  .chart-card-wide { grid-column: 1 / -1; }

  .dash-range-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .dash-range-label { font-size: 0.84rem; font-weight: 600; color: var(--ink-muted); }

  .chart-card {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
  .chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px -12px rgba(60, 40, 20, 0.3);
  }

  .chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
  }
  .chart-legend { display: flex; gap: 10px; flex-wrap: wrap; }
  .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-muted);
    background: var(--surface-alt);
    border-radius: 999px;
    padding: 5px 10px 5px 8px;
  }
  .legend-swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }

  .bar-chart {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 6px;
  }
  .bar-group {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px 0 0;
  }
  .bar-group:hover, .bar-group:focus-within { background: var(--surface-alt); outline: none; }
  .bar-pair {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 200px;
  }
  .bar {
    width: 15px;
    max-width: 24px;
    border-radius: 4px 4px 0 0;
    transition: filter 0.1s ease;
  }
  .bar-group:hover .bar, .bar-group:focus-within .bar { filter: brightness(1.1); }
  .bar-thisyear { background: var(--chart-thisyear); }
  .bar-lastyear { background: var(--chart-lastyear); }
  .bar-axis-label { font-size: 0.74rem; color: var(--ink-muted); font-weight: 600; white-space: nowrap; }

  .chart-tooltip {
    position: absolute;
    z-index: 10;
    background: var(--ink);
    color: var(--bg);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.78rem;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: var(--shadow);
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -100%);
    transition: opacity 0.1s ease;
  }
  .chart-tooltip.visible { opacity: 1; }
  .chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
  .chart-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
  .chart-tooltip .tt-value { font-weight: 700; }

  .status-bars, .ranked-bars { display: flex; flex-direction: column; gap: 14px; }
  .ranked-bars { max-height: 232px; overflow-y: auto; padding-right: 4px; }
  .status-bar-row { display: flex; align-items: center; gap: 10px; }
  .status-bar-label { flex: none; width: 92px; font-size: 0.82rem; color: var(--ink-muted); font-weight: 600; }
  .status-bar-track, .ranked-bar-track {
    flex: 1;
    height: 10px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
  }
  .status-bar-fill, .ranked-bar-fill { height: 100%; border-radius: inherit; transition: width 0.4s ease; }
  .status-bar-value { flex: none; width: 32px; text-align: right; font-size: 0.82rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

  .ranked-bar-row { display: flex; flex-direction: column; gap: 5px; }
  .ranked-bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 0.82rem; }
  .ranked-bar-name { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ranked-bar-count { flex: none; color: var(--ink-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
  .ranked-bar-fee { font-weight: 600; color: var(--ink-faint); font-size: 0.78rem; }
  .ranked-bar-fill { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }
  .ranked-bar-row:hover .ranked-bar-name { color: var(--accent-strong); }

  .dash-empty { color: var(--ink-faint); font-size: 0.85rem; padding: 20px 0; text-align: center; }

  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
  }
