/* 현장노트 — sober navy/teal fieldwork UI.
   Layouts: desktop ≥1100px (sidebar + list/detail workspace),
   tablet 760–1099px (icon rail + focused single pane),
   mobile <760px (top bar + bottom 5 tabs + card flow). */

:root {
  --ink: #123d47;
  --ink-deep: #0d2c35;
  --ink-soft: #2b5561;
  --teal: #126a68;
  --teal-strong: #0b5452;
  --teal-tint: #e3f1ee;
  --mint: #52b7a8;
  --bg: #f3f6f5;
  --surface: #fff;
  --surface-2: #f7faf9;
  --line: #dbe5e2;
  --line-strong: #c3d3cf;
  --text: #1b3036;
  --muted: #5a7177;
  --danger: #a43434;
  --danger-tint: #fbeceb;
  --warn: #8a5a10;
  --warn-tint: #fff3d6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(13 44 53 / .05), 0 4px 16px rgb(13 44 53 / .05);
  --sidebar: 248px;
  --rail: 88px;
  --topbar: 60px;
  --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
h1, h2, h3 { color: var(--ink-deep); margin: 0; line-height: 1.3; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--teal); }
ul, ol { margin: 0; padding: 0; }
dl, dd { margin: 0; }
[tabindex="-1"]:focus { outline: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.hint { font-size: 13px; color: var(--muted); }
.warning { color: var(--warn); background: var(--warn-tint); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--teal); letter-spacing: .02em; }

/* ---------- Controls ---------- */

button, .button, input, select, textarea { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 650; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
  touch-action: manipulation; transition: background-color .12s, border-color .12s;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--ink-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); border-color: var(--line-strong); }
