:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f3;
  color: #17211e;
  font-synthesis: none;
  --ink: #17211e;
  --muted: #62706b;
  --line: #dce3df;
  --surface: #ffffff;
  --soft: #e9f0ed;
  --brand: #1f6b57;
  --brand-dark: #17352d;
  --accent: #d9a441;
  --danger: #a64444;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #15201d;
  color: #edf4ef;
  --ink: #edf4ef;
  --muted: #aabbb2;
  --line: #344840;
  --surface: #1d2b26;
  --soft: #2a4138;
  --brand: #65b999;
  --brand-dark: #173d32;
  --accent: #e2b85d;
  --danger: #ee8c8c;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #f4f6f3; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #17352d; }
.login-panel { width: min(100%, 420px); padding: 40px; border-radius: 8px; background: #fff; box-shadow: 0 22px 70px rgba(0,0,0,.22); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 800; }
.brand-mark.small { width: 36px; height: 36px; font-size: 11px; }
.eyebrow, .section-label { margin: 22px 0 6px; color: var(--brand); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; }
h2 { margin: 0; font-size: 22px; }
.login-copy { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }
.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: #35433e; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd5d0; border-radius: 6px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,107,87,.14); }
.form-error { min-height: 18px; margin: -4px 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template: 64px 1fr / 220px 1fr; }
.topbar { position: sticky; z-index: 20; top: 0; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.sync-state { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #3c9a67; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--soft); color: var(--ink); }
.icon-button svg, .button svg, .nav-list svg, .bottom-nav svg { width: 18px; height: 18px; stroke-width: 1.8; }

.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); padding: 24px 14px; border-right: 1px solid var(--line); background: #fff; }
.nav-list { display: grid; gap: 4px; }
.nav-list a { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 6px; color: #52605b; text-decoration: none; font-size: 14px; font-weight: 650; }
.nav-list a:hover { background: #f2f5f3; color: var(--ink); }
.nav-list a.active { background: var(--soft); color: var(--brand-dark); }

.content { min-width: 0; padding: 40px clamp(24px, 4vw, 64px) 64px; }
.page { display: none; width: min(100%, 1160px); margin: 0 auto; }
.page.active { display: block; }
.page-heading, .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading .eyebrow { margin-top: 0; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 1px solid transparent; border-radius: 6px; font-weight: 750; cursor: pointer; }
.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover { background: #185846; }
.button.secondary { border-color: #bdcbc5; background: #fff; color: var(--ink); }
.button.quiet { border-color: var(--line); background: #fff; color: #41504b; }
.button.full { width: 100%; }
.button.large { min-height: 50px; padding: 0 22px; }
.button:disabled { opacity: .48; cursor: not-allowed; }

.today-layout { margin-top: 28px; }
.focus-panel { min-height: 300px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(28px, 5vw, 58px); border-radius: 8px 8px 0 0; background: var(--brand-dark); color: #fff; }
.focus-panel .section-label { margin: 0; color: #a9c8bc; }
.hero-time { margin-top: 8px; font-size: clamp(64px, 10vw, 108px); font-weight: 750; line-height: .95; font-variant-numeric: tabular-nums; }
.recommendation-note { max-width: 620px; margin: 18px 0 26px; color: #c9d9d3; line-height: 1.5; }
.work-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; background: #fff; }
.summary-strip article { min-width: 0; padding: 20px 24px; border-right: 1px solid var(--line); }
.summary-strip article:last-child { border-right: 0; }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { color: var(--muted); font-size: 12px; }
.summary-strip strong { margin-top: 5px; font-size: 20px; font-variant-numeric: tabular-nums; }
.section-block { margin-top: 46px; }
.section-heading { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.section-heading .section-label { margin: 0 0 4px; }
.section-heading a { color: var(--brand); font-size: 13px; font-weight: 750; text-decoration: none; }
.week-row { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.week-day { min-height: 122px; padding: 18px 14px; border-right: 1px solid var(--line); }
.week-day:last-child { border-right: 0; }
.week-day span, .week-day strong, .week-day small { display: block; }
.week-day span { color: var(--muted); font-size: 12px; }
.week-day strong { margin-top: 16px; font-size: 20px; }
.week-day small { margin-top: 4px; color: var(--muted); }
.empty-state { padding: 15vh 0; text-align: center; color: var(--muted); }
.empty-state > svg { width: 34px; height: 34px; }
.empty-state h1 { margin-top: 16px; color: var(--ink); font-size: 30px; }
.empty-state p { margin-top: 8px; }
.bottom-nav { display: none; }

.split-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 48px; margin-top: 34px; }
.form-section, .data-section { min-width: 0; }
.section-heading.compact { align-items: center; padding-bottom: 12px; }
.section-heading.compact h2 { font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px 14px; padding-top: 22px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 3px; }
.check-label { min-height: 44px; display: flex; flex-direction: row; align-items: center; gap: 10px; padding-top: 20px; }
.check-label input { width: 19px; min-height: 19px; margin: 0; accent-color: var(--brand); }
.record-list { border-bottom: 1px solid var(--line); }
.record-row { min-height: 69px; display: grid; grid-template-columns: minmax(120px, 1fr) minmax(100px, 1fr) auto; align-items: center; gap: 18px; padding: 13px 2px; border-top: 1px solid var(--line); }
.record-row:first-child { border-top: 0; }
.record-row strong, .record-row span, .record-row small { display: block; }
.record-row span, .record-row small { color: var(--muted); font-size: 12px; }
.record-row .record-value { text-align: right; font-variant-numeric: tabular-nums; }
.record-empty { padding: 26px 2px; color: var(--muted); }
.secondary-sections { margin-top: 50px; padding-top: 36px; border-top: 1px solid var(--line); }
.section-block.first { margin-top: 28px; }
.plan-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 12px; border-bottom: 1px solid var(--line); }
.plan-toolbar strong { min-width: 230px; text-align: center; font-size: 14px; }
.plan-table-wrap { width: 100%; overflow-x: auto; }
.plan-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.plan-table th { padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; white-space: nowrap; }
.plan-table td { padding: 13px 12px; border-bottom: 1px solid #e8edea; vertical-align: top; }
.plan-table td:first-child, .plan-table td:nth-child(3), .plan-table td:nth-child(4), .plan-table td:nth-child(5) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; background: #edf2ef; color: #42514b; font-size: 11px; font-weight: 750; }
.status-pill.work { background: #e3f0eb; color: #175a46; }
.status-pill.holiday { background: #dcebf7; color: #245b7a; }
.status-pill.time_off, .status-pill.vacation { background: #f5ecd8; color: #765817; }
.status-pill.sick { background: #f4e6e6; color: #8a3535; }
.plan-table tr.holiday-row td { background: #f1f7fc; border-bottom-color: #d9e7f1; }
.isolation-badge { min-height: 34px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; border-radius: 999px; background: #e3f0eb; color: #175a46; font-size: 12px; font-weight: 750; }
.isolation-badge svg { width: 16px; height: 16px; }
.simulation-layout { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: clamp(32px, 5vw, 70px); margin-top: 34px; }
.scenario-facts { margin-top: 40px; }
.saved-scenarios { margin-top: 40px; }
.saved-scenario-list { border-top: 1px solid var(--line); }
.saved-scenario { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.saved-scenario strong, .saved-scenario small { display: block; }
.saved-scenario small, .empty-note { margin-top: 3px; color: var(--muted); font-size: 12px; }
.saved-scenario-actions, .result-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fact-list { margin-top: 15px; }
.fact-chip { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
.fact-chip button { width: 32px; height: 32px; }
.result-placeholder { min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #c6d2cd; border-radius: 8px; color: var(--muted); text-align: center; }
.result-placeholder > svg { width: 40px; height: 40px; color: var(--brand); }
.result-placeholder h2 { margin-top: 16px; color: var(--ink); }
.result-placeholder p { max-width: 360px; margin: 8px 20px; line-height: 1.5; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; }
.metric { min-height: 104px; padding: 20px; border-right: 1px solid var(--line); }
.metric:nth-child(3n) { border-right: 0; }
.metric:nth-child(n+4) { border-top: 1px solid var(--line); }
.metric span, .metric strong, .metric small { display: block; }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { margin-top: 6px; font-size: 23px; font-variant-numeric: tabular-nums; }
.metric small { margin-top: 4px; color: var(--muted); }
.comparison { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--accent); background: #fbf7ec; color: #635327; font-size: 13px; line-height: 1.5; }
.result-plan-heading { margin-top: 38px; }
.conflict-list { margin-top: 20px; }
.conflict-item { padding: 13px 0; border-bottom: 1px solid var(--line); color: #6b3434; font-size: 13px; }
.account-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.account-summary article { min-height: 120px; padding: 24px; border-right: 1px solid var(--line); }
.account-summary article:last-child { border-right: 0; }
.account-summary span, .account-summary strong, .account-summary small { display: block; }
.account-summary span { color: var(--muted); font-size: 12px; }
.account-summary strong { margin-top: 8px; font-size: 28px; font-variant-numeric: tabular-nums; }
.account-summary small { margin-top: 5px; color: var(--muted); }
.toast { position: fixed; z-index: 60; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 32px)); padding: 13px 17px; border-radius: 6px; background: #17211e; color: #fff; font-size: 13px; box-shadow: 0 12px 32px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #7d3333; }

:root[data-theme="dark"] html,
:root[data-theme="dark"] body { background: #15201d; }
:root[data-theme="dark"] .login-shell { background: #102a23; }
:root[data-theme="dark"] .login-panel,
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .summary-strip,
:root[data-theme="dark"] .plan-table,
:root[data-theme="dark"] .account-summary,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .button.quiet { background: var(--surface); }
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .bottom-nav { background: rgba(29, 43, 38, .97); }
:root[data-theme="dark"] label { color: #cfddd5; }
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { border-color: #4a6157; }
:root[data-theme="dark"] .button.secondary { border-color: #587167; }
:root[data-theme="dark"] .button.quiet { color: #d2ded8; }
:root[data-theme="dark"] .nav-list a { color: #bdccc4; }
:root[data-theme="dark"] .nav-list a:hover { background: #273b34; }
:root[data-theme="dark"] .nav-list a.active { color: #a9e1cb; }
:root[data-theme="dark"] .plan-table td { border-bottom-color: #30443c; }
:root[data-theme="dark"] .status-pill { background: #30433a; color: #d8e5de; }
:root[data-theme="dark"] .status-pill.work,
:root[data-theme="dark"] .isolation-badge { background: #24483b; color: #a9e1cb; }
:root[data-theme="dark"] .status-pill.holiday { background: #25485b; color: #b8ddf1; }
:root[data-theme="dark"] .plan-table tr.holiday-row td { background: #1d3541; border-bottom-color: #315263; }
:root[data-theme="dark"] .status-pill.time_off,
:root[data-theme="dark"] .status-pill.vacation { background: #55451f; color: #f5d991; }
:root[data-theme="dark"] .status-pill.sick { background: #553333; color: #ffb7b7; }
:root[data-theme="dark"] .comparison { background: #3f351d; color: #f0d898; }
:root[data-theme="dark"] .result-placeholder { border-color: #4b6358; }
:root[data-theme="dark"] .bottom-nav a { color: #aabbb2; }
:root[data-theme="dark"] .bottom-nav a.active { color: #8cd3b6; }

@media (max-width: 760px) {
  body { background: #fff; }
  .login-shell { padding: 0; background: #fff; }
  .login-panel { min-height: 100vh; padding: max(56px, env(safe-area-inset-top)) 24px 32px; border-radius: 0; box-shadow: none; }
  .app-shell { display: block; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .topbar { height: 58px; padding: 0 16px; }
  .brand small, .sync-state, .sidebar { display: none; }
  .content { padding: 24px 16px 36px; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 28px; }
  .page-heading .button { width: 42px; padding: 0; font-size: 0; }
  .today-layout { margin: 20px -16px 0; }
  .focus-panel { min-height: 288px; padding: 30px 20px; border-radius: 0; }
  .hero-time { font-size: clamp(66px, 23vw, 90px); }
  .work-actions { width: 100%; }
  .work-actions .button { flex: 1 1 150px; }
  .summary-strip { grid-template-columns: 1fr 1fr; border-right: 0; border-left: 0; border-radius: 0; }
  .summary-strip article { padding: 17px 20px; }
  .summary-strip article:nth-child(2) { border-right: 0; }
  .summary-strip article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .summary-strip strong { font-size: 18px; }
  .section-block { margin-top: 38px; }
  .week-row { grid-template-columns: repeat(5, minmax(88px, 1fr)); overflow-x: auto; }
  .week-day { min-height: 108px; padding: 14px 10px; }
  .bottom-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); min-height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }
  .bottom-nav a { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #68756f; text-decoration: none; font-size: 10px; font-weight: 700; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav svg { width: 20px; height: 20px; }
  .split-layout, .simulation-layout { grid-template-columns: 1fr; gap: 44px; margin-top: 26px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .record-row { grid-template-columns: minmax(100px, 1fr) minmax(90px, 1fr) auto; gap: 10px; }
  .plan-table { min-width: 690px; }
  .plan-toolbar strong { min-width: 190px; }
  .secondary-sections { margin-top: 38px; padding-top: 30px; }
  .isolation-badge { max-width: 138px; min-height: 40px; line-height: 1.2; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3n) { border-right: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .account-summary { grid-template-columns: 1fr; }
  .account-summary article { min-height: 94px; border-right: 0; border-bottom: 1px solid var(--line); }
  .account-summary article:last-child { border-bottom: 0; }
  .toast { right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) {
  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .login-shell { background: #15201d; }
}

@media (max-width: 430px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-actions .button { flex: 1 1 100%; }
  .record-row { grid-template-columns: 1fr auto; }
  .record-row > :nth-child(2) { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric, .metric:nth-child(2n), .metric:nth-child(3n) { border-right: 0; border-top: 1px solid var(--line); }
  .metric:first-child { border-top: 0; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
