  :root {
    --ink: #1C2622;
    --paper: #F6F4EF;
    --surface: #FFFFFF;
    --surface-2: #EFEDE6;
    --border: #DAD9CE;
    --muted: #6B756E;
    --accent: #2F6F62;
    --accent-ink: #FFFFFF;
    --accent-soft: #E3EEEA;
    --accent-warm: #B5791F;
    --accent-warm-soft: #F5E8D2;
    --good: #2F7D4F;
    --good-soft: #E1F0E5;
    --warn: #B5791F;
    --warn-soft: #F5E8D2;
    --bad: #A63A3A;
    --bad-soft: #F6E3E1;
    --focus: #2F6F62;
    --shadow: 0 8px 30px rgba(28,38,34,0.12);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ink: #E9EDEA;
      --paper: #121B17;
      --surface: #182420;
      --surface-2: #1F2E28;
      --border: #2C3F38;
      --muted: #93A29A;
      --accent: #62BBA4;
      --accent-ink: #0B1F19;
      --accent-soft: #1E3730;
      --accent-warm: #E3A94A;
      --accent-warm-soft: #3A2F1B;
      --good: #57B57F;
      --good-soft: #1D3327;
      --warn: #E3A94A;
      --warn-soft: #3A2F1B;
      --bad: #E37272;
      --bad-soft: #3A2222;
      --focus: #62BBA4;
      --shadow: 0 8px 30px rgba(0,0,0,0.4);
    }
  }
  :root[data-theme="dark"] {
    --ink: #E9EDEA;
    --paper: #121B17;
    --surface: #182420;
    --surface-2: #1F2E28;
    --border: #2C3F38;
    --muted: #93A29A;
    --accent: #62BBA4;
    --accent-ink: #0B1F19;
    --accent-soft: #1E3730;
    --accent-warm: #E3A94A;
    --accent-warm-soft: #3A2F1B;
    --good: #57B57F;
    --good-soft: #1D3327;
    --warn: #E3A94A;
    --warn-soft: #3A2F1B;
    --bad: #E37272;
    --bad-soft: #3A2222;
    --focus: #62BBA4;
    --shadow: 0 8px 30px rgba(0,0,0,0.4);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'Public Sans', 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, .display { font-family: 'Be Vietnam Pro', 'Segoe UI', sans-serif; text-wrap: balance; }
  table { font-variant-numeric: tabular-nums; }
  .num { font-variant-numeric: tabular-nums; }
  a { color: var(--accent); }
  button { font-family: inherit; }
  ::selection { background: var(--accent-soft); }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

  .app-shell { display: flex; flex-direction: column; min-height: 100vh; }

  .topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 14px 24px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
  }
  .brand { display: flex; align-items: baseline; gap: 10px; }
  .brand .mark {
    width: 30px; height: 30px; border-radius: 7px;
    background: linear-gradient(155deg, var(--accent), var(--accent-warm));
    display: inline-block;
  }
  .brand h1 { font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
  .brand .sub { color: var(--muted); font-size: 12px; }
  .statstrip { display: flex; gap: 20px; margin-left: auto; flex-wrap: wrap; }
  .stat { text-align: right; }
  .stat .n { font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 18px; }
  .stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

  .tabbar {
    display: flex; gap: 4px; padding: 0 20px; background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .tabbtn {
    border: none; background: none; padding: 12px 14px; cursor: pointer;
    color: var(--muted); font-weight: 600; font-size: 13.5px;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  .tabbtn.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tabbtn .badge {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
    background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700;
  }

  main { flex: 1; padding: 20px 24px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }
  .view { display: none; }
  .view.active { display: block; }

  .layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
  @media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

  .panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  }
  .filters { padding: 16px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 20px; }
  .field { display: flex; flex-direction: column; gap: 5px; }
  .field label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
  input, select, textarea {
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px;
  }
  input:focus, select:focus, textarea:focus { border-color: var(--accent); }
  .btn {
    border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer;
  }
  .btn:hover { border-color: var(--accent); }
  .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .btn.primary:hover { filter: brightness(1.06); }
  .btn.ghost { border-color: transparent; background: none; }
  .btn.danger { color: var(--bad); }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  .btn.small { padding: 5px 10px; font-size: 12px; }

  .toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .toolbar .count { color: var(--muted); font-size: 13px; }
  .toolbar .search { flex: 1; min-width: 180px; }

  .tablewrap { overflow-x: auto; }
  table.list { width: 100%; border-collapse: collapse; min-width: 760px; }
  table.list th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface);
  }
  table.list td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
  table.list tbody tr { cursor: pointer; }
  table.list tbody tr:hover { background: var(--surface-2); }
  .name-cell .name { font-weight: 600; }
  .name-cell .sub { color: var(--muted); font-size: 12px; }

  .pill {
    display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
  }
  .pill.good { background: var(--good-soft); color: var(--good); }
  .pill.bad { background: var(--bad-soft); color: var(--bad); }
  .pill.warn { background: var(--warn-soft); color: var(--warn); }
  .pill.neutral { background: var(--surface-2); color: var(--muted); }

  .empty { padding: 60px 20px; text-align: center; color: var(--muted); }

  .overlay {
    position: fixed; inset: 0; background: rgba(10,16,14,0.42); z-index: 40;
    display: none; align-items: stretch; justify-content: flex-end;
  }
  .overlay.open { display: flex; }
  .drawer {
    width: min(560px, 100%); background: var(--paper); height: 100%;
    box-shadow: var(--shadow); overflow-y: auto; padding: 22px 24px 100px;
    position: relative;
  }
  .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
  .drawer-head h2 { margin: 0 0 4px; font-size: 20px; }
  .drawer-head .meta { color: var(--muted); font-size: 12.5px; }
  .close-x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 4px; }

  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  @media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

  .section-title {
    font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 14px; margin: 26px 0 10px;
    display: flex; align-items: center; justify-content: space-between;
  }

  table.sem { width: 100%; border-collapse: collapse; }
  table.sem th { text-align: left; font-size: 10.5px; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
  table.sem td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
  table.sem input, table.sem select { width: 100%; padding: 5px 6px; font-size: 12.5px; }
  table.sem tr.review-row { background: var(--warn-soft); }

  .drawer-actions {
    position: sticky; bottom: 0; left: 0; right: 0; background: var(--paper);
    border-top: 1px solid var(--border); padding: 14px 0; margin-top: 22px;
    display: flex; gap: 10px; justify-content: flex-end;
  }

  .statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 22px; }
  .statcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
  .statcard .n { font-family: 'Be Vietnam Pro'; font-size: 26px; font-weight: 800; }
  .statcard .l { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

  .breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
  @media (max-width: 780px) { .breakdown { grid-template-columns: 1fr; } }
  .bd-title { font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 13.5px; margin-bottom: 10px; }
  .barrow { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px; }
  .barrow .bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
  .barrow .bar > span { display: block; height: 100%; background: var(--accent); }
  .barrow.warm .bar > span { background: var(--accent-warm); }

  .subtabs { display: inline-flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
  .subtabbtn { border: none; background: transparent; color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 7px; cursor: pointer; }
  .subtabbtn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

  .dashgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
  @media (max-width: 780px) { .dashgrid { grid-template-columns: 1fr; } }
  .dashpanel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
  .dashpanel .bd-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .dashpanel .bd-title .hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }
  .dashpanel .bd-empty { color: var(--muted); font-size: 12.5px; }

  .donutrow { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
  .donut { width: 128px; height: 128px; border-radius: 50%; flex-shrink: 0; }
  .donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
  .donut-legend .item { display: flex; align-items: center; gap: 8px; }
  .donut-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
  .donut-legend .val { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 4px; }

  .hero {
    position: relative; border-radius: 18px; overflow: hidden; min-height: 300px;
    display: flex; align-items: flex-end; margin-bottom: 28px; isolation: isolate;
  }
  .hero-mosaic {
    position: absolute; inset: 0; display: grid;
    grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; z-index: 0;
  }
  .hero-mosaic .tile { background-size: cover; background-position: center 20%; filter: saturate(.85) blur(.5px); transform: scale(1.04); }
  .hero-overlay {
    position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(180deg, rgba(14,22,18,.32) 0%, rgba(12,19,16,.78) 62%, rgba(10,16,13,.93) 100%);
  }
  .hero-content { position: relative; z-index: 2; padding: 34px 36px 30px; color: #F3F2EC; width: 100%; box-sizing: border-box; }
  .hero-eyebrow { font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 11.5px; letter-spacing: .12em; color: #D9C892; margin-bottom: 10px; text-transform: uppercase; }
  .hero-content h1 { font-family: 'Be Vietnam Pro'; font-weight: 800; font-size: 30px; margin: 0 0 10px; text-wrap: balance; color: #fff; }
  .hero-sub { font-size: 14px; line-height: 1.55; color: rgba(243,242,236,.85); max-width: 640px; margin: 0 0 22px; }
  .hero-stats { display: flex; gap: 14px; flex-wrap: wrap; }
  .hero-stats .statcard {
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.22);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 12px; padding: 13px 18px; min-width: 128px;
  }
  .hero-stats .statcard .n { color: #fff; font-family: 'Be Vietnam Pro'; font-size: 21px; font-weight: 800; }
  .hero-stats .statcard .l { color: rgba(243,242,236,.75); font-size: 11.5px; margin-top: 3px; }

  .home-section-title { font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 14px; margin: 6px 0 12px; }

  .home-quicknav { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 14px; margin-bottom: 32px; }
  .homecard {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
    cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 8px;
    transition: border-color .15s ease, transform .15s ease; font-family: inherit;
  }
  .homecard:hover { border-color: var(--accent); transform: translateY(-2px); }
  .homecard .ic { font-size: 22px; }
  .homecard .t { font-family: 'Be Vietnam Pro'; font-weight: 700; font-size: 14.5px; color: var(--ink); }
  .homecard .d { color: var(--muted); font-size: 12px; line-height: 1.4; }
  .homecard .badge2 { align-self: flex-start; background: var(--bad-soft); color: var(--bad); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }

  .home-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px,1fr)); gap: 14px; margin-bottom: 8px; }
  .facecard { text-align: center; cursor: pointer; background: none; border: none; font-family: inherit; padding: 0; }
  .facecard .ph, .facecard .ph-placeholder {
    width: 100%; aspect-ratio: 1/1; border-radius: 50%; box-shadow: 0 0 0 1px var(--border);
    border: 3px solid var(--surface);
  }
  .facecard .ph { object-fit: cover; background: var(--surface-2); display: block; }
  .facecard .ph-placeholder { background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 20px; font-family: 'Be Vietnam Pro'; font-weight: 700; }
  .facecard .fn { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .facecard .fs { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  @media (max-width: 640px) {
    .hero-content h1 { font-size: 22px; }
    .hero-mosaic { grid-template-columns: repeat(4,1fr); }
  }

  .toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px;
    font-size: 13px; z-index: 80; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .toast.show { opacity: 1; }

  .flagline { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .flagline:last-child { border-bottom: none; }
  .flagline .who { font-weight: 600; }
  .flagline .what { color: var(--muted); font-size: 12.5px; }

  .readonly-banner {
    background: var(--warn-soft); color: var(--warn); padding: 8px 24px; font-size: 12.5px; font-weight: 600;
    display: none;
  }
  .readonly-banner.show { display: block; }

  .photo-box { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
  .photo-preview {
    width: 84px; height: 108px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
  }
  .photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .photo-placeholder { color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }
  .photo-actions { display: flex; flex-direction: column; gap: 8px; }

  .exportbar { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
  .reportgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 18px; }
  .reportcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
  .reportcard .n { font-family: 'Be Vietnam Pro'; font-size: 21px; font-weight: 800; }
  .reportcard .l { color: var(--muted); font-size: 12px; margin-top: 3px; }
  .reportnote { color: var(--muted); font-size: 12px; padding: 10px 16px; }

  /* ---------- login screen ---------- */
  .login-screen {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 30% 20%, var(--accent-soft), var(--paper) 60%);
    padding: 24px;
  }
  .login-card {
    width: 100%; max-width: 360px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
    padding: 32px 28px; display: flex; flex-direction: column; gap: 16px;
  }
  .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
  .login-brand .mark {
    width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(155deg, var(--accent), var(--accent-warm));
  }
  .login-brand h1 { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
  .login-brand .sub { color: var(--muted); font-size: 12px; }
  .login-card .field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
  .login-card .field input {
    width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--paper); color: var(--ink); font-size: 14px; font-family: inherit;
  }
  .login-card .field input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
  .login-card .field { margin-bottom: 2px; }
  .login-error { background: var(--bad-soft); color: var(--bad); font-size: 12.5px; font-weight: 600; padding: 9px 12px; border-radius: 8px; }
  .login-note { color: var(--muted); font-size: 11.5px; text-align: center; line-height: 1.5; }
  .login-card .btn.primary { width: 100%; padding: 11px; font-size: 14px; }

  /* ---------- header user badge ---------- */
  .userbar { display: flex; align-items: center; gap: 10px; }
  .user-badge { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; margin-right: 4px; }
  .user-badge .ub-name { font-weight: 700; font-size: 13px; }
  .user-badge .ub-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

  /* ---------- users admin table ---------- */
  table.datatable { width: 100%; border-collapse: collapse; min-width: 720px; }
  table.datatable th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
  }
  table.datatable td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13.5px; }
  .btn.danger { background: var(--bad-soft); color: var(--bad); border: 1px solid transparent; }
  .btn.danger:hover { background: var(--bad); color: #fff; }
