:root {
    --navy-950: #0e1e2d;
    --navy-900: #14293d;
    --navy-800: #1c3b52;
    --teal-700: #0b716b;
    --teal-600: #108b83;
    --teal-100: #dff3f0;
    --ink: #193040;
    --muted: #5e7180;
    --line: #d6e0e5;
    --line-strong: #b8c8d0;
    --paper: #f8faf9;
    --white: #ffffff;
    --warning: #98620a;
    --warning-bg: #fff5d9;
    --danger: #a23a3a;
    --danger-bg: #fff0ef;
    --success: #146c50;
    --success-bg: #e7f6ef;
    --shadow: 0 16px 40px rgba(20, 41, 61, .08);
    --radius: 10px;
    --radius-small: 6px;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font-sans); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--teal-700); text-underline-offset: 3px; }
a:hover { color: var(--navy-800); }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
:focus-visible { outline: 3px solid rgba(16, 139, 131, .42); outline-offset: 2px; }

.skip-link { position: fixed; top: -100px; left: 16px; z-index: 50; padding: 10px 14px; color: var(--white); background: var(--navy-900); border-radius: 0 0 var(--radius-small) var(--radius-small); }
.skip-link:focus { top: 0; }
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { display: flex; position: fixed; z-index: 20; inset: 0 auto 0 0; width: 270px; flex-direction: column; color: #e9f1f3; background: var(--navy-900); border-right: 1px solid rgba(255,255,255,.08); }
.brand-lockup { display: flex; align-items: center; justify-content: space-between; padding: 24px 22px 20px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--white); text-decoration: none; }
.brand img { display: block; width: 42px; height: 42px; }
.brand-copy { display: grid; line-height: 1.02; letter-spacing: -.02em; }
.brand-copy strong { font-size: 1.08rem; font-weight: 720; }
.brand-copy span { color: #a8c3c9; font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; }
.primary-nav { overflow-y: auto; padding: 8px 13px 20px; }
.nav-label { margin: 12px 10px 6px; color: #81a7af; font-size: .67rem; font-weight: 760; letter-spacing: .12em; text-transform: uppercase; }
.nav-label-spaced { margin-top: 26px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 3px 0; padding: 9px 11px; color: #d5e4e7; border-radius: 7px; font-size: .91rem; text-decoration: none; transition: background-color 150ms ease, color 150ms ease; }
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--white); background: rgba(91, 197, 188, .15); }
.nav-link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--teal-600); }
.nav-mark { width: 18px; color: #6cc4bd; font-size: .82rem; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 18px 21px 22px; border-top: 1px solid rgba(255,255,255,.08); }
.legal-note { margin: 0; color: #9db7bd; font-size: .72rem; line-height: 1.45; }
.app-main-column { width: calc(100% - 270px); min-width: 0; margin-left: 270px; }
.app-header { display: flex; position: sticky; z-index: 10; top: 0; align-items: center; min-height: 74px; padding: 14px clamp(18px, 4vw, 56px); background: rgba(248, 250, 249, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(9px); }
.header-context { display: grid; gap: 1px; }
.eyebrow { color: var(--teal-700); font-size: .69rem; font-weight: 780; letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; }
.header-path { color: var(--navy-900); font-size: .92rem; font-weight: 650; }
.header-actions { display: flex; align-items: center; gap: 13px; margin-left: auto; }
.session-user { max-width: 260px; overflow: hidden; color: var(--muted); font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; color: var(--navy-800); background: transparent; border: 1px solid transparent; border-radius: var(--radius-small); font-size: 1.35rem; line-height: 1; }
.icon-button:hover { background: var(--teal-100); }
.menu-toggle, .sidebar-close { display: none; }
.page-content { width: min(1420px, 100%); min-height: calc(100vh - 128px); margin: 0 auto; padding: clamp(24px, 4vw, 54px) clamp(18px, 4vw, 56px); }
.page-mount { min-width: 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { max-width: 780px; margin: 4px 0 7px; color: var(--navy-900); font-size: clamp(1.75rem, 3vw, 2.7rem); letter-spacing: -.045em; line-height: 1.05; }
.page-heading p { max-width: 720px; margin: 0; color: var(--muted); }
.page-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 30px 0 12px; }
.section-title h2 { margin: 0; color: var(--navy-900); font-size: 1.15rem; letter-spacing: -.02em; }
.section-title p { margin: 0; color: var(--muted); font-size: .86rem; }
.grid { display: grid; gap: 18px; }
.grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.card { min-width: 0; padding: 22px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(20, 41, 61, .035); }
.card h2, .card h3 { margin: 0 0 6px; color: var(--navy-900); letter-spacing: -.025em; }
.card h2 { font-size: 1.16rem; }
.card h3 { font-size: 1rem; }
.card > p:first-of-type { margin-top: 0; }
.card-muted { background: #f1f6f5; border-style: dashed; }
.card-accent { border-top: 4px solid var(--teal-600); }
.metric { display: flex; min-height: 130px; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: .78rem; font-weight: 680; letter-spacing: .045em; text-transform: uppercase; }
.metric-value { margin: 8px 0 1px; color: var(--navy-900); font-family: var(--font-mono); font-size: clamp(1.65rem, 3vw, 2.55rem); font-weight: 720; letter-spacing: -.06em; line-height: 1; }
.metric-note { color: var(--muted); font-size: .78rem; }
.prose { max-width: 840px; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 8px 0 18px; padding-left: 22px; }
.prose li { margin: 6px 0; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; color: var(--white); background: var(--teal-700); border: 1px solid var(--teal-700); border-radius: 6px; font-size: .87rem; font-weight: 720; text-decoration: none; transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease; }
.button:hover { color: var(--white); background: #095b56; border-color: #095b56; }
.button:active { transform: translateY(1px); }
.button-secondary { color: var(--navy-900); background: var(--white); border-color: var(--line-strong); }
.button-secondary:hover { color: var(--navy-900); background: #eef4f3; border-color: var(--teal-600); }
.button-quiet { color: var(--navy-800); background: transparent; border-color: transparent; }
.button-quiet:hover { color: var(--navy-900); background: #eaf2f2; }
.button-danger { color: var(--danger); background: var(--white); border-color: #e3b4b0; }
.button-danger:hover { color: #7d2828; background: var(--danger-bg); border-color: var(--danger); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: .8rem; }
.button-block { width: 100%; }
.button-large { min-height: 52px; padding: 12px 20px; font-size: 1rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 17px; }
.form-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: var(--navy-900); font-size: .82rem; font-weight: 700; }
.field label .optional { color: var(--muted); font-size: .75rem; font-weight: 450; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: var(--white); border: 1px solid var(--line-strong); border-radius: 5px; }
.field textarea { min-height: 92px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #85959d; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal-600); outline: 2px solid rgba(16, 139, 131, .14); }
.field-help { margin: 5px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.35; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; grid-column: 1 / -1; margin-top: 3px; }
.form-status { min-height: 22px; margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.form-status[data-state="error"] { color: var(--danger); }
.form-status[data-state="success"] { color: var(--success); }

.alert-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; color: var(--navy-900); background: var(--teal-100); border: 1px solid #b8e2dc; border-radius: 6px; font-size: .88rem; }
.alert::before { content: "i"; display: inline-grid; flex: 0 0 20px; width: 20px; height: 20px; place-items: center; color: var(--white); background: var(--teal-700); border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }
.alert-error { color: #7d2828; background: var(--danger-bg); border-color: #e3b4b0; }
.alert-error::before { content: "!"; background: var(--danger); }
.alert-warning { color: #71500b; background: var(--warning-bg); border-color: #ecd594; }
.alert-warning::before { content: "!"; background: var(--warning); }
.alert-success { color: var(--success); background: var(--success-bg); border-color: #b9dfce; }
.alert-success::before { content: "✓"; background: var(--success); }
.empty-state { padding: 28px 18px; color: var(--muted); background: #f4f7f6; border: 1px dashed var(--line-strong); border-radius: var(--radius-small); text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--navy-900); }
.loading { padding: 26px 0; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 9px; vertical-align: -2px; border: 2px solid #bbd4d1; border-top-color: var(--teal-700); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-small); }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; background: var(--white); font-size: .84rem; }
.data-table th { padding: 11px 13px; color: var(--muted); background: #f3f7f6; border-bottom: 1px solid var(--line); font-size: .7rem; font-weight: 760; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-bottom: 1px solid #e7edef; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdfd; }
.data-table .actions-cell { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: .88em; }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; color: var(--navy-800); background: #e8eff0; border-radius: 99px; font-size: .71rem; font-weight: 700; }
.status-pill-success { color: var(--success); background: var(--success-bg); }
.status-pill-warning { color: #795208; background: var(--warning-bg); }
.status-pill-danger { color: var(--danger); background: var(--danger-bg); }
.status-pill-teal { color: var(--teal-700); background: var(--teal-100); }
.list-plain { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.list-plain li { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #e7edef; }
.list-plain li:last-child { border-bottom: 0; }
.list-key { color: var(--muted); }
.list-value { color: var(--navy-900); font-weight: 650; text-align: right; }

.ponto-hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 18px; align-items: stretch; }
.clock-panel { display: flex; min-height: 300px; flex-direction: column; justify-content: center; padding: clamp(24px, 4vw, 48px); color: var(--white); background: var(--navy-900); border-radius: var(--radius); box-shadow: var(--shadow); }
.clock-panel .eyebrow { color: #8dd0c9; }
.clock-panel h2 { max-width: 640px; margin: 7px 0 12px; color: var(--white); font-size: clamp(1.6rem, 3.7vw, 3.1rem); letter-spacing: -.055em; line-height: 1.04; }
.clock-panel p { max-width: 600px; margin: 0 0 24px; color: #c4d8da; }
.clock-panel .button { align-self: flex-start; color: var(--navy-900); background: #8dd0c9; border-color: #8dd0c9; }
.clock-panel .button:hover { background: var(--white); border-color: var(--white); }
.server-time { color: #c4d8da; font-family: var(--font-mono); font-size: .88rem; }
.location-indicator { display: flex; min-height: 100%; flex-direction: column; justify-content: space-between; padding: 24px; background: var(--teal-100); border: 1px solid #b8e2dc; border-radius: var(--radius); }
.location-indicator h3 { margin-top: 0; }
.location-state { margin: 12px 0; color: var(--navy-900); font-weight: 650; }
.location-detail { margin: 0; color: var(--muted); font-size: .82rem; }
.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline-item { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 0 0 21px; }
.timeline-item::before { content: ""; position: absolute; top: 10px; bottom: 0; left: 8px; width: 1px; background: var(--line-strong); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { z-index: 1; width: 17px; height: 17px; margin-top: 2px; background: var(--teal-600); border: 4px solid var(--teal-100); border-radius: 50%; }
.timeline-time { color: var(--navy-900); font-family: var(--font-mono); font-weight: 700; }
.timeline-meta { color: var(--muted); font-size: .8rem; }

.auth-page { display: grid; min-height: calc(100vh - 130px); place-items: center; }
.auth-card { width: min(500px, 100%); padding: clamp(24px, 5vw, 42px); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 25px; }
.auth-brand img { width: 40px; height: 40px; }
.auth-card h1 { margin: 0 0 8px; color: var(--navy-900); font-size: 1.85rem; letter-spacing: -.045em; }
.auth-card .lead { margin: 0 0 24px; color: var(--muted); }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 17px; font-size: .85rem; }
.auth-note { margin-top: 26px; padding-top: 15px; color: var(--muted); border-top: 1px solid var(--line); font-size: .76rem; }

details.disclosure { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-small); }
details.disclosure + details.disclosure { margin-top: 10px; }
details.disclosure summary { padding: 14px 16px; color: var(--navy-900); cursor: pointer; font-weight: 720; }
details.disclosure[open] summary { border-bottom: 1px solid var(--line); }
.disclosure-body { padding: 16px; }
.notice { padding: 13px 15px; color: var(--navy-800); background: #f1f6f5; border-left: 3px solid var(--teal-600); font-size: .86rem; }
.map-pending { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; color: #71500b; background: var(--warning-bg); border: 1px solid #ecd594; border-radius: var(--radius-small); font-size: .84rem; }
.admin-map { min-height: 360px; margin: 12px 0 9px; overflow: hidden; background: #e8efee; border: 1px solid var(--line-strong); border-radius: var(--radius-small); }
.admin-map .leaflet-control-attribution { font-size: .66rem; }
.map-status { min-height: 22px; margin: 0; color: var(--muted); font-size: .78rem; }
.history-summary { margin: 13px 0 0; }

.receipt-dialog { width: min(620px, calc(100% - 24px)); max-height: min(760px, calc(100vh - 24px)); padding: 0; color: var(--ink); background: var(--white); border: 0; border-radius: var(--radius); box-shadow: 0 24px 80px rgba(14, 30, 45, .28); }
.receipt-dialog::backdrop { background: rgba(14, 30, 45, .52); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 5px 0 0; color: var(--navy-900); font-size: 1.4rem; letter-spacing: -.035em; }
.receipt-content { max-height: 55vh; overflow-y: auto; padding: 22px 24px; }
.receipt-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.receipt-field { padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.receipt-field dt { color: var(--muted); font-size: .7rem; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
.receipt-field dd { margin: 3px 0 0; color: var(--navy-900); font-weight: 680; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 24px 22px; border-top: 1px solid var(--line); }

.app-footer { display: flex; flex-wrap: wrap; gap: 6px 22px; min-height: 54px; align-items: center; padding: 15px clamp(18px, 4vw, 56px); color: var(--muted); border-top: 1px solid var(--line); font-size: .74rem; }

@media (max-width: 1080px) {
    .grid-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ponto-hero { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .app-sidebar { transform: translateX(-102%); transition: transform 180ms ease; box-shadow: 12px 0 30px rgba(14, 30, 45, .2); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-backdrop { display: none; position: fixed; z-index: 15; inset: 0; background: rgba(14, 30, 45, .42); }
    .app-backdrop.is-visible { display: block; }
    .app-main-column { width: 100%; margin-left: 0; }
    .menu-toggle, .sidebar-close { display: inline-grid; }
    .menu-toggle { margin-right: 10px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-heading-actions { justify-content: flex-start; }
    .grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .app-header { min-height: 64px; padding: 10px 15px; }
    .header-context .eyebrow { font-size: .6rem; }
    .header-path { font-size: .83rem; }
    .session-user { display: none; }
    .page-content { padding: 27px 15px 36px; }
    .page-heading h1 { font-size: 2rem; }
    .card { padding: 17px; }
    .grid-two, .grid-three, .grid-four, .form-grid, .form-grid-three { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .form-actions { grid-column: auto; }
    .receipt-summary { grid-template-columns: 1fr; }
    .admin-map { min-height: 280px; }
    .app-footer { align-items: flex-start; flex-direction: column; gap: 5px; }
}
@media print {
    body * { visibility: hidden; }
    #receipt-dialog, #receipt-dialog * { visibility: visible; }
    #receipt-dialog { position: absolute; inset: 0; width: 100%; max-height: none; box-shadow: none; }
    .dialog-actions, .dialog-head .icon-button { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
