:root {
  color-scheme: light;
  --ink: #17242c;
  --muted: #66747c;
  --paper: #f5f6f3;
  --surface: #ffffff;
  --line: #dfe4df;
  --green: #1f604e;
  --green-deep: #17483c;
  --green-soft: #e9f2ee;
  --blue: #215b88;
  --amber: #9b6517;
  --red: #a33a39;
  --shadow: 0 14px 40px rgba(29, 46, 41, .08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
body { background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 650 clamp(1.7rem, 3vw, 2.35rem)/1.12 Georgia, serif; letter-spacing: -.02em; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
h3 { margin-bottom: .35rem; font-size: 1rem; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .3rem; color: var(--green); font-size: .72rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 25px 18px; background: #163b32; color: white; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 9px 25px; }
.brand span { display: block; color: #b9d1c8; font-size: .77rem; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #e9f2ee; color: var(--green-deep); font-weight: 800; letter-spacing: -.04em; }
nav { display: grid; gap: 4px; }
.nav-item { border: 0; border-radius: 10px; padding: 10px 12px; background: transparent; color: #cbe0d8; text-align: left; cursor: pointer; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: white; }
.sidebar-logout { margin-top: auto; color: white !important; border-color: rgba(255,255,255,.25) !important; }
.main { min-width: 0; padding: 0 36px 56px; }
.disclaimer { margin: 0 -36px 30px; padding: 9px 36px; background: #eef0ea; border-bottom: 1px solid var(--line); color: #5c655f; font-size: .78rem; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.header-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(.98); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { background: var(--green); border-color: var(--green); color: white; }
.button.secondary { background: var(--surface); }
.button.subtle { background: transparent; }
.button.danger { color: var(--red); border-color: #e9cac9; }
.button.small { min-height: 34px; padding: 6px 10px; font-size: .8rem; }
.button.full { width: 100%; }
.danger-text { color: var(--red) !important; }

.searchbar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px 160px; gap: 10px; margin-bottom: 26px; }
input, select, textarea { width: 100%; border: 1px solid #ccd4cf; border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,96,78,.12); }
textarea { min-height: 110px; resize: vertical; }
label { display: grid; gap: 6px; color: #46534d; font-weight: 650; font-size: .85rem; }
.content { display: grid; gap: 22px; }
.command-center { border-color: #cddbd3; background: linear-gradient(180deg, #ffffff, #f8fbf8); }
.command-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.command-head h2 { margin: 0; font: 650 clamp(1.25rem, 2.5vw, 1.75rem)/1.15 Georgia, serif; letter-spacing: -.01em; }
.command-summary { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.2fr); gap: 12px; margin-bottom: 14px; }
.critical-progress, .travel-progress { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfa; }
.critical-progress > div:first-child, .travel-progress > div:first-child { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.critical-progress span:not(.progress-bar span), .travel-progress strong { color: var(--muted); font-size: .85rem; }
.critical-progress strong { font: 750 1.35rem/1 Georgia, serif; color: var(--ink); }
.progress-bar { display: block; height: 10px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: #e2e9e4; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.travel-progress { display: grid; gap: 10px; }
.stage-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stage-pills span { min-width: 0; padding: 9px; border-radius: 10px; background: var(--green-soft); color: var(--green-deep); font-size: .74rem; font-weight: 750; text-align: center; }
.stage-pills b { display: block; font: 750 1.25rem/1 Georgia, serif; }
.next-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.filter-panel .panel-head { margin-bottom: 10px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tab, .chip-button { min-height: 42px; border: 1px solid #cbd8d1; border-radius: 999px; padding: 8px 12px; background: var(--surface); color: var(--green-deep); font-weight: 800; cursor: pointer; }
.filter-tab.active, .filter-tab:hover, .chip-button:hover { border-color: var(--green); background: var(--green-soft); }
.filter-tab span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 5px; border-radius: 999px; background: #eff4f1; font-size: .72rem; }
.chip-button:disabled { border-color: var(--green); background: var(--green); color: white; cursor: default; opacity: 1; }
.quick-buttons { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.plan-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.task-lane { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.task-lane.today { border-top: 4px solid var(--green); }
.task-lane.week { border-top: 4px solid var(--blue); }
.task-lane.waiting { border-top: 4px solid var(--amber); }
.task-lane.later { border-top: 4px solid #789086; }
.lane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.lane-head h3 { margin: 0; }
.lane-head span { min-width: 28px; min-height: 28px; border-radius: 999px; display: grid; place-items: center; background: var(--green-soft); color: var(--green-deep); font-size: .75rem; font-weight: 800; }
.canonical-drawer { padding: 0; overflow: hidden; }
.canonical-drawer > summary { min-height: 56px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; cursor: pointer; }
.canonical-drawer > summary::-webkit-details-marker, .inline-details > summary::-webkit-details-marker { display: none; }
.canonical-drawer h2 { margin: 0; }
.canonical-drawer > summary strong { min-width: 34px; min-height: 34px; border-radius: 999px; display: grid; place-items: center; background: var(--green-soft); color: var(--green-deep); }
.canonical-cards { padding: 0 20px 20px; }
.inline-details > summary { min-height: 48px; padding: 10px 0; color: var(--green); font-weight: 800; cursor: pointer; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric, .panel, .record-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { padding: 20px; }
.metric strong { display: block; margin-top: 4px; font: 650 1.9rem/1 Georgia, serif; }
.metric span { color: var(--muted); font-size: .8rem; }
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.cards { display: grid; gap: 11px; }
.record-card { padding: 16px; box-shadow: none; }
.record-card p:last-child { margin-bottom: 0; }
.record-card > .muted { overflow-wrap: anywhere; }
.record-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.meta { display: flex; gap: 8px 14px; flex-wrap: wrap; margin: 7px 0 0; color: var(--muted); font-size: .82rem; }
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-deep); font-size: .72rem; font-weight: 750; text-transform: capitalize; }
.tag.amber { background: #fbf0db; color: var(--amber); }
.tag.red { background: #f9e5e4; color: var(--red); }
.tag.blue { background: #e5eff7; color: var(--blue); }
.empty { padding: 34px 20px; border: 1px dashed #cbd2cd; border-radius: var(--radius); text-align: center; color: var(--muted); }
.stack-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.stack-list li { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.stack-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.detail { white-space: pre-wrap; overflow-wrap: anywhere; }
.quick-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.quick-action { min-height: 54px; border: 1px solid #cbd8d1; border-radius: 13px; padding: 10px 12px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--surface); color: var(--green-deep); font-weight: 750; cursor: pointer; box-shadow: 0 6px 22px rgba(29, 46, 41, .05); }
.quick-action span { font-size: 1.2rem; line-height: 1; }
.quick-action:hover { border-color: var(--green); background: var(--green-soft); }
.todo-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.todo-bucket, .stage-column { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfa; padding: 13px; }
.todo-bucket.danger { border-top: 4px solid var(--red); }
.todo-bucket.today { border-top: 4px solid var(--green); }
.todo-bucket.waiting { border-top: 4px solid var(--amber); }
.todo-bucket.complete { border-top: 4px solid #789086; }
.todo-bucket-head, .stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.todo-bucket-head { margin: 0; cursor: pointer; list-style: none; }
.todo-bucket-head::-webkit-details-marker { display: none; }
.todo-bucket[open] .todo-bucket-head { margin-bottom: 10px; }
.todo-bucket-head h3, .stage-head h3 { margin: 0; }
.todo-bucket-head > span, .stage-head > span { min-width: 27px; min-height: 27px; border-radius: 999px; display: grid; place-items: center; background: var(--green-soft); color: var(--green-deep); font-size: .75rem; font-weight: 800; }
.todo-items { display: grid; gap: 8px; }
.todo-item { min-width: 0; padding: 11px; display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; border-radius: 10px; background: white; border: 1px solid var(--line); }
.todo-item > div { min-width: 0; }
.todo-item strong { display: block; overflow-wrap: anywhere; }
.todo-item p { margin: 6px 0 0; color: var(--muted); font-size: .82rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.todo-item p span, .status-story p > span { display: block; margin-bottom: 2px; color: var(--green); font-size: .69rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.bucket-empty { margin: 0; padding: 15px 8px; color: var(--muted); text-align: center; font-size: .85rem; }
.bucket-more { width: 100%; min-height: 40px; margin-top: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--green); font-weight: 750; cursor: pointer; }
.bucket-more:hover { background: var(--green-soft); }
.quick-select { min-width: 112px; gap: 3px; font-size: .69rem; text-transform: uppercase; letter-spacing: .06em; }
.quick-select select { min-height: 42px; padding: 7px 27px 7px 9px; font-size: .78rem; font-weight: 750; text-transform: capitalize; }
.status-story { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(130px, .8fr) minmax(180px, 1.25fr) minmax(180px, 1.25fr); gap: 9px; margin: 13px 0; }
.status-story.single { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.status-story.task-story { grid-template-columns: minmax(130px, .9fr) minmax(90px, .65fr) minmax(100px, .65fr) minmax(150px, 1fr); }
.status-story p { min-width: 0; margin: 0; padding: 10px; border-radius: 9px; background: #f6f8f5; overflow-wrap: anywhere; }
.status-story p strong { text-transform: capitalize; }
.compact-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 9px 0 0; }
.compact-facts div { min-width: 0; padding: 7px 8px; border-radius: 9px; background: #f6f8f5; }
.compact-facts dt { margin: 0 0 2px; color: var(--green); font-size: .65rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.compact-facts dd { margin: 0; font-size: .82rem; font-weight: 700; overflow-wrap: anywhere; }
.task-card.compact { padding: 13px; }
.task-card.compact h3 { font-size: .95rem; }
.task-card.compact .status-story { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 10px 0; }
.task-card.compact .status-story p { padding: 8px; font-size: .84rem; }
.task-card.compact .tag { min-height: 22px; }
.application-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.stage-column { padding: 14px; }
.application-card .record-top { flex-direction: column; }
.application-card .record-actions { width: 100%; justify-content: flex-start; }
.application-card .status-story { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.notice { margin-bottom: 18px; padding: 11px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green-deep); font-weight: 650; }

dialog { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 28px); border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 31, 27, .55); }
#recordForm { padding: 22px; overflow-y: auto; max-height: calc(100vh - 28px); }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head { margin-bottom: 18px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.icon-button { border: 0; background: transparent; font-size: 2rem; line-height: 1; color: var(--muted); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { min-height: 23px; margin: 4px 0 8px; color: var(--red); font-size: .85rem; }
.upload-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
.upload-form .button { justify-self: start; }

.login-page { min-height: 100vh; background: linear-gradient(145deg, #eef3ee, #f8f6f0); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card form { margin-top: 25px; }
.system-note { margin: 22px 0 0; color: var(--muted); font-size: .73rem; text-align: center; }
.mobile-nav, .mobile-panel { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 13px 18px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; overflow: visible; }
  .brand { padding: 0; flex: 0 0 auto; }
  .brand span { display: none; }
  .sidebar nav { order: 3; width: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-item { white-space: nowrap; }
  .sidebar-logout { margin: 0 0 0 auto; white-space: nowrap; }
  .main { padding: 0 24px 44px; }
  .disclaimer { margin: 0 -24px 25px; padding-left: 24px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .command-summary, .next-actions, .plan-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-story, .status-story.single { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  html, body { height: 100%; }
  .app-shell { min-height: 0; height: calc(100vh - 76px - env(safe-area-inset-bottom)); overflow: hidden; }
  .sidebar { display: none; }
  .brand { width: calc(100% - 86px); }
  .brand strong { display: block; }
  .brand span { display: block; }
  .brand-mark { width: 38px; height: 38px; }
  .sidebar nav { overflow: visible; padding-bottom: 2px; }
  .sidebar-logout { min-height: 38px; padding: 6px 10px; }
  .main { height: 100%; overflow-y: auto; padding: 0 14px 24px; }
  .disclaimer { margin: 0 -14px 21px; padding: 8px 14px; }
  .topbar { align-items: flex-start; margin-bottom: 14px; }
  .header-actions .secondary { display: none; }
  .header-actions .primary { min-height: 48px; }
  .searchbar { grid-template-columns: minmax(0, 1fr) 1fr; }
  .search-field { grid-column: 1 / -1; }
  .metrics, .grid-two { grid-template-columns: 1fr; }
  .command-head { align-items: stretch; flex-direction: column; }
  .command-head .button { width: 100%; }
  .command-summary, .next-actions, .plan-board { grid-template-columns: 1fr; }
  .stage-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-tab, .chip-button { min-height: 48px; border-radius: 12px; }
  .metric { padding: 16px; }
  .panel { padding: 15px; }
  .canonical-drawer { padding: 0; }
  .canonical-drawer > summary { min-height: 56px; padding: 15px; }
  .canonical-cards { padding: 0 15px 15px; }
  .record-top { align-items: stretch; flex-direction: column; }
  .record-actions { justify-content: flex-start; }
  .button, .button.small, .nav-item, input, select, .todo-bucket-head, .bucket-more { min-height: 48px; }
  .button.small { min-width: 48px; }
  .icon-button { min-width: 48px; min-height: 48px; padding: 0; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick-action { min-height: 52px; padding: 8px; }
  .quick-action:last-child { grid-column: 1 / -1; }
  .todo-board, .application-board { grid-template-columns: 1fr; }
  .todo-item { align-items: stretch; flex-direction: column; }
  .todo-item .quick-select { width: 100%; }
  .quick-select select { min-height: 48px; }
  .status-story, .status-story.single, .status-story.task-story { grid-template-columns: 1fr; }
  .compact-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .upload-form { grid-template-columns: 1fr; }
  .login-card { padding: 26px 21px; }
  .dialog-actions { position: sticky; bottom: -22px; z-index: 2; margin: 18px -22px -22px; padding: 13px 22px max(13px, env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--line); }
  .dialog-actions .button { flex: 1; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.98); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(23,36,44,.12); }
  .mobile-nav-item { min-width: 0; min-height: 52px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: .75rem; font-weight: 850; cursor: pointer; }
  .mobile-nav-item.active, .mobile-nav-item:hover { background: var(--green-soft); color: var(--green-deep); }
  .mobile-nav-item.add { background: var(--green); color: white; }
  .mobile-panel { position: fixed; left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 49; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 18px 60px rgba(23,36,44,.22); }
  .mobile-panel:not([hidden]) { display: grid; }
  .mobile-panel-item { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfa; color: var(--ink); font-weight: 800; cursor: pointer; }
  .mobile-panel-item:hover { border-color: var(--green); background: var(--green-soft); }
}
