:root {
  --bg: #f3f1eb;
  --surface: #fffdf8;
  --surface-2: #e8e5dd;
  --ink: #18201d;
  --muted: #68716c;
  --line: #d9d7cf;
  --accent: #d8694a;
  --accent-dark: #9f3e29;
  --green: #285d4a;
  --danger: #a53030;
  --shadow: 0 16px 48px rgba(31, 38, 35, .09);
  --radius: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --surface: #1b201e; --surface-2: #262c29; --ink: #f4f1e9;
    --muted: #aab3ae; --line: #353c39; --accent: #e17a5c; --accent-dark: #f19a80;
    --green: #86bea8; --danger: #f08a8a; --shadow: 0 16px 48px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; font-size: 16px; }
button, a { touch-action: manipulation; }
a { color: var(--green); text-underline-offset: 3px; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--accent-dark); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(1.75rem, 6vw, 2.6rem); letter-spacing: -.04em; line-height: 1.05; }
h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.connection-banner { position: fixed; z-index: 100; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 9px 16px; border-radius: 99px; background: var(--ink); color: var(--bg); font-weight: 750; box-shadow: var(--shadow); }
.toast { position: fixed; z-index: 120; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 13px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); text-align: center; }
.auth-shell, .offline-shell { min-height: 100vh; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom)); }
.auth-card { width: min(100%, 430px); padding: 30px; border: 1px solid var(--line); border-radius: 32px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card > .muted { margin: 12px 0 26px; line-height: 1.5; }
.brand-mark { width: 58px; height: 58px; display: flex; align-items: flex-end; gap: 5px; margin-bottom: 24px; padding: 12px; border-radius: 18px; background: var(--ink); }
.brand-mark span { width: 7px; height: 28px; border-radius: 9px; background: var(--bg); opacity: .92; transform: rotate(-13deg); }
.brand-mark span:nth-child(2) { height: 22px; opacity: .65; }
.brand-mark span:nth-child(3) { height: 15px; opacity: .38; }
.stack { display: grid; gap: 11px; }
.stack label { font-weight: 700; font-size: .9rem; }
input, select { min-height: 48px; width: 100%; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); color: var(--ink); padding: 10px 13px; }
.pin-input { text-align: center; font-size: 1.55rem; letter-spacing: .35em; }
.user-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 8px; padding: 0; border: 0; }
.user-picker input { position: absolute; opacity: 0; pointer-events: none; }
.user-picker span { min-height: 52px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); font-weight: 750; }
.user-picker input:checked + span { border-color: var(--accent); color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--accent); }
.primary-button, .small-button, .primary-small, .ghost-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: 13px; padding: 10px 16px; font-weight: 800; text-decoration: none; }
.primary-button, .primary-small { border: 0; background: var(--ink); color: var(--bg); }
.small-button, .ghost-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.form-error { min-height: 1.25em; margin: 0; color: var(--danger); font-size: .9rem; }
.auth-footer { display: flex; justify-content: space-between; margin-top: 25px; font-size: .85rem; }
.app-shell { width: min(100%, 720px); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 18px calc(98px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.topbar .muted { margin: 8px 0 0; }
.topbar.compact { margin-bottom: 22px; }
.icon-button { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 1.3rem; }
.hero-counter { margin: 22px 0 2px; text-align: center; }
.hero-counter p { margin: 0; font-size: .85rem; }
.hero-counter strong { display: block; font-size: clamp(4rem, 20vw, 7.2rem); letter-spacing: -.08em; line-height: .95; font-variant-numeric: tabular-nums; }
.action-zone { min-height: 330px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.smoke-button { width: min(76vw, 285px); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 18px 40px rgba(180, 75, 47, .3), inset 0 -10px 0 rgba(91, 30, 18, .13); transition: transform .14s ease, filter .14s ease; }
.smoke-button:active { transform: scale(.96); }
.smoke-button:disabled { cursor: wait; filter: saturate(.5); opacity: .75; }
.smoke-button > span:nth-child(2) { font-size: 1.55rem; font-weight: 850; letter-spacing: -.03em; }
.smoke-button small { opacity: .78; }
.smoke-icon { display: flex; align-items: flex-end; gap: 5px; height: 45px; }
.smoke-icon i { display: block; width: 7px; height: 35px; border-radius: 8px; background: white; transform: rotate(-11deg); opacity: .92; }
.smoke-icon i:nth-child(2) { height: 27px; opacity: .65; }
.smoke-icon i:nth-child(3) { height: 18px; opacity: .4; }
.action-status { min-height: 25px; margin-top: 15px; color: var(--green); font-weight: 800; text-align: center; }
.undo-button { min-height: 44px; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--accent-dark); font-weight: 800; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 10px 0 26px; }
.metric-grid article { min-width: 0; padding: 15px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.metric-grid span, .metric-grid small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.25; }
.metric-grid strong { display: block; margin: 7px 0 4px; font-size: 1.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-card, .filter-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-card { padding: 20px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-heading a { font-size: .85rem; }
.event-list, .history-list { margin: 0; padding: 0; list-style: none; }
.event-list li { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.event-list li:first-child { border-top: 0; }
.event-list time { font-variant-numeric: tabular-nums; font-weight: 800; }
.empty { color: var(--muted); text-align: center; padding: 24px !important; }
.bottom-nav { position: fixed; z-index: 50; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 560px); display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.bottom-nav a { min-height: 45px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 750; }
.bottom-nav a.active { background: var(--ink); color: var(--bg); }
.filter-card { padding: 12px; margin-bottom: 12px; }
.segmented { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.segmented button { min-height: 44px; flex: 0 0 auto; border: 0; border-radius: 11px; padding: 8px 13px; background: transparent; color: var(--muted); font-weight: 700; }
.segmented button.active { background: var(--ink); color: var(--bg); }
.range-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
.range-form label { font-size: .75rem; color: var(--muted); }
.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stats-summary div { min-width: 0; }
.stats-summary span { display: block; color: var(--muted); font-size: .72rem; }
.stats-summary strong { display: block; margin-top: 5px; font-size: 1.15rem; }
.history-list li { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.history-list li:first-child { border: 0; }
.history-list .time { font-weight: 850; font-variant-numeric: tabular-nums; }
.history-list small { color: var(--muted); }
.status { padding: 5px 8px; border-radius: 99px; background: var(--surface-2); font-size: .7rem; font-weight: 750; }
.status.cancelled { color: var(--danger); text-decoration: line-through; }
.admin-shell { width: min(100% - 32px, 1280px); margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 0 60px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 12px; }
.admin-cards article { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.admin-cards span { display: block; color: var(--muted); font-size: .78rem; }
.admin-cards strong { display: block; margin-top: 7px; font-size: 1.7rem; }
.admin-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.panel { padding: 20px; margin-bottom: 12px; }
.chart-panel canvas { width: 100%; height: 240px; display: block; }
.filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 8px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
.user-admin-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.user-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.user-card .section-heading { margin: 0 0 12px; }
.user-card p { color: var(--muted); font-size: .8rem; }
dialog { width: min(calc(100% - 28px), 540px); border: 0; border-radius: 24px; padding: 0; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgba(8, 12, 10, .68); backdrop-filter: blur(5px); }
.dialog-card { position: relative; padding: 25px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.dialog-card h2 { margin-bottom: 20px; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.document-shell { width: min(calc(100% - 36px), 720px); margin: 0 auto; padding: max(40px, env(safe-area-inset-top)) 0 60px; }
.document-shell h1 { margin-bottom: 30px; font-size: clamp(2.4rem, 8vw, 4.5rem); }
.document-shell p { font-size: 1.05rem; line-height: 1.7; }
.back-link { display: inline-block; margin-bottom: 45px; }
.offline-shell { width: min(calc(100% - 36px), 460px); text-align: center; }
.offline-shell .brand-mark { margin-inline: auto; }
.offline-shell p { color: var(--muted); line-height: 1.6; }
@media (max-width: 850px) {
  .admin-cards { grid-template-columns: repeat(3, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .user-admin-list { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .auth-card { padding: 24px 20px; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid article { padding: 13px 9px; }
  .metric-grid strong { font-size: 1.08rem; }
  .stats-summary { grid-template-columns: repeat(2, 1fr); }
  .range-form, .filters { grid-template-columns: 1fr 1fr; }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-cards { grid-template-columns: repeat(2, 1fr); }
  .admin-shell { width: min(100% - 20px, 1280px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
