  :root {
    --paper: #F6FAF7;
    --record: #FFFFFF;
    --line: #DCE6DF;
    --ink: #12181F;
    --ink-64: #12181FA3;
    --ink-40: #12181F66;
    --carimbo: #15803D;
    --indicacao: #15803D;
    --conforme: #1E7B45;
    --conforme-text: #15683A;
    --nao-conforme: #B3261E;
    --observacao: #B7791F;
    --observacao-tint: #B7791F26;

    --r: 9px;
    --r-sm: 6px;
    --sp: 8px;
    --shadow-sheet: 0 1px 2px rgba(18,24,31,.06), 0 4px 14px rgba(18,24,31,.05);
    --shadow-pop: 0 8px 28px rgba(18,24,31,.16);

    --cabinet-line: #DCE6DF;
    --chip: #E4EFE7;

    /* persistent dark-green navigation rail — identical in both themes */
    --rail-bg: #0C271A;
    --rail-line: rgba(255,255,255,.09);
    --rail-ink: #DCEAE0;
    --rail-ink-64: #9FC4AE;
    --rail-active-bg: #17A357;
    --rail-active-ink: #FFFFFF;
  }

  html[data-theme="dark"] {
    --paper: #0B1E14;
    --record: #11291B;
    --line: #1E3B29;
    --ink: #E8F1EA;
    --ink-64: #E8F1EAA3;
    --ink-40: #E8F1EA66;
    --carimbo: #34C76A;
    --indicacao: #5CD08A;
    --conforme: #3DBE6E;
    --conforme-text: #7FE0A4;
    --nao-conforme: #EB6F66;
    --observacao: #E0A23A;
    --observacao-tint: #E0A23A33;

    --shadow-sheet: 0 1px 2px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.4);
    --shadow-pop: 0 10px 30px rgba(0,0,0,.55);

    --cabinet-line: #1E3B29;
    --chip: #1A3826;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: "Poppins", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
  }
  .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums slashed-zero; }

  a { color: var(--indicacao); }
  button { font-family: inherit; cursor: pointer; }
  h1, h2, h3, h4 { margin: 0; }

  :focus-visible {
    outline: 3px solid rgba(21,128,61,.55);
    outline-offset: 2px;
    border-radius: var(--r-sm);
  }

  /* ---------- LAYOUT ---------- */
  .app {
    display: grid;
    grid-template-columns: 256px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "side head" "side main";
    min-height: 100vh;
  }
  .app.collapsed { grid-template-columns: 60px 1fr; }

  /* ---------- SIDEBAR ---------- */
  .side {
    grid-area: side;
    background: var(--rail-bg);
    color: var(--rail-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
    border-right: 1px solid var(--rail-line);
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--rail-line);
  }
  .brand-seal {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 7px;
    background: var(--rail-active-bg);
    display: grid; place-items: center;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25);
  }
  .brand-seal svg { width: 22px; height: 22px; }
  .brand-txt { line-height: 1.05; }
  .brand-txt strong {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: .01em;
    color: var(--rail-ink);
  }
  .brand-txt span { font-size: .68rem; color: var(--rail-ink-64); letter-spacing: .04em; }
  .app.collapsed .brand-txt { display: none; }
  .app.collapsed .brand { justify-content: center; padding: 16px 0; }

  .side-scroll { flex: 1; padding: 8px 8px 16px; }

  .nav-pinned { margin-bottom: 6px; }
  .drawer { margin-bottom: 2px; }
  .drawer-head {
    width: 100%;
    background: none; border: 0;
    color: var(--rail-ink-64);
    font-weight: 600;
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
    padding: 11px 10px 7px;
    text-align: left;
  }
  .drawer-head .chev {
    margin-left: auto;
    transition: transform .18s ease;
    opacity: .55;
    font-size: .7rem;
  }
  .drawer.open .drawer-head .chev { transform: rotate(90deg); }
  .drawer-tab { display: none; }
  .drawer-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height .2s ease-out;
  }

  .nav-item {
    width: 100%;
    background: none; border: 0;
    color: var(--rail-ink);
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: .92rem;
    text-align: left;
    position: relative;
    line-height: 1.2;
  }
  .nav-item:hover { background: rgba(255,255,255,.06); color: var(--rail-ink); }
  .nav-item.active {
    background: var(--rail-active-bg);
    color: var(--rail-active-ink);
    font-weight: 600;
  }
  .nav-item.active:hover { background: var(--rail-active-bg); color: var(--rail-active-ink); }
  /* code-chip + pin-dot are the collapsed-rail glyphs — hidden when expanded */
  .code-chip {
    display: none;
    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(255,255,255,.06);
    color: var(--rail-ink-64);
    border: 1px solid var(--rail-line);
    flex: 0 0 auto;
    min-width: 30px;
    text-align: center;
  }
  .nav-item.active .code-chip {
    background: rgba(255,255,255,.2);
    color: #fff;
    border-color: rgba(255,255,255,.28);
  }
  .nav-item .lbl { flex: 1; }
  .pin-dot { display: none; width: 30px; text-align: center; font-size: .9rem; flex: 0 0 30px; }

  .side-foot-wrap { position: relative; }
  .side-foot {
    width: 100%;
    border: 0; border-top: 1px solid var(--rail-line);
    background: none;
    color: var(--rail-ink);
    padding: 10px 12px;
    display: flex; align-items: center; gap: 10px;
    font-size: .8rem;
    text-align: left;
    cursor: pointer;
  }
  .side-foot:hover { background: rgba(255,255,255,.06); }
  .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--rail-active-bg); color: var(--rail-active-ink);
    display: grid; place-items: center;
    font-weight: 700; font-size: .8rem; flex: 0 0 30px;
  }
  .side-foot .who { display: flex; flex-direction: column; line-height: 1.15; }
  .side-foot .who strong { color: var(--rail-ink); font-weight: 600; font-size: .82rem; }
  .side-foot .who span { color: var(--rail-ink-64); font-size: .7rem; }
  .acct-caret { margin-left: auto; color: var(--rail-ink-64); display: inline-flex; transition: transform .15s ease; }
  .acct-caret svg { width: 16px; height: 16px; }
  .side-foot[aria-expanded="true"] .acct-caret { transform: rotate(180deg); }

  /* account / config popover — opens upward from the sidebar foot */
  .acct-menu {
    position: absolute;
    left: 8px; right: 8px;
    bottom: calc(100% + 8px);
    background: var(--record);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    z-index: 60;
    padding: 6px;
    color: var(--ink);
  }
  .acct-menu[hidden] { display: none; }
  .acct-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
  .acct-head .avatar { background: var(--carimbo); }
  .acct-who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
  .acct-who strong { font-size: .9rem; font-weight: 600; color: var(--ink); }
  .acct-who span { font-size: .76rem; color: var(--ink-64); }
  .acct-divider { height: 1px; background: var(--line); margin: 4px 2px; }
  .acct-row {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--r-sm);
    background: none; border: 0; text-align: left;
    font-size: .88rem; color: var(--ink); cursor: pointer;
    line-height: 1.2;
  }
  .acct-row:hover { background: var(--paper); }
  .acct-ic { display: inline-flex; flex: 0 0 18px; width: 18px; height: 18px; color: var(--ink-64); }
  .acct-ic svg { width: 18px; height: 18px; }
  .acct-label { flex: 1; }
  .acct-row-danger { color: var(--nao-conforme); }
  .acct-row-danger .acct-ic { color: var(--nao-conforme); }
  .acct-row-danger:hover { background: rgba(179,38,30,.08); }

  /* toggle switch inside the Modo noturno row */
  .switch {
    margin-left: auto; flex: 0 0 auto;
    width: 38px; height: 22px; border-radius: 999px;
    background: var(--line); border: 1px solid var(--line);
    position: relative; transition: background .15s ease, border-color .15s ease;
  }
  .switch-knob {
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: transform .15s ease;
  }
  .acct-switch-row[aria-checked="true"] .switch { background: var(--carimbo); border-color: var(--carimbo); }
  .acct-switch-row[aria-checked="true"] .switch-knob { transform: translateX(16px); }

  /* collapsed rail: popover anchors to the right of the icon-rail */
  .app.collapsed .acct-menu {
    position: fixed;
    left: 68px; right: auto;
    bottom: 14px; top: auto;
    width: 248px;
  }

  .app.collapsed .lbl,
  .app.collapsed .drawer-head span,
  .app.collapsed .chev,
  .app.collapsed .side-foot .who,
  .app.collapsed .drawer-tab { display: none; }
  .app.collapsed .drawer-head {
    height: 1px; padding: 0; margin: 10px 12px;
    background: var(--rail-line); overflow: hidden;
  }
  .app.collapsed .nav-item { justify-content: center; padding: 8px 0; }
  .app.collapsed .nav-item .code-chip,
  .app.collapsed .nav-item .pin-dot { display: inline-flex; align-items: center; justify-content: center; }
  .app.collapsed .pin-dot { flex: none; }
  .app.collapsed .side-foot { justify-content: center; }
  .app.collapsed .acct-caret { display: none; }

  /* ---------- HEADER ---------- */
  .head {
    grid-area: head;
    background: var(--record);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px;
    height: 60px;
    position: sticky; top: 0;
    z-index: 30;
  }
  .icon-btn {
    background: none; border: 1px solid transparent;
    color: var(--ink-64);
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    display: grid; place-items: center;
    font-size: 1.1rem;
  }
  .icon-btn:hover { background: var(--paper); color: var(--ink); }
  .crumb { font-size: .9rem; color: var(--ink-64); display: flex; align-items: center; gap: 8px; }
  .crumb strong { color: var(--ink); font-weight: 600; }
  .crumb .sep { color: var(--ink-40); }


  /* ---------- MAIN ---------- */
  .main { grid-area: main; padding: 24px 28px 64px; max-width: 1320px; }
  .view { display: none; animation: fade .12s ease-out; }
  .view.active { display: block; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }

  .page-title {
    font-weight: 700;
    font-size: 1.95rem;
    line-height: 1.15;
    letter-spacing: -.01em;
    margin-bottom: 2px;
  }
  .page-sub { color: var(--ink-64); font-size: .95rem; margin-bottom: 18px; }

  /* gantry sub-tabs */
  .gantry {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--line);
    margin: 14px 0 22px;
    overflow-x: auto;
  }
  .gantry button {
    background: none; border: 0;
    padding: 9px 14px;
    color: var(--ink-64);
    font-weight: 600; font-size: .9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
  }
  .gantry button:hover { color: var(--ink); }
  .gantry button.active { color: var(--indicacao); border-bottom-color: var(--indicacao); }

  /* ---------- CARDS / GRID ---------- */
  .grid { display: grid; gap: 16px; }
  .cards-4 { grid-template-columns: repeat(4, 1fr); }
  .cards-3 { grid-template-columns: repeat(3, 1fr); }
  .cards-2 { grid-template-columns: repeat(2, 1fr); }

  .sheet {
    background: var(--record);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-sheet);
  }
  .pad { padding: 18px; }
  .sheet-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
  }
  .sheet-head h2 { font-size: 1.05rem; font-weight: 600; }
  .sheet-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

  /* readout tile */
  .tile {
    background: var(--record);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-sheet);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
  }
  .tile .cap {
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .1em; color: var(--ink-64);
    display: flex; align-items: center; gap: 6px;
  }
  .readout { display: flex; align-items: baseline; gap: 7px; margin-top: 10px; }
  .readout .val {
    font-family: "IBM Plex Mono", monospace;
    font-variant-numeric: tabular-nums slashed-zero;
    font-size: 1.7rem; font-weight: 500; line-height: 1;
    letter-spacing: -.01em;
  }
  .readout .unit { font-size: .85rem; color: var(--ink-64); font-weight: 500; }
  .tile .foot { margin-top: 10px; font-size: .8rem; color: var(--ink-64); display: flex; align-items: center; gap: 6px; }
  .tile.alert .readout .val { color: var(--nao-conforme); }
  /* trend deltas — color encodes good/bad, never the arrow direction */
  .trend-good { color: var(--conforme-text); font-weight: 600; }
  .trend-bad { color: var(--nao-conforme); font-weight: 600; }
  .txt-bad { color: var(--nao-conforme); font-weight: 600; }


  .lgpd-note {
    display: flex; align-items: center; gap: 7px;
    font-size: .76rem; color: var(--ink-64);
    padding: 11px 18px; border-top: 1px solid var(--line);
  }
  .lgpd-note svg { width: 14px; height: 14px; flex: 0 0 14px; opacity: .7; }

  .module-links {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: .82rem; color: var(--ink-64);
    margin-top: 24px;
  }
  .module-links .ml-sep { color: var(--ink-40); }

  /* badges */
  .badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; line-height: 1.3;
    white-space: nowrap;
  }
  .badge .g { font-size: .82em; }
  .b-conforme { background: #EBF3EE; color: var(--conforme-text); border: 1px solid #BCD3C4; }
  .b-nc { background: #FAEEED; color: var(--nao-conforme); border: 1px solid #E2BEBA; }
  .b-obs { background: var(--observacao-tint); color: #7A5512; border: 1px solid #E6D4AC; }
  .b-info { background: #EEF4F9; color: var(--indicacao); border: 1px solid #BBD0E2; }
  .b-neutral { background: var(--paper); color: var(--ink-64); border: 1px solid var(--line); }
  .b-crit { background: #FBF1F0; color: var(--nao-conforme); border: 1px solid #E2BEBA; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }

  .plate {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 600; font-size: .82rem;
    letter-spacing: .03em;
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 2px 7px; border-radius: var(--r-sm);
    color: var(--ink);
    display: inline-block;
  }

  /* division classifier (Divisão) — quiet greige chip, NOT a status color */
  .div-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px; border-radius: 999px;
    font-size: .72rem; font-weight: 600; line-height: 1.3;
    white-space: nowrap;
    background: var(--chip);
    color: var(--ink-64);
    border: 1px solid var(--cabinet-line);
  }
  .div-tag .dt-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
  .div-florestal .dt-dot { background: #5E8E63; }
  .div-rodoviario .dt-dot { background: #5E7FA8; }

  .divisao-split {
    display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin: 8px 0 0; font-size: .82rem; color: var(--ink-64);
  }
  .divisao-split .ds-item { display: inline-flex; align-items: center; gap: 6px; }
  .divisao-split .ds-item .dt-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
  .divisao-split .ds-item strong { color: var(--ink); font-weight: 600; }
  .divisao-split .ds-bar {
    display: flex; width: 150px; height: 8px; border-radius: 999px;
    overflow: hidden; border: 1px solid var(--line);
  }
  .divisao-split .ds-bar i { display: block; height: 100%; }
  .divisao-split .ds-bar .seg-flor { background: #5E8E63; }
  .divisao-split .ds-bar .seg-rodo { background: #5E7FA8; }

  /* buttons */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 16px;
    border-radius: var(--r);
    font-weight: 600; font-size: .9rem;
    border: 1px solid transparent;
    background: var(--record); color: var(--ink);
    line-height: 1;
  }
  .btn-primary { background: var(--carimbo); color: #fff; border-color: var(--carimbo); }
  .btn-primary:hover { background: #115C30; border-color: #115C30; }
  .btn-secondary { background: var(--record); border-color: var(--line); color: var(--ink); }
  .btn-secondary:hover { background: var(--paper); }
  .btn-danger { background: transparent; border-color: var(--nao-conforme); color: var(--nao-conforme); }
  .btn-danger:hover { background: #FAEEED; }
  .btn-sm { padding: 7px 11px; font-size: .82rem; }

  /* tables */
  .tbl-wrap { overflow-x: auto; }

  /* Charts scale uniformly with the sheet; below the min-width they scroll like a
     wide table instead of shrinking the labels into unreadable specks. */
  .chart-wrap { overflow-x: auto; }
  .atua-chart { display: block; width: 100%; min-width: 620px; height: auto; }
  .atua-col .atua-bar { transition: opacity .12s ease; }
  .atua-col:hover .atua-bar { opacity: .82; }
  table.ledger { width: 100%; border-collapse: collapse; font-size: .88rem; }
  table.ledger thead th {
    text-align: left;
    font-size: .68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; color: var(--ink-64);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: #FAFAF8;
    white-space: nowrap;
  }
  table.ledger tbody td { padding: 11px 14px; border-bottom: 1px solid #EDEFE9; vertical-align: middle; }
  table.ledger tbody tr:last-child td { border-bottom: 0; }
  table.ledger tbody tr:hover { background: #FAFAF7; }
  table.ledger .num { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums slashed-zero; text-align: right; }
  th.num { text-align: right !important; }
  tr.nc-row td { background: #FCF4F3; }
  tr.nc-row td:first-child { box-shadow: inset 3px 0 0 var(--nao-conforme); }
  tr.low-row td { background: #FAF4E6; }
  tr.low-row td:first-child { box-shadow: inset 3px 0 0 var(--observacao); }

  .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
  .field {
    display: flex; flex-direction: column; gap: 4px;
  }
  .field label { font-size: .72rem; font-weight: 600; color: var(--ink-64); text-transform: uppercase; letter-spacing: .06em; }
  input, select {
    font-family: inherit; font-size: .9rem;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--record);
    color: var(--ink);
  }
  input:focus, select:focus {
    outline: none;
    border-color: var(--carimbo);
    box-shadow: 0 0 0 3px rgba(21,128,61,.18);
  }
  input.mono { font-family: "IBM Plex Mono", monospace; }

  /* reading input pair */
  .reading-pair { display: flex; }
  .reading-pair input { border-radius: var(--r) 0 0 var(--r); border-right: 0; width: 130px; }
  .unit-chip {
    display: inline-flex; align-items: center; padding: 0 12px;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: 0 var(--r) var(--r) 0;
    font-family: "IBM Plex Mono", monospace; font-size: .82rem;
    color: var(--ink-64); font-weight: 500;
  }


  /* ---------- TRI-STATE CONTROL ---------- */
  .checklist-item {
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--record);
    position: relative;
  }
  .ci-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
  .ci-label { font-weight: 600; font-size: .95rem; line-height: 1.3; }
  .tristate { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
  .seg {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--record);
    color: var(--ink-64);
    font-weight: 600; font-size: .86rem;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    transition: transform .08s ease;
  }
  .seg .g { font-size: 1rem; }
  .seg[aria-pressed="true"].s-conforme { background: var(--conforme); border-color: var(--conforme); color: #fff; }
  .seg[aria-pressed="true"].s-nc { background: var(--nao-conforme); border-color: var(--nao-conforme); color: #fff; }
  .seg[aria-pressed="true"].s-obs { background: var(--observacao-tint); border-color: #E6D4AC; color: #7A5512; }
  .seg.pressed { transform: scale(.96); }
  .ci-reveal {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px dashed var(--line);
    display: none;
  }
  .ci-reveal.show { display: block; }
  .photo-slot {
    border: 1.5px dashed var(--nao-conforme);
    border-radius: var(--r);
    padding: 14px; text-align: center;
    color: var(--nao-conforme); font-size: .84rem; font-weight: 600;
    background: #FCF4F3;
  }
  .obs-note { font-size: .8rem; color: #7A5512; margin-top: 8px; display: flex; align-items: center; gap: 6px; }


  /* mini trend bars */
  .spark { display: flex; align-items: flex-end; gap: 4px; height: 48px; }
  .spark .bar { flex: 1; background: var(--indicacao); border-radius: 2px 2px 0 0; min-height: 4px; opacity: .85; }
  .spark .bar.lo { background: var(--observacao); }

  .progress { height: 7px; border-radius: 4px; background: var(--paper); overflow: hidden; border: 1px solid var(--line); }
  .progress > i { display: block; height: 100%; background: var(--conforme); }
  .progress.warn > i { background: var(--observacao); }
  .progress.bad > i { background: var(--nao-conforme); }

  .empty {
    text-align: center; padding: 40px 20px; color: var(--ink-64);
  }
  .empty .stamp-ill {
    width: 60px; height: 60px; margin: 0 auto 14px;
    border: 2px solid var(--carimbo); border-radius: 10px;
    transform: rotate(-3deg); display: grid; place-items: center;
    color: var(--carimbo); opacity: .55;
  }
  .empty h3 { font-weight: 700; margin-bottom: 4px; color: var(--ink); }

  .meta-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px 24px; }
  .meta-grid .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-64); font-weight: 600; margin-bottom: 2px; }
  .meta-grid .v { font-size: .95rem; font-weight: 500; }

  .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-64); }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

  .section-gap { margin-top: 22px; }
  .row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

  /* ---------- AUTH (logged-out, full-screen) ---------- */
  .auth-stage { display: none; }
  body.auth-mode .app, body.auth-mode .scrim, body.auth-mode .bottom-nav { display: none !important; }
  body.auth-mode .auth-stage {
    display: grid; place-items: center;
    min-height: 100vh; padding: 24px;
    background: var(--paper);
  }
  .auth-view { width: 100%; max-width: 400px; }
  .auth-card {
    background: var(--record);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    padding: 28px 26px;
  }
  .auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
  .auth-seal {
    width: 42px; height: 42px; border-radius: 9px; flex: 0 0 42px;
    background: var(--carimbo); display: grid; place-items: center;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25);
  }
  .auth-seal svg { width: 26px; height: 26px; }
  .auth-brand-txt { line-height: 1.12; }
  .auth-brand-txt strong { display: block; font-size: 1.15rem; font-weight: 700; color: var(--ink); }
  .auth-brand-txt span { font-size: .78rem; color: var(--ink-64); }
  .auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; color: var(--ink); }
  .auth-sub { font-size: .9rem; color: var(--ink-64); margin: 0 0 20px; }
  .auth-form { display: grid; gap: 14px; }
  .auth-form .btn-primary { width: 100%; min-height: 46px; margin-top: 4px; }
  input[readonly] { background: var(--paper); color: var(--ink-64); cursor: default; }
  .auth-foot-demo { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--ink-40); text-align: center; }
  .linklike { background: none; border: 0; padding: 0; color: var(--indicacao); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
  .linklike:hover { color: var(--carimbo); }

  .auth-alert {
    display: flex; align-items: center; gap: 10px;
    background: #FAEEED; border: 1px solid #E2BEBA; color: var(--nao-conforme);
    border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 16px;
    font-size: .86rem; font-weight: 500;
  }
  .auth-alert[hidden] { display: none; }
  .auth-alert span { flex: 1; }
  .auth-alert-x { background: none; border: 0; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 2px; }

  .auth-note {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--paper); border: 1px solid var(--line);
    border-left: 3px solid var(--indicacao);
    border-radius: var(--r-sm); padding: 11px 13px; margin: 0 0 18px;
    font-size: .86rem; color: var(--ink); line-height: 1.4;
  }
  .auth-note .auth-note-ic { color: var(--indicacao); flex: 0 0 18px; display: inline-flex; margin-top: 1px; }
  .auth-note strong { font-weight: 600; }

  /* "Não sou um robô" verification (visual only) */
  .robot-check {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--line); border-radius: var(--r);
    padding: 12px 14px; background: var(--record); cursor: pointer;
    user-select: none; min-height: 52px;
  }
  .robot-check input { position: absolute; opacity: 0; width: 0; height: 0; }
  .robot-box {
    width: 24px; height: 24px; border: 2px solid var(--ink-40);
    border-radius: 4px; flex: 0 0 24px; display: grid; place-items: center;
    background: var(--record); transition: background .12s ease, border-color .12s ease;
  }
  .robot-check input:checked + .robot-box { background: var(--carimbo); border-color: var(--carimbo); }
  .robot-check input:checked + .robot-box::after {
    content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
  }
  .robot-check input:focus-visible + .robot-box { outline: 3px solid rgba(21,128,61,.55); outline-offset: 2px; }
  .robot-label { flex: 1; font-weight: 500; font-size: .9rem; color: var(--ink); }
  .robot-badge { display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--ink-40); font-size: .56rem; text-align: center; }
  .robot-badge svg { width: 18px; height: 18px; }

  /* password rule hints */
  .pw-rules { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 5px; }
  .pw-rules li { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--ink-64); }
  .pw-rules li .rule-dot { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--ink-40); flex: 0 0 15px; display: grid; place-items: center; }
  .pw-rules li.ok { color: var(--conforme-text); }
  .pw-rules li.ok .rule-dot { background: var(--conforme); border-color: var(--conforme); }
  .pw-rules li.ok .rule-dot::after { content: ""; width: 4px; height: 7px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }

  /* in-shell account forms */
  .form-col { display: grid; gap: 14px; }
  .form-note { display: flex; align-items: flex-start; gap: 8px; font-size: .82rem; color: var(--ink-64); margin: 16px 0 0; line-height: 1.4; }
  .form-note .form-note-ic { flex: 0 0 16px; color: var(--ink-64); display: inline-flex; margin-top: 1px; }
  .form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

  /* 403 acesso negado */
  .denied { text-align: center; max-width: 460px; margin: 48px auto; }
  .denied-icon {
    width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%;
    background: var(--chip); color: var(--ink-64);
    display: grid; place-items: center;
  }
  .denied-icon svg { width: 30px; height: 30px; }
  .denied .page-title { margin-bottom: 8px; }
  .denied .page-sub { margin-bottom: 22px; }

  /* ---------- CRUD helpers (users / assets / inspections) ---------- */
  .cards-top { align-items: start; }
  .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

  .copy-row { display: flex; gap: 8px; align-items: stretch; }
  .copy-row input { flex: 1; min-width: 0; }
  .copy-row .btn { flex: 0 0 auto; white-space: nowrap; }

  .seg-pick { display: inline-flex; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 4px; flex-wrap: wrap; }
  .seg-pick button { border: 0; background: none; padding: 9px 18px; border-radius: var(--r-sm); font-weight: 600; font-size: .88rem; color: var(--ink-64); cursor: pointer; }
  .seg-pick button[aria-pressed="true"] { background: var(--record); color: var(--ink); box-shadow: var(--shadow-sheet); }

  .asset-checklist { display: grid; gap: 4px; max-height: 300px; overflow-y: auto; margin-top: 8px; }
  .asset-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
  .asset-row:hover { background: var(--paper); }
  .asset-row input { position: absolute; opacity: 0; width: 0; height: 0; }
  .asset-cb { width: 19px; height: 19px; border: 2px solid var(--ink-40); border-radius: 4px; flex: 0 0 19px; display: grid; place-items: center; transition: background .12s ease, border-color .12s ease; }
  .asset-row input:checked + .asset-cb { background: var(--carimbo); border-color: var(--carimbo); }
  .asset-row input:checked + .asset-cb::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }
  .asset-row input:focus-visible + .asset-cb { outline: 3px solid rgba(21,128,61,.55); outline-offset: 2px; }

  .warn-box {
    display: flex; align-items: flex-start; gap: 8px;
    background: var(--observacao-tint); border: 1px solid #E6D4AC; border-left: 3px solid var(--observacao);
    color: #7A5512; border-radius: var(--r-sm); padding: 10px 12px; margin: 10px 0;
    font-size: .84rem; font-weight: 500; line-height: 1.4;
  }
  .warn-box[hidden] { display: none; }
  .warn-box .warn-ic { flex: 0 0 16px; display: inline-flex; margin-top: 1px; }

  .correction-banner {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--chip); border: 1px solid var(--cabinet-line); border-left: 4px solid var(--indicacao);
    border-radius: var(--r); padding: 14px 16px; font-size: .9rem; line-height: 1.45; color: var(--ink);
  }
  .correction-banner .cb-ic { color: var(--indicacao); flex: 0 0 22px; display: inline-flex; margin-top: 1px; }
  .correction-banner .cb-ic svg { width: 22px; height: 22px; }

  .reviewed-tag { color: var(--conforme-text); font-size: .8rem; font-weight: 600; white-space: nowrap; }
  tr.inativo { opacity: .5; }

  .toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
    background: var(--ink); color: var(--paper);
    padding: 11px 18px; border-radius: var(--r); box-shadow: var(--shadow-pop);
    font-size: .88rem; font-weight: 500; z-index: 80;
    opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
    max-width: calc(100vw - 32px);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


  /* ---------- DRIVER / OPERADOR MOBILE APP (full-screen phone) ---------- */
  #driverStage { display: none; }
  body.driver-mode .app,
  body.driver-mode .scrim,
  body.driver-mode .bottom-nav,
  body.driver-mode .auth-stage { display: none !important; }
  body.driver-mode #driverStage { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: #0C271A; }

  .phone {
    width: 390px; max-width: 100%; height: min(844px, 94vh);
    background: var(--paper); color: var(--ink);
    border: 11px solid #060a08; border-radius: 44px;
    box-shadow: 0 24px 60px rgba(0,0,0,.45);
    overflow: hidden; display: flex; flex-direction: column;
  }

  /* persistent sync status bar */
  .phone-status { flex: 0 0 auto; padding: 12px 16px; font-size: .82rem; font-weight: 600; border-bottom: 1px solid var(--line); }
  .phone-status .ps-line { display: none; align-items: center; gap: 8px; width: 100%; background: none; border: 0; text-align: left; font: inherit; color: inherit; padding: 0; }
  .phone-status .ps-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
  .phone-status[data-state="online"] { background: rgba(30,123,69,.10); color: var(--conforme-text); }
  .phone-status[data-state="online"] .ps-online { display: flex; }
  .phone-status[data-state="online"] .ps-dot { background: var(--conforme); }
  .phone-status[data-state="offline"] { background: var(--observacao-tint); color: #7A5512; }
  .phone-status[data-state="offline"] .ps-offline { display: flex; }
  .phone-status[data-state="offline"] .ps-dot { background: var(--observacao); }
  .phone-status[data-state="expired"] { background: #FAEEED; color: var(--nao-conforme); }
  .phone-status[data-state="expired"] .ps-expired { display: flex; cursor: pointer; }
  .phone-status[data-state="expired"] .ps-dot { background: var(--nao-conforme); }
  .phone-status[data-state="photos"] { background: rgba(21,128,61,.10); color: var(--indicacao); }
  .phone-status[data-state="photos"] .ps-photos { display: flex; }
  .phone-status[data-state="photos"] .ps-dot { background: var(--indicacao); animation: pulse 1.2s infinite; }
  @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

  .phone-body { flex: 1; overflow-y: auto; }
  .dscreen { display: none; }
  .dscreen.active { display: block; }
  .dscreen-body { padding: 16px; }
  .dscreen-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 2; }
  .dscreen-head strong { font-size: .95rem; }
  .phone-back { background: none; border: 0; color: var(--indicacao); font: inherit; font-weight: 600; cursor: pointer; padding: 8px 2px; min-height: 44px; }

  .phone-greet { padding: 16px 16px 4px; }
  .phone-greet h2 { font-size: 1.3rem; font-weight: 700; }
  .phone-greet p { font-size: .85rem; color: var(--ink-64); margin: 2px 0 0; }

  .veh-card { display: block; width: 100%; text-align: left; background: var(--record); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sheet); padding: 14px; margin-bottom: 12px; }
  .veh-card.pending { border-left: 4px solid var(--carimbo); }
  .veh-card.done { opacity: .58; }
  .veh-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .veh-status { font-size: .85rem; color: var(--ink-64); margin-bottom: 12px; }
  .veh-card .btn { width: 100%; min-height: 52px; }
  .veh-card.done .veh-status { margin-bottom: 0; }

  .phone-empty { text-align: center; padding: 36px 22px; }
  .phone-empty .pe-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--chip); color: var(--ink-64); display: grid; place-items: center; }
  .phone-empty .pe-ic svg { width: 28px; height: 28px; }
  .phone-empty h3 { font-weight: 700; margin-bottom: 6px; }
  .phone-empty p { font-size: .88rem; color: var(--ink-64); line-height: 1.45; }
  .hoje-block { display: none; }
  .hoje-content[data-hoje="normal"] .hoje-normal,
  .hoje-content[data-hoje="never"] .hoje-never,
  .hoje-content[data-hoje="empty"] .hoje-empty { display: block; }

  .cap-setup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  .cap-setup-row:last-child { border-bottom: 0; }
  .cap-setup-row .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-64); font-weight: 600; }
  /* capture setup: label stacked above value (clean on a narrow phone) */
  .cap-setup-grid { display: grid; gap: 14px; }
  .cap-set { display: grid; gap: 5px; }
  .cap-set-k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-64); font-weight: 600; display: flex; align-items: baseline; gap: 7px; }
  .cap-set-help { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .72rem; color: var(--ink-40); }
  .cap-set-v { font-size: .92rem; font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .cap-hint { font-size: .76rem; color: var(--observacao); margin: 6px 0 0; }
  .cap-op-note { font-size: .8rem; color: var(--ink-64); background: var(--chip); border-radius: var(--r-sm); padding: 10px 12px; margin: 14px 0; line-height: 1.4; }
  .cap-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-64); margin: 20px 0 8px; }
  .cap-finish { width: 100%; min-height: 54px; margin-top: 22px; }
  .cap-blocked { display: none; }
  [data-checklist="missing"] .cap-blocked { display: block; }
  [data-checklist="missing"] .cap-ready { display: none; }
  .phone-body { overflow-x: hidden; }

  /* captura as section tabs */
  #driverStage .phone { position: relative; }
  .dscreen[data-screen="captura"].active { display: flex; flex-direction: column; height: 100%; }
  .cap-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
  .cap-setup-wrap { padding: 14px 16px 0; }
  .cap-allconforme { font-size: .82rem; color: var(--ink-64); background: var(--chip); border-radius: var(--r-sm); padding: 9px 12px; margin: 12px 16px 0; line-height: 1.4; }
  .cap-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 0 10px; position: sticky; top: 0; background: var(--paper); z-index: 3; scrollbar-width: none; margin-top: 12px; }
  .cap-tabs::-webkit-scrollbar { display: none; }
  .cap-tab { flex: 0 0 auto; background: none; border: 0; border-bottom: 2px solid transparent; padding: 13px 10px; font-size: .82rem; font-weight: 600; color: var(--ink-64); white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; min-height: 48px; margin-bottom: -1px; }
  .cap-tab.active { color: var(--carimbo); border-bottom-color: var(--carimbo); }
  .cap-tab-badge { display: inline-flex; align-items: center; gap: 3px; }
  .cap-tab-nc { background: var(--nao-conforme); color: #fff; border-radius: 999px; font-size: .6rem; font-weight: 700; min-width: 15px; height: 15px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; }
  .cap-tab-obs { width: 7px; height: 7px; border-radius: 50%; background: var(--observacao); }
  .cap-panels { padding: 14px 16px 10px; }
  .cap-tabpanel[hidden] { display: none; }
  .cap-footer { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); background: var(--record); }
  .cap-scroll[data-checklist="missing"] + .cap-footer { display: none; }
  .cap-footer-info { flex: 1; text-align: center; font-size: .76rem; color: var(--ink-64); font-weight: 600; white-space: nowrap; }
  .cap-prev, .cap-next { flex: 0 0 auto; min-height: 48px; padding: 10px 14px; white-space: nowrap; }
  .cap-prev[hidden] { display: none; }
  .cap-review { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 12; }
  .cap-review[hidden] { display: none; }
  .cap-review-card { background: var(--record); width: 100%; max-height: 82%; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 18px; }
  .review-counts { font-size: .86rem; color: var(--ink-64); margin: 2px 0 14px; }
  .review-list { display: grid; gap: 8px; }
  .review-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 12px; font-size: .86rem; font-weight: 500; color: var(--ink); cursor: pointer; min-height: 46px; }
  .review-empty { font-size: .88rem; color: var(--conforme-text); }
  .phone .tristate { gap: 6px; }
  .phone .tristate .seg { min-width: 0; font-size: .74rem; padding: 0 4px; gap: 4px; line-height: 1.1; }
  .phone .tristate .seg .g { font-size: .9rem; }
  .cap-photo { margin-top: 10px; }
  .cap-photo .photo-slot { width: 100%; cursor: pointer; }
  .cap-photo[data-photo="filled"] .photo-slot { display: none; }
  .cap-photo[data-photo="empty"] .cap-photo-thumb { display: none; }
  .cap-photo-thumb { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
  .cap-thumb { width: 48px; height: 48px; border-radius: 8px; background: linear-gradient(135deg, var(--cabinet-line), var(--chip)); flex: 0 0 48px; border: 1px solid var(--line); }
  .cap-thumb-txt { font-size: .85rem; font-weight: 600; flex: 1; }
  .nc-only, .obs-only { display: none; }
  .checklist-item[data-result="nc"] .nc-only { display: block; }
  .checklist-item[data-result="obs"] .obs-only { display: block; }

  .ins-card { display: block; width: 100%; text-align: left; background: var(--record); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sheet); padding: 14px; margin-bottom: 10px; cursor: pointer; }
  .ins-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .ins-card-meta { font-size: .82rem; color: var(--ink-64); margin-bottom: 8px; }

  .conta-id { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .avatar.lg { width: 48px; height: 48px; font-size: 1rem; flex: 0 0 48px; }
  .conta-id strong { display: block; font-size: 1.05rem; }
  .conta-id .conta-sub { font-size: .84rem; color: var(--ink-64); }
  .conta-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
  /* driver account menu mirrors the desktop sidebar account popover */
  .conta-menu { padding: 6px; margin-bottom: 6px; }
  .phone .acct-row { min-height: 48px; }
  .conta-sync { margin-bottom: 6px; }
  .conta-sync .conta-row:first-child { padding-top: 2px; }
  .conta-sync-btn { width: 100%; min-height: 50px; margin-top: 12px; }
  .conta-version { border-bottom: 0; }
  .conta-gate-hint { font-size: .76rem; color: var(--ink-64); margin: 8px 2px 0; display: flex; align-items: center; gap: 6px; }
  .conta-gate-hint[hidden] { display: none; }
  .conta-gate-hint .gate-ic { display: inline-flex; flex: 0 0 14px; }
  .conta-gate-hint .gate-ic svg { width: 14px; height: 14px; }
  .is-gated { opacity: .45; pointer-events: none; }
  .dchip { background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: .76rem; font-weight: 600; color: var(--ink); cursor: pointer; min-height: 36px; }

  .phone-tabs { flex: 0 0 auto; display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); background: var(--record); }
  .phone-tabs button { background: none; border: 0; padding: 9px 4px 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-64); font-size: .66rem; font-weight: 600; cursor: pointer; min-height: 56px; }
  .phone-tabs button .pt-ic { display: inline-flex; }
  .phone-tabs button .pt-ic svg { width: 22px; height: 22px; }
  .phone-tabs button.active { color: var(--carimbo); }

  /* mobile bottom nav */
  .bottom-nav { display: none; }
  .scrim { display: none; }

  /* ---------- DARK MODE: component literal overrides ---------- */
  html[data-theme="dark"] :focus-visible { outline-color: rgba(52,199,106,.6); }

  html[data-theme="dark"] input:focus,
  html[data-theme="dark"] select:focus { box-shadow: 0 0 0 3px rgba(52,199,106,.22); }

  html[data-theme="dark"] .b-conforme { background: rgba(61,190,110,.16); color: var(--conforme-text); border-color: rgba(61,190,110,.4); }
  html[data-theme="dark"] .b-nc { background: rgba(235,111,102,.16); color: var(--nao-conforme); border-color: rgba(235,111,102,.4); }
  html[data-theme="dark"] .b-obs { color: var(--observacao); border-color: rgba(224,162,58,.4); }
  html[data-theme="dark"] .b-info { background: rgba(92,208,138,.16); color: var(--indicacao); border-color: rgba(92,208,138,.4); }
  html[data-theme="dark"] .b-crit { background: rgba(235,111,102,.16); color: var(--nao-conforme); border-color: rgba(235,111,102,.4); }

  html[data-theme="dark"] .div-florestal .dt-dot,
  html[data-theme="dark"] .divisao-split .ds-bar .seg-flor { background: #84B68A; }
  html[data-theme="dark"] .div-rodoviario .dt-dot,
  html[data-theme="dark"] .divisao-split .ds-bar .seg-rodo { background: #8AA8D0; }

  html[data-theme="dark"] table.ledger thead th { background: rgba(255,255,255,.04); border-bottom-color: var(--line); }
  html[data-theme="dark"] table.ledger tbody td { border-bottom-color: var(--line); }
  html[data-theme="dark"] table.ledger tbody tr:hover { background: rgba(255,255,255,.03); }
  html[data-theme="dark"] tr.nc-row td { background: rgba(235,111,102,.1); }
  html[data-theme="dark"] tr.low-row td { background: rgba(224,162,58,.1); }

  html[data-theme="dark"] .seg[aria-pressed="true"].s-conforme { color: #06140C; }
  html[data-theme="dark"] .seg[aria-pressed="true"].s-nc { color: #2A0907; }
  html[data-theme="dark"] .seg[aria-pressed="true"].s-obs { border-color: rgba(224,162,58,.4); color: var(--observacao); }

  html[data-theme="dark"] .photo-slot { background: rgba(235,111,102,.12); }
  html[data-theme="dark"] .obs-note { color: var(--observacao); }

  html[data-theme="dark"] .btn-primary { color: #06140C; }
  html[data-theme="dark"] .btn-primary:hover { background: #2CB860; border-color: #2CB860; }
  html[data-theme="dark"] .btn-danger:hover { background: rgba(235,111,102,.14); }
  html[data-theme="dark"] .acct-row-danger:hover { background: rgba(235,111,102,.12); }
  html[data-theme="dark"] .auth-alert { background: rgba(235,111,102,.16); border-color: rgba(235,111,102,.4); color: var(--nao-conforme); }
  html[data-theme="dark"] .robot-check input:checked + .robot-box::after,
  html[data-theme="dark"] .pw-rules li.ok .rule-dot::after,
  html[data-theme="dark"] .asset-row input:checked + .asset-cb::after { border-color: #06140C; }
  html[data-theme="dark"] .warn-box { border-color: rgba(224,162,58,.4); color: var(--observacao); }
  html[data-theme="dark"] .phone-status[data-state="offline"] { color: var(--observacao); }
  html[data-theme="dark"] .phone-status[data-state="expired"] { background: rgba(235,111,102,.16); color: var(--nao-conforme); }

  html[data-theme="dark"] .bottom-nav { box-shadow: 0 -2px 12px rgba(0,0,0,.4); }
  html[data-theme="dark"] .scrim { background: rgba(0,0,0,.6); }

  /* ---------- RESPONSIVE ---------- */
  @media (max-width: 1100px) {
    .cards-4 { grid-template-columns: repeat(2,1fr); }
  }
  @media (max-width: 900px) {
    .app { grid-template-columns: 1fr; grid-template-areas: "head" "main"; }
    .app.collapsed { grid-template-columns: 1fr; }
    #collapseBtn { display: none; }
    .crumb { min-width: 0; overflow: hidden; }
    .crumb > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .side {
      position: fixed; left: 0; top: 0; bottom: 0; width: 264px;
      transform: translateX(-100%); transition: transform .2s ease;
    }
    .app.nav-open .side { transform: translateX(0); }
    .scrim {
      position: fixed; inset: 0; background: rgba(20,24,30,.5); z-index: 35;
    }
    .app.nav-open .scrim { display: block; }
    .cards-3 { grid-template-columns: 1fr 1fr; }
    .main { padding: 18px 16px 90px; }
    .bottom-nav {
      display: grid; grid-template-columns: repeat(5,1fr);
      position: fixed; bottom: 0; left: 0; right: 0;
      background: var(--record); border-top: 1px solid var(--line);
      z-index: 36; box-shadow: 0 -2px 12px rgba(27,31,38,.08);
    }
    .bn-item {
      background: none; border: 0; padding: 8px 4px 9px;
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      color: var(--ink-64); font-size: .64rem; font-weight: 600;
    }
    .bn-item .ic { font-size: 1.15rem; }
    .bn-item.active { color: var(--indicacao); }
    .bn-item.accent { color: var(--carimbo); }
  }
  @media (max-width: 640px) {
    body { font-size: 17px; }
    .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr; }
    .page-title { font-size: 1.55rem; }
    input, select { min-height: 44px; padding: 11px 12px; }
    .gantry button { min-height: 44px; }
    .btn-sm { min-height: 44px; }
    .form-actions .btn { min-height: 44px; }
    body.driver-mode #driverStage { padding: 0; }
    .phone { width: 100%; height: 100vh; max-width: none; border: 0; border-radius: 0; box-shadow: none; }
    /* stacked table cards */
    table.responsive thead { display: none; }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
    table.responsive tr {
      border: 1px solid var(--line); border-radius: var(--r);
      margin-bottom: 10px; background: var(--record); padding: 4px 0;
    }
    table.responsive td { border: 0 !important; box-shadow: none !important; display: flex; justify-content: space-between; gap: 16px; padding: 8px 14px; text-align: right; }
    table.responsive td::before {
      content: attr(data-label);
      font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
      color: var(--ink-64); text-align: left; flex: 0 0 auto;
    }
    table.responsive td .num, table.responsive td.num { text-align: right; }
    tr.nc-row td:first-child, tr.low-row td:first-child { box-shadow: none !important; }
  }
  @media (min-width: 901px) { body.has-menu .icon-btn.menu { display: none; } }

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

/* ============================================================
   Shared component + utility layer (moved out of the layout.html inline bridge so
   every admin page — and the coming modules — draw from this single stylesheet).
   Loaded after the base rules above, so legacy-markup overrides still win.
   ============================================================ */

/* Shell tweaks */
.drawer.open > .drawer-body { max-height: 1000px; }
.scrim { display: none; }
.nav-item, .brand, .acct-row, .drawer-head { text-decoration: none; }
.brand-txt { display: flex; flex-direction: column; }
.brand-txt span { margin-top: 1px; }

/* Gantry sub-tabs: keep horizontal scroll for overflow but hide the scrollbar chrome. */
.gantry { overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.gantry::-webkit-scrollbar { display: none; }
.gantry a { background: none; border: 0; padding: 9px 14px; color: var(--ink-64); font-weight: 600;
  font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.gantry a:hover { color: var(--ink); text-decoration: none; }
.gantry a.active { color: var(--indicacao); border-bottom-color: var(--indicacao); }

/* Radio-backed tri-state (the .seg above is button/aria-pressed based). */
.tristate label.seg { cursor: pointer; position: relative; }
.tristate label.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.tristate label.seg.s-conforme:has(input:checked) { background: var(--conforme); border-color: var(--conforme); color: #fff; }
.tristate label.seg.s-nc:has(input:checked) { background: var(--nao-conforme); border-color: var(--nao-conforme); color: #fff; }
.tristate label.seg.s-obs:has(input:checked) { background: var(--observacao-tint); border-color: #E6D4AC; color: #7A5512; }
.tristate label.seg:focus-within { outline: 3px solid rgba(21,128,61,.45); outline-offset: 2px; }
/* Older WebViews (< Chrome 105) lack :has(); show the radio so the chosen tri-state stays legible. */
@supports not (selector(:has(*))) {
  .tristate label.seg input { position: static; opacity: 1; width: auto; height: auto; margin-right: 5px; }
}

/* Page scaffolding + text utilities */
.app > main { grid-area: main; padding: 24px 28px 64px; max-width: 1320px; min-width: 0; }
h1 { font-size: 1.95rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 1rem; }
.muted { color: var(--ink-64); font-size: .9rem; }
.nc { color: var(--nao-conforme); font-weight: 600; }
.print-only { display: none; }

/* Card (legacy panel; .sheet is the prototype equivalent) */
.card { background: var(--record); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sheet); padding: 18px; margin-bottom: 16px; }
.card.tight { padding: 14px; }
.card h2 { font-size: 1.05rem; margin: 0 0 .6rem; }

/* Tag + dot-badge variants */
.tag { display: inline-block; background: var(--chip); color: var(--ink-64); border-radius: var(--r-sm);
  padding: .14rem .5rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.tag.crit { background: #FBF1F0; color: var(--nao-conforme); }
.badge.ok, .badge.bad, .badge.warn, .badge.off { border: 1px solid transparent; }
.badge.ok::before, .badge.bad::before, .badge.warn::before, .badge.off::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: #EBF3EE; color: var(--conforme-text); border-color: #BCD3C4; }
.badge.bad { background: #FAEEED; color: var(--nao-conforme); border-color: #E2BEBA; }
.badge.warn { background: var(--observacao-tint); color: #7A5512; border-color: #E6D4AC; }
.badge.off { background: var(--paper); color: var(--ink-64); border-color: var(--line); }
html[data-theme="dark"] .badge.ok { background: rgba(61,190,110,.16); color: var(--conforme-text); border-color: rgba(61,190,110,.4); }
html[data-theme="dark"] .badge.bad { background: rgba(235,111,102,.16); color: var(--nao-conforme); border-color: rgba(235,111,102,.4); }
html[data-theme="dark"] .badge.warn { background: rgba(224,162,58,.16); color: var(--observacao); border-color: rgba(224,162,58,.4); }

/* Pills, progress bars, pager, alert boxes */
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  border: 1px solid var(--line); color: var(--ink-64); background: var(--paper); white-space: nowrap; }
.bar-track { background: var(--chip); height: 16px; border-radius: 8px; min-width: 2px; overflow: hidden; }
.bar-fill { background: var(--indicacao); height: 100%; border-radius: 8px; }
.bar-fill.crit, .bar-fill.nc { background: var(--nao-conforme); }
.pager { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.error { background: #FAEEED; color: var(--nao-conforme); padding: .65rem .9rem; border-radius: var(--r);
  margin-bottom: 1rem; border: 1px solid #E2BEBA; }
.notice { background: #EBF3EE; color: var(--conforme-text); padding: .65rem .9rem; border-radius: var(--r);
  margin-bottom: 1rem; border: 1px solid #BCD3C4; }
html[data-theme="dark"] .error { background: rgba(235,111,102,.16); border-color: rgba(235,111,102,.4); }
html[data-theme="dark"] .notice { background: rgba(61,190,110,.16); border-color: rgba(61,190,110,.4); }

/* Bare form controls used by legacy forms */
label { display: block; margin: .9rem 0 .35rem; font-weight: 600; font-size: .82rem; color: var(--ink-64);
  text-transform: uppercase; letter-spacing: .04em; }
textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r);
  font-size: .95rem; background: var(--record); color: var(--ink); font-family: inherit; }

/* Buttons: bare .btn = primary green; modifier variants keep their own style */
.btn { cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.secondary):not(.danger) { background: var(--carimbo); color: #fff; border-color: var(--carimbo); }
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.secondary):not(.danger):hover { background: #115C30; border-color: #115C30; color: #fff; }
.btn.secondary { background: var(--record); border-color: var(--line); color: var(--ink); }
.btn.secondary:hover { background: var(--paper); }
.btn.danger { background: transparent; border-color: var(--nao-conforme); color: var(--nao-conforme); }
.btn.danger:hover { background: #FAEEED; }
.btn.sm { padding: 7px 11px; font-size: .82rem; }

/* Inspection laudo (inspection_detail) */
.badge-lg { font-size: .85rem; padding: 5px 12px; }
.laudo-verdict { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.laudo-verdict .lv-total { margin-left: auto; font-size: .8rem; white-space: nowrap; }
.laudo-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem 1.5rem; padding: 13px 18px; font-size: .9rem; }
.laudo-meta .lm-k { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-64); margin-bottom: 2px; }
.ck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 16px; }
.ck-cell { display: flex; align-items: baseline; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--line); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.ck-num { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums slashed-zero; font-size: .72rem; color: var(--ink-40); min-width: 1.6em; text-align: right; flex: 0 0 auto; }
.ck-glyph { width: 1.1em; text-align: center; font-size: .8rem; color: var(--conforme-text); flex: 0 0 auto; }
.ck-label { font-size: .84rem; line-height: 1.3; }
.ck-cell.is-nc { background: #FCF4F3; }
.ck-cell.is-nc .ck-glyph { color: var(--nao-conforme); font-weight: 700; }
.ck-cell.is-obs { background: var(--observacao-tint); }
.ck-cell.is-obs .ck-glyph { color: var(--observacao); font-weight: 700; }
html[data-theme="dark"] .ck-cell.is-nc { background: rgba(235,111,102,.12); }
html[data-theme="dark"] .ck-cell.is-obs { background: rgba(224,162,58,.12); }

.row-actions { white-space: nowrap; }
main table { width: 100%; border-collapse: collapse; }
main table:not(.ledger) th { text-align: left; font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-64); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
main table:not(.ledger) td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
main table:not(.ledger) tbody tr:last-child td { border-bottom: 0; }

/* Modal (xanaduConfirm / xanaduAlert) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 1rem; }
.modal-card { background: var(--record); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-pop); max-width: 440px; width: 100%; padding: 1.4rem; }
.modal-card p { margin: 0 0 1.2rem; line-height: 1.5; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

@media print {
  @page { margin: 1.1cm; }
  :root, html[data-theme="dark"] {
    --paper: #fff; --record: #fff; --line: #ccc; --ink: #000; --ink-64: #333; --ink-40: #666;
    --carimbo: #0f5132; --indicacao: #0f5132; --conforme-text: #0a6b2f; --nao-conforme: #9b1c1c; --observacao: #92400e; --chip: #f1f1f1;
  }
  .side, .head, .scrim, .noprint, #to-top { display: none !important; }
  .app { display: block; }
  .app > main, .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet, .card { border: 0; box-shadow: none; padding: 0; margin: 0 0 8px; }
  table.ledger, main table { font-size: 9.5px; }
  table.ledger thead th, main table th { background: #fff; color: #000; padding: 2px 4px; border-bottom: 1px solid #ccc; }
  table.ledger tbody td, main table td { padding: 2px 4px; border-bottom: 1px solid #ccc; }
  thead { display: table-header-group; }
  tr.nc-row td { background: #f3f3f3 !important; }
  tr.nc-row td:first-child { box-shadow: none; border-left: 3px solid #000; }
  .badge, .tag, .plate, .div-tag { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; }
  .print-only { display: block; }
  .laudo-verdict { padding: 5px 0; border-bottom: 1px solid #ccc; }
  .laudo-meta { padding: 6px 0; gap: 4px 18px; grid-template-columns: repeat(4, 1fr); }
  .laudo-meta .lm-k { font-size: 7px; }
  .ck-grid { grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
  .ck-cell { padding: 1px 2px; break-inside: avoid; border-bottom: 1px solid #eee; border-radius: 0; }
  .ck-cell.is-nc { background: #f3f3f3 !important; }
  .ck-cell.is-obs { background: #fff !important; }
  .ck-label { font-size: 8.5px; }
  .ck-num, .ck-glyph { font-size: 8px; }
  .ck-cell.is-nc .ck-glyph, .ck-cell.is-obs .ck-glyph { color: #000; }
  h2 { font-size: 12px; margin: 0 0 4px; }
  .apts tr, .laudo-meta > div { break-inside: avoid; }
  .photo-grid img { max-height: 96px !important; border-radius: 0 !important; }
}
