:root {
  --bg: #e7eef0;
  --surface: #ffffff;
  --ink: #14233a;
  --muted: #5d6e80;
  --line: #d5e0e6;
  --teal: #0c6b66;
  --teal-dark: #084e4a;
  --teal-soft: #e5f4f2;
  --red: #c0392f;
  --red-soft: #fdeceb;
  --red-ink: #8d241c;
  --orange: #c56a08;
  --orange-soft: #fff3e0;
  --orange-ink: #8a4b06;
  --blue: #1a5fad;
  --blue-soft: #e7f1fb;
  --blue-ink: #154884;
  --purple: #6d3cae;
  --purple-soft: #f3e9fb;
  --purple-ink: #532c86;
  --slate: #3d4d5c;
  --slate-soft: #eef2f5;
  --green: #1e7a4d;
  --green-soft: #e5f6ed;
  --green-ink: #14613c;
  --shadow: 0 10px 30px rgba(20, 35, 58, 0.08);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 280px at 50% -120px, #d7ebe8, transparent 70%),
    var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.65; cursor: wait; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 13px; margin-top: 6px; }

.login { min-height: 100vh; display: flex; flex-direction: column; }
.login-hero {
  color: white;
  padding: calc(36px + var(--safe-t)) 24px 48px;
  background:
    radial-gradient(circle at 85% 10%, rgba(255,255,255,.16), transparent 32%),
    linear-gradient(165deg, #0f7a74 0%, #084e4a 58%, #16324a 100%);
}
.login-hero h1 { font-size: 28px; line-height: 1.2; max-width: 16ch; margin-top: 16px; }
.login-hero p { margin-top: 8px; color: rgba(255,255,255,.86); max-width: 34ch; }
.login-card {
  margin: -28px 16px 24px;
  background: var(--surface);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--teal); color: white; font-weight: 800; letter-spacing: -0.04em;
}
.login-hero .brand-mark { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.16); font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; position: relative; }
.field span, .label { font-size: 14px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fbfefe;
  font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); background: white; outline: none; box-shadow: 0 0 0 3px rgba(12,107,102,.15); }
details { margin-top: 14px; color: var(--muted); font-size: 14px; }
details p { margin-top: 6px; }
summary { cursor: pointer; font-weight: 650; color: var(--teal-dark); }