.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); }
.primary:disabled:hover { background: var(--teal); border-color: var(--teal); }
.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.ghost:hover { background: var(--teal-tint); border-color: transparent; }
.danger { color: var(--danger); }
.danger:hover { background: var(--danger-tint); border-color: #e0b8b5; }
.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-solid:hover { background: #8a2828; border-color: #8a2828; }
button.small, .button.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.block { width: 100%; }
.large { min-height: 52px; padding: 12px 22px; font-size: 16px; }
.icon-button { width: 44px; padding: 0; }
.text-link { white-space: nowrap; flex: none; font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 32px; }
.text-link:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid #8cc9bf; outline-offset: 2px; }

.field { display: grid; gap: 6px; }
.field label, .chips legend { font-size: 14px; font-weight: 650; color: var(--ink-deep); }
.optional { font-weight: 500; color: var(--muted); font-size: 13px; }
.field-hint { font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); font-size: 16px;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid #a9d6ce; outline-offset: 0; border-color: var(--teal); }
input[type=date], input[type=time] { appearance: none; -webkit-appearance: none; display: block; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-error:empty { display: none; }
.form-error, .action-status:not(:empty) {
  display: grid; gap: 8px; justify-items: start; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger-tint); color: #7d2323; font-size: 14px;
}
.form-error .muted, .action-status .muted { color: #6b3b3b; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--teal); }
.check label { font-weight: 600; }

.chips { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { margin-bottom: 8px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 14px; font-weight: 600; color: var(--ink-soft); background: #fff; }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid #8cc9bf; outline-offset: 2px; }

/* ---------- Badges ---------- */

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap; background: #eaf1ef; color: var(--ink-soft); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.today { background: var(--teal); color: #fff; }
.badge.muted-badge { background: #eceff0; color: #66767a; }
.st-open { background: #e2f3ef; color: #0d5d58; box-shadow: inset 0 0 0 1px #b6ddd5; }
.st-accepted { background: #e4ecf7; color: #1d4a80; }
.st-done { background: #e6f2e2; color: #2c6324; }
.st-unfulfilled { background: var(--warn-tint); color: var(--warn); }
.st-cancelled { background: #eceff0; color: #5f6d70; }
.st-declined { background: #f9e7ea; color: #92304a; }
.vs-open { background: #e2f3ef; color: #0d5d58; }
.vs-cancelled { background: #eceff0; color: #5f6d70; }
.vs-completed { background: #e6f2e2; color: #2c6324; }
.src-visit { background: #efe9f8; color: #553a87; }

/* ---------- Login ---------- */

body.signed-out { background: var(--ink-deep); }
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 460px); gap: 64px; align-items: center; max-width: 1180px; margin: 0 auto; padding: 48px 48px calc(48px + var(--safe-b)); }
.login-intro { color: #d7e7e4; display: grid; gap: 28px; }
.login-intro h1 { color: #fff; font-size: 40px; line-height: 1.25; letter-spacing: -.03em; }
.login-points { list-style: none; display: grid; gap: 12px; font-size: 16px; }
.login-points li { padding-left: 22px; position: relative; }
.login-points li::before { content: ""; position: absolute; left: 0; top: .6em; width: 10px; height: 2px; background: var(--mint); }
.login-card { padding: 32px; display: grid; gap: 14px; }
.login-card h2 { font-size: 22px; }
.login-form { margin-top: 8px; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-deep); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand.light { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 17px; font-weight: 800; box-shadow: inset 0 -3px 0 var(--mint); }
.brand.light .brand-mark { background: #fff; color: var(--ink); }
.brand-text small, .brand small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; opacity: .7; }

/* ---------- Shell ---------- */

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: calc(12px + var(--safe-t)); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px;
  background: var(--ink-deep); color: #cfe0dd; overflow-y: auto;
}
.sidebar .brand { padding: 4px 10px 8px; }
.side-nav { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; font-weight: 650; }
.nav-link.side { min-height: 46px; padding: 0 12px; border-radius: var(--radius-sm); font-size: 15px; color: #c9dbd8; }
.nav-link.side:hover { background: rgb(255 255 255 / .07); color: #fff; }
.nav-link.side[aria-current="page"] { background: rgb(82 183 168 / .18); color: #fff; box-shadow: inset 3px 0 0 var(--mint); }
.side-foot { margin-top: auto; display: grid; gap: 6px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: #87a5a2; padding: 0 12px; }
.side-account { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 12px 6px 0 12px; border-top: 1px solid rgb(255 255 255 / .1); }
.side-account-text { display: grid; min-width: 0; flex: 1; }
.side-account-text strong { color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-account-text small { color: #9fb9b6; font-size: 12px; }
.icon-button.on-dark { background: transparent; border-color: rgb(255 255 255 / .16); color: #d6e6e3; }
.icon-button.on-dark:hover { background: rgb(255 255 255 / .08); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 750; font-size: 15px; }
.avatar.small { width: 30px; height: 30px; font-size: 13px; }

.frame { margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.tabbar { display: none; }
.frame > #main { display: block; max-width: 1480px; margin: 0 auto; padding: 28px 32px 48px; min-height: 70vh; }

.notice:empty { display: none; }
.notice { max-width: 1480px; margin: 16px auto 0; padding: 0 32px; }
.notice-inner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warn-tint); border: 1px solid #ecd7a6; color: #5f420e; font-size: 14px; }
.notice-actions { display: flex; gap: 6px; }

.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast-item { background: var(--ink-deep); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / .22); animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.boot { min-height: 60vh; display: grid; place-items: center; padding: 24px; }

/* ---------- Page structure ---------- */

.page { display: grid; gap: 20px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-desc { margin-top: 6px; color: var(--muted); font-size: 15px; }
.page-actions { display: flex; gap: 8px; }

.split { display: grid; grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.list-pane {
  position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 14px; align-content: start; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.detail-pane { display: grid; gap: 16px; min-width: 0; align-content: start; }
.back-link { display: none; align-items: center; gap: 4px; min-height: 44px; font-weight: 650; text-decoration: none; color: var(--ink-soft); width: fit-content; padding-right: 8px; }
.back-link .icon { width: 22px; height: 22px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; }
.section-actions { display: flex; gap: 6px; }

/* ---------- Filters ---------- */

.filters { display: grid; gap: 10px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: #edf2f1; border-radius: 12px; }
.segmented a { display: grid; place-items: center; min-height: 40px; padding: 4px 6px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--ink-soft); text-decoration: none; text-align: center; }
.segmented a[aria-current="page"] { background: #fff; color: var(--ink-deep); box-shadow: 0 1px 3px rgb(13 44 53 / .14); }
.filter-desc { font-size: 13px; color: var(--muted); }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-select { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.inline-select select { width: auto; min-height: 40px; padding: 6px 10px; font-size: 14px; }
.filter-chip { display: inline-flex; align-items: center; gap: 2px; padding-left: 12px; border-radius: 999px; background: var(--teal-tint); color: var(--teal-strong); font-size: 14px; font-weight: 650; max-width: 100%; }
.filter-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { display: grid; place-items: center; width: 40px; height: 40px; color: inherit; border-radius: 50%; }
.chip-remove .icon { width: 16px; height: 16px; }

/* ---------- Rows ---------- */

.rows, .result-list, .compact-rows { list-style: none; display: grid; gap: 6px; }
.row {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); text-decoration: none;
  white-space: normal; font-weight: 400; min-height: 44px;
}
.row:hover { border-color: var(--line-strong); background: var(--surface-2); }
.row[aria-current="true"] { border-color: var(--teal); background: #f1f9f7; box-shadow: inset 3px 0 0 var(--teal); }
.row-main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.row-title { font-weight: 700; color: var(--ink-deep); font-size: 15px; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-summary { font-size: 14px; color: var(--text); }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.due.overdue { color: var(--danger); font-weight: 650; }
.row.compact { padding: 10px 12px; }
.visit-row { align-items: center; }
.date-chip { display: grid; place-items: center; flex: none; width: 50px; height: 54px; border-radius: 10px; background: #eef4f3; color: var(--ink); line-height: 1.1; }
.date-chip small { font-size: 11px; font-weight: 650; color: var(--muted); }
.date-chip strong { font-size: 20px; font-weight: 800; }
.date-chip.today { background: var(--teal); color: #fff; }
.date-chip.today small { color: #d6f0eb; }
.more-wrap { display: grid; gap: 8px; }
.more-wrap:empty { display: none; }
.more { width: 100%; }

/* ---------- States ---------- */

.state { display: grid; justify-items: center; gap: 6px; padding: 28px 18px; text-align: center; border-radius: 12px; color: var(--muted); font-size: 14px; }
.state strong { color: var(--ink-deep); font-size: 15px; }
.state.empty { border: 1px dashed var(--line-strong); background: var(--surface-2); }
.state.empty .button, .state.empty button { margin-top: 6px; }
.state.error { background: var(--danger-tint); color: #7d2323; }
.state.error strong { color: #7d2323; }
.state.loading { grid-auto-flow: column; justify-content: center; align-items: center; gap: 10px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .toast-item { animation: none; } }

/* ---------- Search ---------- */

.hospital-search { display: grid; gap: 10px; }
.search-form { display: flex; gap: 8px; position: relative; }
.search-form input { padding-left: 40px; }
.search-icon { position: absolute; left: 12px; top: 13px; color: var(--muted); pointer-events: none; }
.search-form button { flex: none; }
.search-status { font-size: 13px; color: var(--muted); min-height: 20px; }

/* ---------- Detail ---------- */

.detail-head { display: grid; gap: 10px; }
.tag-line { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-title { font-size: 24px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.facts { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 14px; font-size: 14.5px; margin-top: 4px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { overflow-wrap: anywhere; }
.summary-block { padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; font-size: 16px; }
.when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 17px; color: var(--ink-deep); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.mini-list .state { padding: 16px 12px; }
.actions-wrap { display: grid; gap: 10px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.action-bar:empty { display: none; }
.action-hint { font-size: 14px; }
.action-status:empty { display: none; }
.actions-wrap.compact, .action-bar.compact { margin: 0; }
.ask-list { list-style: none; display: grid; gap: 10px; }
.ask { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.ask-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ask .actions-wrap { padding-top: 10px; }
.note-quote { padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--ink-soft); }
.privacy-note { margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: #f1eef8; color: #4a3a73; font-size: 14px; }

.override-list { display: grid; }
.override-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.override-row:first-child { border-top: 0; }
.override-row dt { font-weight: 650; font-size: 14px; color: var(--ink-deep); padding-top: 2px; }
.override-value { display: grid; gap: 4px; min-width: 0; }
.override-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-edit .form-actions { justify-content: flex-start; }
.card > .hint { margin-bottom: 10px; }

.note-form { padding-bottom: 18px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.note-form .form-actions { justify-content: flex-start; }
.note-list { list-style: none; }
.note { display: grid; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; }
.note-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-actions { display: flex; gap: 4px; }

.data-block { display: grid; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.data-block:first-of-type { border-top: 0; }
.plain { list-style: none; display: grid; gap: 4px; font-size: 14.5px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.stat dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat dd { font-size: 13px; color: var(--muted); }
.stat dd strong { font-size: 20px; color: var(--teal-strong); font-variant-numeric: tabular-nums; }
.source { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: #f2f6f5; width: fit-content; max-width: 100%; }
.source dt { font-weight: 650; color: var(--ink-soft); }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 650; color: var(--ink-soft); font-size: 14px; }
details[open] > summary { margin-bottom: 6px; }
.hours { border-collapse: collapse; font-size: 14px; }
.hours th, .hours td { text-align: left; padding: 6px 16px 6px 0; border-bottom: 1px solid var(--line); }
.hours th { color: var(--muted); font-weight: 600; width: 64px; }

.timeline { list-style: none; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; display: grid; gap: 2px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line-strong); }
.timeline li:last-child::after { display: none; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.tl-head time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- Home ---------- */

.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.home-head h1 { margin-top: 4px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-btn { min-height: 48px; padding: 10px 18px; }
.home-work { display: grid; gap: 16px; }
.home-primary, .home-secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-primary { align-items: stretch; }
.home-secondary { align-items: start; }
.panel { display: grid; align-content: start; padding: 18px; }
.panel .section-head { align-items: flex-start; }
.panel .section-head h2 { font-size: 16px; }
.panel.priority { border-top: 3px solid var(--teal); }
.panel.priority .section-head h2 { font-size: 18px; }
.panel.secondary { box-shadow: none; background: var(--surface-2); }
.panel.secondary .section-head h2 { font-size: 15px; color: var(--ink-soft); }
.home-work .panel .state { padding: 18px 12px; }

.announcements { display: grid; gap: 4px; padding: 18px; border-left: 4px solid var(--teal); }
.announcements .section-head { align-items: flex-start; margin-bottom: 8px; }
.announcements .section-head h2 { font-size: 18px; }
.announcements .state { padding: 18px 12px; }
.announcement-list { list-style: none; display: grid; gap: 8px; }
.announcement-item { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.announcement-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.announcement-meta strong { color: var(--ink-deep); font-size: 14px; }
.announcement-meta time { font-variant-numeric: tabular-nums; }
.announcement-delete { margin-left: auto; }
.announcement-text { font-size: 15px; line-height: 1.65; color: var(--text); }
.announcement-quote { max-height: 40vh; overflow: auto; padding: 10px 12px; border-left: 3px solid var(--line-strong); background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.announcements .more { margin-top: 6px; }

/* ---------- Traffic ---------- */

.traffic-card { display: grid; gap: 14px; justify-items: start; padding: 28px; }
.traffic-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--teal-tint); color: var(--teal); }
.traffic-icon .icon { width: 28px; height: 28px; }
.url-line { overflow-wrap: anywhere; }

/* ---------- Admin ---------- */

.admin-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.issue-form { position: sticky; top: 20px; }
.member-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.member-table th, .member-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.member-table thead th { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.member-table tbody th { font-weight: 700; color: var(--ink-deep); }
.member-table tbody th .badge { margin-left: 6px; }
.member-table tr.inactive td, .member-table tr.inactive th { color: var(--muted); }
.cell-action { text-align: right; }

/* ---------- Dialogs ---------- */

dialog.sheet {
  width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 860px); padding: 0; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgb(8 30 36 / .3); overflow: hidden;
}
dialog.sheet.wide { width: min(680px, calc(100vw - 32px)); }
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(8 30 36 / .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 10px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 18px; }
.dialog-head .icon-button { border-color: transparent; }
.dialog-desc { padding: 12px 22px 0; color: var(--muted); font-size: 14px; }
.dialog-body > .dialog-desc { padding: 0; }
.dialog-body { padding: 18px 22px 22px; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 16px; align-content: start; }
.dialog-body .result-list { max-height: none; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--teal-tint); }
.picked > div { display: grid; min-width: 0; }
.picked strong { color: var(--ink-deep); }
.picked-label { font-size: 12px; font-weight: 700; color: var(--teal-strong); }
.form-actions.sticky { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px 22px; background: linear-gradient(to bottom, rgb(255 255 255 / .9), #fff 30%); }
.account-summary { display: flex; gap: 12px; align-items: center; }
.account-summary > div { display: grid; }
.menu-item { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; background: #fff; }
.menu-item.danger { color: var(--danger); }

/* ---------- Wide desktop ---------- */

@media (min-width: 1440px) {
  .split { grid-template-columns: 420px minmax(0, 1fr); gap: 28px; }
  .frame > #main { padding: 32px 40px 56px; }
}

/* ---------- Narrower desktop: single column detail cards ---------- */

@media (max-width: 1279px) {
  .two-col { grid-template-columns: 1fr; gap: 18px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Tablet (rail) & mobile: focused single pane ---------- */

@media (max-width: 1099px) {
  .sidebar { width: var(--rail); padding: 14px 8px; gap: 14px; align-items: stretch; }
  .sidebar .brand { justify-content: center; padding: 4px 0 6px; }
  .sidebar .brand-text, .side-label, .side-account-text, .side-account { display: none; }
  .nav-link.side { flex-direction: column; justify-content: center; gap: 4px; min-height: 62px; padding: 6px 4px; font-size: 12px; text-align: center; }
  .nav-link.side[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--mint); }
  .nav-link.side .icon { width: 22px; height: 22px; }
  .admin-link.side { display: none; }
  .frame { margin-left: var(--rail); }

  .topbar {
    display: flex; position: sticky; top: 0; z-index: 15; height: calc(var(--topbar) + var(--safe-t)); padding: var(--safe-t) 20px 0;
    align-items: center; justify-content: space-between; gap: 12px; background: rgb(243 246 245 / .94);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { visibility: hidden; }
  .topbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .top-admin { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-soft); font-weight: 650; font-size: 14px; }
  .top-admin[aria-current="page"] { background: var(--teal-tint); color: var(--teal-strong); }
  .account-button { min-height: 44px; padding: 4px 12px 4px 6px; border-radius: 999px; gap: 8px; max-width: 220px; }
  .top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

  .frame > #main { padding: 22px 24px 40px; }
  .notice { padding: 0 24px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split[data-mode="list"] .detail-pane, .split[data-mode="detail"] .list-pane { display: none; }
  .page[data-mode="detail"] > .page-head { display: none; }
  .list-pane { position: static; max-height: none; overflow: visible; padding: 0; background: transparent; border: 0; }
  .back-link { display: inline-flex; }
  .admin-grid { grid-template-columns: 1fr; }
  .issue-form { position: static; }
  .detail-pane, .list-pane { max-width: 760px; width: 100%; margin: 0 auto; }
}

/* ---------- Mobile ---------- */

@media (max-width: 759px) {
  :root { font-size: 16px; }
  h1 { font-size: 23px; }
  .sidebar { display: none; }
  .frame { margin-left: 0; }
  .topbar { padding: var(--safe-t) 12px 0 16px; height: calc(56px + var(--safe-t)); }
  .topbar .brand { visibility: visible; font-size: 17px; }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: 15px; border-radius: 9px; }
  .top-admin span { display: none; }
  .top-admin { width: 44px; justify-content: center; padding: 0; }
  .account-button { max-width: 150px; padding-right: 10px; }

  .frame > #main { padding: 16px 16px calc(var(--tabbar) + var(--safe-b) + 28px); }
  .notice { padding: 0 16px; margin-top: 12px; }
  .page { gap: 16px; }
  .page-head { align-items: center; flex-wrap: nowrap; }
  .page-desc { display: none; }
  .page-actions .primary { padding: 9px 12px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + var(--safe-b)); padding: 0 4px var(--safe-b);
    background: rgb(255 255 255 / .97); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgb(13 44 53 / .05);
  }
  .nav-link.tab { flex-direction: column; justify-content: center; gap: 3px; min-height: 44px; color: #637a7f; font-size: 11.5px; font-weight: 650; letter-spacing: -.02em; }
  .nav-link.tab .icon { width: 23px; height: 23px; }
  .nav-link.tab[aria-current="page"] { color: var(--teal); }
  .nav-link.tab[aria-current="page"] .icon { stroke-width: 2.2; }
  body.typing .tabbar { display: none; }
  body.typing .frame > #main { padding-bottom: 24px; }

  .card { padding: 18px 16px; border-radius: 14px; }
  .detail-title { font-size: 21px; }
  .facts { grid-template-columns: 76px minmax(0, 1fr); }
  .head-actions > button { flex: 1 1 140px; }
  .action-bar > button { flex: 1 1 auto; }
  .row { padding: 12px; }
  .row-tags { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .override-row { grid-template-columns: 1fr; gap: 6px; }
  .field-row { grid-template-columns: 1fr; }
  .segmented a { font-size: 13.5px; }

  .home-head { display: grid; gap: 14px; }
  .home-head h1 { font-size: 21px; }
  .quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .quick-btn { flex-direction: column; gap: 6px; min-height: 76px; padding: 10px 6px; font-size: 13.5px; white-space: normal; text-align: center; line-height: 1.25; }
  .quick-btn .icon { width: 24px; height: 24px; }
  .home-work, .home-primary, .home-secondary { grid-template-columns: 1fr; gap: 12px; }
  .panel, .announcements { padding: 16px 14px; }
  .announcement-item { padding: 12px; }

  .toast { bottom: calc(var(--tabbar) + var(--safe-b) + 12px); }

  /* Dialogs become bottom sheets that respect the keyboard and safe areas. */
  dialog.sheet, dialog.sheet.wide {
    width: 100vw; max-width: 100vw; max-height: calc(100dvh - 24px - var(--safe-t)); margin: auto 0 0; border-radius: 18px 18px 0 0;
  }
  dialog.sheet.wide { height: calc(100dvh - 24px - var(--safe-t)); }
  .dialog-head { padding: 10px 8px 8px 18px; }
  .dialog-body { padding: 16px 16px calc(18px + var(--safe-b)); }
  .form-actions.sticky { bottom: calc(-18px - var(--safe-b)); margin: 0 -16px calc(-18px - var(--safe-b)); padding: 12px 16px calc(14px + var(--safe-b)); }
  .form-actions.sticky > * { flex: 1; }
  .dialog-desc { padding: 10px 18px 0; }

  /* Member table → stacked cards */
  .member-table thead { display: none; }
  .member-table, .member-table tbody, .member-table tr, .member-table th, .member-table td { display: block; }
  .member-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .member-table th, .member-table td { border: 0; padding: 0; }
  .member-table td[data-label]:not(.cell-action)::before { content: attr(data-label) " · "; color: var(--muted); font-size: 12.5px; }
  .member-table tbody th { grid-column: 1; }
  .member-table td { grid-column: 1; font-size: 13.5px; }
  .member-table .cell-action { grid-column: 2; grid-row: 1 / span 5; align-self: center; }

  .login-page { grid-template-columns: 1fr; gap: 28px; padding: calc(28px + var(--safe-t)) 18px calc(28px + var(--safe-b)); align-content: start; }
  .login-intro { gap: 18px; }
  .login-intro h1 { font-size: 28px; }
  .login-points { font-size: 15px; gap: 8px; }
  .login-card { padding: 22px 18px; }
}

@media (max-width: 374px) {
  .frame > #main { padding-left: 12px; padding-right: 12px; }
  .nav-link.tab { font-size: 11px; }
  .quick-btn { font-size: 12.5px; }
  .account-button .top-name { display: none; }
  .account-button { padding: 4px; }
  .row-meta { font-size: 12px; }
  .segmented a { font-size: 12.5px; padding: 4px 2px; }
}