.app {
  width: min(1040px, 100%);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.home-scroll { flex: 1; min-height: 0; overflow: auto; }
.header {
  flex: none;
  z-index: 20;
  padding: calc(8px + var(--safe-t)) 16px 10px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(213,224,230,.9);
}
.header-row, .hello-row, .meta-row, .split, .time-row, .time-add, .user-row, .brand {
  display: flex; align-items: center; gap: 10px;
}
.header-row { justify-content: space-between; }
.brand { gap: 10px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; line-height: 1.1; }
.brand-text small, .hello-row small { color: var(--muted); }
.header-actions { display: flex; gap: 8px; }
.icon-btn, .avatar-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 1.5px solid var(--line);
  background: white; display: grid; place-items: center; position: relative; padding: 0;
}
.avatar-btn { background: var(--teal); color: white; font-weight: 800; border-color: transparent; }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: white; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}
.subhead { padding: 8px 16px 0; }
.hello-row { justify-content: space-between; align-items: flex-start; }
.hello-row h1 { font-size: 20px; line-height: 1.15; }
.role-pill {
  flex: none; background: var(--teal-soft); color: var(--teal-dark);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 750;
}
.date-line { margin-top: 2px; color: var(--muted); font-size: 13px; }
.assignee-field { display: block; margin-top: 8px; }
.assignee-field span { display: block; font-weight: 750; font-size: 13px; margin-bottom: 4px; }
.assignee-field select { background: white; font-weight: 650; min-height: 44px; padding: 8px 12px; }
.page-head .btn { min-height: 40px; padding: 8px 12px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 16px 0; }
.stat {
  text-align: left; border: 0; border-radius: 14px; padding: 8px 10px; min-height: 64px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2px;
}
.stat-due { min-height: 64px; }
.stat-debt { background: #fff4e4; }
.stat-debt .stat-num, .stat-debt .stat-label { color: #8a4b06; }
.stat-num { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.stat-due .stat-num { font-size: 28px; }
.stat-label { font-size: 12.5px; font-weight: 700; line-height: 1.25; }
.stat-due { background: var(--red-soft); }
.stat-due .stat-num, .stat-due .stat-label { color: var(--red-ink); }
.stat-blocked { background: var(--slate-soft); }
.stat-blocked .stat-num { color: #5c2a2a; }
.stat-partial { background: var(--orange-soft); }
.stat-partial .stat-num, .stat-partial .stat-label { color: var(--orange-ink); }
.stat-delivery { background: var(--blue-soft); }
.stat-delivery .stat-num, .stat-delivery .stat-label { color: var(--blue-ink); }
.stat-paper { background: var(--purple-soft); }
.stat-paper .stat-num, .stat-paper .stat-label { color: var(--purple-ink); }
.stat.is-on.stat-due { background: var(--red); }
.stat.is-on.stat-blocked { background: #4a3030; }
.stat.is-on.stat-partial { background: var(--orange); }
.stat.is-on.stat-delivery { background: var(--blue); }
.stat.is-on.stat-paper { background: var(--purple); }
.stat.is-on.stat-debt { background: #b86a12; }
.stat.is-on .stat-num, .stat.is-on .stat-label { color: white; }

.controls { padding: 8px 16px 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tab {
  text-align: left; background: white; border: 1.5px solid var(--line); border-radius: 14px;
  min-height: 52px; padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; gap: 1px;
}
.tab-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.tab-kicker { font-weight: 800; font-size: 13.5px; line-height: 1.2; }
.tab small { color: var(--muted); font-size: 11px; line-height: 1.25; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-count { font-weight: 800; color: var(--teal-dark); }
.tab.is-on { background: var(--teal); border-color: var(--teal); color: white; }
.tab.is-on small, .tab.is-on .tab-count { color: rgba(255,255,255,.86); }
.search { margin-top: 6px; position: relative; }
.search input { padding-left: 42px; background: white; min-height: 42px; }
.search svg { position: absolute; left: 14px; top: 13px; }
.filter-note, .result-line { margin-top: 6px; font-size: 13px; }
.filter-note {
  background: #fff8e8; color: #7a4b08; border-radius: 12px; padding: 10px 12px; font-weight: 650;
}
.list { display: grid; gap: 10px; padding: 8px 16px 16px; }
.card {
  background: white; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  box-shadow: inset 5px 0 0 var(--teal), 0 10px 30px rgba(20, 35, 58, 0.06);
}
.card-red { box-shadow: inset 5px 0 0 var(--red), 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-slate { box-shadow: inset 5px 0 0 #6b3a3a, 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-orange { box-shadow: inset 5px 0 0 var(--orange), 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-blue { box-shadow: inset 5px 0 0 var(--blue), 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-purple { box-shadow: inset 5px 0 0 var(--purple), 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-green { box-shadow: inset 5px 0 0 var(--green), 0 10px 30px rgba(20, 35, 58, 0.06); }
.card-debt { box-shadow: inset 5px 0 0 #b86a12, 0 10px 30px rgba(20, 35, 58, 0.06); }
.hospital { font-size: 18px; line-height: 1.25; margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { font-size: 12px; font-weight: 750; border-radius: 999px; padding: 4px 8px; background: var(--slate-soft); }
.tag-blue { background: var(--blue-soft); color: var(--blue-ink); }
.tag-slate { background: #f3eeee; color: #6a3030; }
.tag-orange { background: var(--orange-soft); color: var(--orange-ink); }
.tag-green { background: var(--green-soft); color: var(--green-ink); }
.tag-purple { background: var(--purple-soft); color: var(--purple-ink); }
.tag-red, .tag-pin { background: var(--red-soft); color: var(--red-ink); }
.tag-debt { background: #fff4e4; color: #8a4b06; }
.line-group { margin-top: 8px; }
.line-title { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.line-extra { margin: 0 0 8px 32px; }
.items { margin: 0 0 8px 32px; }
.cat-panel { margin-top: 10px; }
.meta-row { justify-content: space-between; align-items: center; margin: 8px 0; gap: 8px; }
.due { font-weight: 850; font-size: 13px; letter-spacing: .01em; }
.due-late, .due-today { color: var(--red-ink); }
.due-soon { color: var(--blue-ink); }
.due-later, .due-none { color: var(--muted); }
.who { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.block-note, .note {
  background: #f6f8f9; border-radius: 12px; padding: 8px 10px; font-size: 14px; margin: 8px 0; color: #314255;
}
.note { font-style: italic; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 15px; }
.check input { width: 22px; height: 22px; min-height: 22px; margin-top: 1px; accent-color: var(--teal); }
.mini { margin: 8px 0; padding-left: 18px; color: #314255; }
.stack { display: grid; gap: 8px; margin-top: 10px; }
.btn {
  border: 0; border-radius: 14px; min-height: 48px; padding: 12px 14px; font-weight: 750;
}
.btn:active { transform: scale(.985); }
.btn-primary, .btn-go { background: var(--teal); color: white; }
.btn-go { width: 100%; min-height: 52px; font-size: 16.5px; }
.btn-ghost { background: white; color: var(--teal-dark); border: 1.5px solid var(--line); }
.btn-danger { background: var(--red-soft); color: var(--red-ink); }
.btn-block { width: 100%; }
.empty {
  background: white; border-radius: 18px; padding: 28px 16px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.fab-wrap {
  flex: none;
  z-index: 25;
  display: flex; justify-content: center;
  padding: 8px 16px calc(8px + var(--safe-b));
  background: rgba(231, 238, 240, .97);
  border-top: 1px solid rgba(213, 224, 230, .9);
  pointer-events: none;
}
.fab {
  pointer-events: auto; width: min(520px, 100%); min-height: 54px;
  border: 0; border-radius: 16px; background: #12324a; color: white; font-weight: 800; font-size: 16px;
  box-shadow: 0 10px 24px rgba(18, 50, 74, .28);
}
body.locked .fab-wrap { display: none; }

.layer { position: fixed; inset: 0; z-index: 40; background: rgba(20, 35, 58, .38); }
.page {
  position: absolute; inset: 0; background: var(--bg); overflow: auto;
  display: flex; flex-direction: column;
}
.page-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) 12px 10px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.page-head h2 { font-size: 18px; flex: 1; }
.page-body { padding: 16px 16px calc(20px + var(--safe-b)); }
.savebar { padding-top: 16px; }
.sheet-wrap { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: min(520px, 100%); background: white; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(16px + var(--safe-b)); box-shadow: var(--shadow);
}
.sheet h3 { font-size: 20px; }
.sheet p { margin: 8px 0 16px; color: #314255; }
.bell-wrap { position: absolute; inset: 0; }
.bell-panel {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(68px + var(--safe-t)); width: min(520px, calc(100% - 20px));
  max-height: min(74vh, 680px); overflow: auto; background: white; border-radius: 18px;
  box-shadow: var(--shadow); padding: 12px;
}
.mini-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mini-stat { font-size: 12px; font-weight: 750; border-radius: 999px; padding: 4px 8px; }
.digest-group { margin-top: 8px; }
.digest-group h3 { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 6px; }
.digest-item {
  width: 100%; text-align: left; background: #f7fafb; border: 0; border-radius: 12px;
  padding: 10px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px;
}
.digest-item span, .digest-item small { color: var(--muted); font-size: 13px; }
.dialog { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; }
.dialog-card {
  width: min(520px, 100%); max-height: min(86vh, 760px); overflow: hidden;
  display: flex; flex-direction: column;
  background: white; border-radius: 22px; padding: 16px; box-shadow: var(--shadow);
}
.dialog-card [data-body] { overflow: auto; min-height: 0; margin-top: 10px; }
.dialog-card > .stack { flex: none; }
.dialog-card h3 { font-size: 22px; }

.choice-grid { display: grid; gap: 8px; }
.choice, .chip, .switch {
  width: 100%; text-align: left; background: white; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px;
}
.choice { min-height: 64px; display: flex; flex-direction: column; gap: 2px; }
.choice small, .switch small { color: var(--muted); font-weight: 500; }
.choice.is-on, .chip.is-on, .switch.is-on { border-color: var(--teal); background: var(--teal-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { width: auto; min-height: 44px; border-radius: 999px; font-weight: 750; }
.switch { display: flex; gap: 12px; align-items: center; }
.switch-ui {
  width: 46px; height: 28px; border-radius: 999px; background: #d5dee4; position: relative; flex: none;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white;
  transition: transform .15s ease;
}
.switch.is-on .switch-ui { background: var(--teal); }
.switch.is-on .switch-ui::after { transform: translateX(18px); }
.switch:disabled { opacity: .55; }
.card.is-fresh { outline: 3px solid var(--teal); outline-offset: 2px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.row-actions .btn { min-height: 40px; }
.subchoices { display: grid; gap: 8px; margin-top: 8px; }
.item-edit {
  background: white; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 8px;
  display: grid; gap: 8px;
}
.item-edit .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% - 6px); background: white;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 5; overflow: hidden;
}
.suggest button { width: 100%; text-align: left; background: white; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
.settings-card, .panel {
  background: white; border-radius: 16px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.settings-card h3, .panel h3 { font-size: 16px; margin-bottom: 8px; }
.time-row, .user-row {
  justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.user-row { align-items: flex-start; }
.time-add { margin-top: 8px; }
.time-add input { flex: 1; }
.banner {
  background: var(--green-soft); color: var(--green-ink); border-radius: 12px; padding: 10px 12px; font-weight: 700; margin-bottom: 10px;
}
.banner.warn { background: var(--orange-soft); color: var(--orange-ink); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline small { color: var(--muted); }
.error-text { color: var(--red-ink); font-weight: 700; min-height: 1.2em; }

@media (min-width: 900px) {
  .hello-row h1 { font-size: 26px; }
  .date-line { font-size: 14px; }
  .assignee-field select { min-height: 48px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 10px; padding-top: 16px; }
  .stat { min-height: 108px; padding: 14px; }
  .stat-due { min-height: 120px; }
  .stat-num { font-size: 32px; }
  .stat-due .stat-num { font-size: 36px; }
  .stat-label { font-size: 13px; }
  .tabs { grid-template-columns: repeat(4, 1fr); }
  .tab { min-height: 88px; padding: 12px; }
  .tab-kicker { font-size: 15px; }
  .tab small { font-size: 12px; }
  .list { grid-template-columns: 1fr 1fr; align-items: start; }
  .page-body { width: min(760px, 100%); margin: 0 auto; }
  .sheet { border-radius: 22px; margin-bottom: 24px; }
  .login { display: grid; grid-template-columns: 1.1fr .9fr; }
  .login-hero { display: flex; flex-direction: column; justify-content: flex-end; min-height: 100vh; padding: 48px; }
  .login-card { align-self: center; margin: 32px; }
  .login-hero h1 { font-size: 42px; max-width: 14ch; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
