:root {
  color-scheme: light;
  --ink: #17231d;
  --ink-soft: #536057;
  --paper: #f4f1ea;
  --surface: #fffdf8;
  --line: #d8d3c8;
  --acid: #c9f24b;
  --acid-dark: #7aa314;
  --rust: #bc583a;
  --yellow: #f2c94c;
  --blue: #6d96a8;
  --radius: 18px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, button, input, select, textarea, dialog { font-family: var(--font-sans); }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--acid-dark); }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; background: var(--ink); color: white; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }
.eyebrow { margin: 0 0 .6rem; font-size: .72rem; font-weight: 850; letter-spacing: .16em; color: var(--ink-soft); }
.eyebrow.light { color: #d4e1d8; }
.button { border: 0; border-radius: 999px; padding: .78rem 1.15rem; font-weight: 800; cursor: pointer; }
.button.primary { background: var(--acid); color: var(--ink); box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.button.ink { background: var(--ink); color: white; }
.button.secondary { background: #e7e2d8; color: var(--ink); }
.button:hover { transform: translateY(-1px); }
.icon-button { border: 0; background: transparent; width: 2.3rem; height: 2.3rem; border-radius: 50%; cursor: pointer; font-size: 1.25rem; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; }
.login-story { background: var(--ink); color: white; padding: clamp(2rem, 7vw, 7rem); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.brand-logo { display: block; object-fit: contain; }
.login-logo { position: absolute; top: 2rem; left: 2rem; width: clamp(10rem, 22vw, 16rem); height: auto; }
.login-story h1 { font-size: clamp(3rem, 6vw, 6.6rem); font-weight: 780; line-height: .92; margin: 0; max-width: 12ch; letter-spacing: -.055em; }
.login-copy { max-width: 35rem; color: #bac8bf; font-size: 1.15rem; line-height: 1.6; margin-top: 2rem; }
.login-orbit { position: absolute; width: 34rem; height: 34rem; border: 1px solid #476054; border-radius: 50%; right: -14rem; bottom: -16rem; }
.login-orbit::before, .login-orbit::after { content: ""; position: absolute; inset: 4rem; border: 1px solid #476054; border-radius: 50%; }
.login-orbit::after { inset: 9rem; background: var(--acid); border: 0; opacity: .9; }
.login-card { background: var(--surface); padding: clamp(2rem, 6vw, 6rem); display: flex; justify-content: center; flex-direction: column; }
.login-card h2 { font-size: clamp(2.2rem, 4vw, 3.8rem); font-weight: 760; margin: 0; letter-spacing: -.04em; }
.login-card > p:not(.eyebrow) { color: var(--ink-soft); max-width: 29rem; line-height: 1.6; }
.form-stack { display: grid; gap: .65rem; margin: 1.6rem 0 1rem; max-width: 29rem; }
label { font-size: .82rem; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: .85rem .95rem; background: white; color: var(--ink); }
textarea { resize: vertical; }
.form-stack .button { margin-top: .7rem; }
.form-status { min-height: 1.4rem; color: var(--rust); font-weight: 700; }
.text-link { color: var(--ink); font-weight: 750; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.35rem 1rem; background: var(--ink); color: white; display: flex; flex-direction: column; }
.wordmark { color: white; text-decoration: none; display: block; padding: .15rem .55rem 1.4rem; }
.sidebar-logo { width: 100%; max-width: 11rem; height: auto; }
.nav-label { color: #7f9086; font-size: .64rem; letter-spacing: .16em; font-weight: 850; margin: 1.2rem .7rem .45rem; }
.nav-item { width: 100%; border: 0; background: transparent; color: #c9d3cd; text-align: left; padding: .66rem .75rem; border-radius: 10px; cursor: pointer; display: flex; gap: .7rem; align-items: center; margin-bottom: .16rem; font-size: .88rem; }
.nav-item span { color: #87998e; width: 1rem; }
.nav-item:hover, .nav-item.active { background: #29372f; color: white; }
.nav-item.active span { color: var(--acid); }
.sidebar-user { margin-top: auto; border-top: 1px solid #34443a; padding: 1rem .35rem 0; display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; }
.avatar { width: 2.35rem; height: 2.35rem; border-radius: 50%; display: grid; place-items: center; background: #426152; color: white; font-weight: 850; }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user strong { font-size: .83rem; }
.sidebar-user small { font-size: .68rem; color: #91a197; margin-top: .15rem; }
.sidebar-user .icon-button { color: #aab9b0; }

.workspace { min-width: 0; }
.topbar { min-height: 72px; border-bottom: 1px solid var(--line); background: rgba(244,241,234,.94); backdrop-filter: blur(12px); display: flex; align-items: center; gap: 1rem; padding: .85rem clamp(1rem, 3vw, 2.4rem); position: sticky; top: 0; z-index: 20; }
.search-box { display: flex; align-items: center; gap: .55rem; max-width: 34rem; flex: 1; background: #eae6dd; border-radius: 999px; padding: 0 .9rem; }
.search-box input { border: 0; background: transparent; padding: .65rem 0; }
.top-actions { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.sync-state { color: var(--ink-soft); font-size: .75rem; }
.sync-state::before { content: ""; display: inline-block; width: .5rem; height: .5rem; background: var(--acid-dark); border-radius: 50%; margin-right: .4rem; }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 1.3rem; }
.content { padding: clamp(1.3rem, 3vw, 2.5rem); }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; }
.page-heading h1 { font-size: clamp(2.1rem, 4vw, 4.4rem); font-weight: 760; letter-spacing: -.055em; margin: 0; }
.page-heading p:last-child { color: var(--ink-soft); margin-bottom: 0; }
.view-switch { border: 1px solid var(--line); border-radius: 999px; padding: .25rem; background: #ece8df; display: flex; }
.view-switch button { border: 0; background: transparent; padding: .58rem .85rem; border-radius: 999px; color: var(--ink-soft); }
.view-switch button.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(23,35,29,.08); }
.filter-row { display: flex; gap: .5rem; align-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 2rem 0 1.4rem; padding: .8rem 0; }
.filter { border: 0; border-radius: 999px; background: transparent; padding: .55rem .78rem; color: var(--ink-soft); cursor: pointer; }
.filter.active { background: var(--ink); color: white; }
.filter span { background: rgba(255,255,255,.2); border-radius: 999px; padding: .08rem .38rem; margin-left: .3rem; }
.filter-spacer { flex: 1; }
.compact-select, .calendar-month { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: var(--ink-soft); font-weight: 750; }
.compact-select select, .calendar-month input { width: auto; min-width: 6rem; border-radius: 999px; padding: .5rem .7rem; background: var(--surface); font-size: .76rem; }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(250px, 1fr)); gap: 1rem; align-items: start; overflow-x: auto; padding-bottom: 1rem; }
.column { min-height: 480px; border-top: 3px solid var(--line); }
.column[data-status="in_progress"] { border-color: var(--yellow); }
.column[data-status="review"] { border-color: var(--blue); }
.column[data-status="done"] { border-color: var(--acid-dark); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem .2rem; }
.column-head h2 { font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; margin: 0; }
.column-count { color: var(--ink-soft); font-size: .76rem; }
.column-list { display: grid; gap: .7rem; }
.task-card { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 1rem; cursor: pointer; box-shadow: 0 3px 0 rgba(23,35,29,.035); text-align: left; width: 100%; color: var(--ink); }
.task-card:hover { border-color: #a9a398; transform: translateY(-1px); }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.task-number { font-size: .7rem; font-weight: 850; color: var(--ink-soft); letter-spacing: .08em; }
.priority { font-size: .68rem; font-weight: 900; border-radius: 999px; padding: .2rem .45rem; background: #e8e4db; }
.priority.P0 { background: #f3c5b7; color: #7d2e1d; }
.priority.P1 { background: #f4dfa0; color: #654c00; }
.task-card h3 { font-size: 1.05rem; line-height: 1.25; margin: 0 0 .55rem; font-weight: 720; }
.task-result { font-size: .79rem; color: var(--ink-soft); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; padding-top: .75rem; border-top: 1px solid #e7e2d8; font-size: .69rem; color: var(--ink-soft); }
.mini-avatar { width: 1.6rem; height: 1.6rem; background: var(--ink); color: white; display: grid; place-items: center; border-radius: 50%; font-weight: 800; }
.empty-state { border: 1px dashed #bdb6a9; border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--ink-soft); }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.task-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.task-table th, .task-table td { border-bottom: 1px solid var(--line); padding: .85rem 1rem; text-align: left; vertical-align: top; font-size: .8rem; }
.task-table th { position: sticky; top: 0; background: #ece8df; color: var(--ink-soft); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.task-table tr:last-child td { border-bottom: 0; }
.task-table td:first-child { min-width: 19rem; }
.task-table td:first-child strong, .task-table td:first-child small { display: block; }
.task-table td:first-child strong { margin: .25rem 0; font-size: .9rem; }
.task-table td:first-child small { max-width: 34rem; color: var(--ink-soft); }
.task-link { border: 0; background: transparent; padding: 0; color: var(--acid-dark); font-size: .7rem; font-weight: 900; cursor: pointer; }
.status-pill { display: inline-block; border-radius: 999px; background: #e7e2d8; padding: .3rem .55rem; white-space: nowrap; }
.calendar-view { min-width: 0; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); }
.calendar-weekdays { color: var(--ink-soft); font-size: .7rem; font-weight: 850; text-align: center; text-transform: uppercase; letter-spacing: .08em; }
.calendar-weekdays span { padding: .5rem; }
.calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.calendar-day { min-height: 132px; padding: .55rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-day > strong { display: block; font-size: .72rem; color: var(--ink-soft); margin-bottom: .45rem; }
.calendar-day.muted { background: #efebe3; }
.calendar-task { display: block; width: 100%; border: 0; border-left: 3px solid var(--acid-dark); border-radius: 6px; background: #ece8df; color: var(--ink); text-align: left; padding: .42rem; margin-bottom: .35rem; font-size: .7rem; cursor: pointer; }
.calendar-task .priority { margin-right: .3rem; padding: .1rem .25rem; }

.task-dialog { border: 0; padding: 0; border-radius: 22px; width: min(680px, calc(100vw - 2rem)); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(14,24,18,.3); }
.task-dialog::backdrop { background: rgba(12,22,16,.55); backdrop-filter: blur(4px); }
.dialog-head { padding: 1.5rem 1.6rem 1rem; display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 2rem; font-weight: 760; margin: 0; }
.task-form, .task-detail { padding: 1.4rem 1.6rem 1.6rem; display: grid; gap: .75rem; }
.form-grid { display: grid; grid-template-columns: 1.2fr .6fr 1fr; gap: .7rem; }
.form-grid > div { display: grid; gap: .45rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: .5rem; }
.detail-dialog { width: min(760px, calc(100vw - 2rem)); }
.template-dialog { width: min(980px, calc(100vw - 2rem)); }
.template-layout { padding: 1.3rem 1.6rem 1.6rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.template-layout h3 { margin: 0 0 .8rem; }
.template-list { display: grid; gap: .7rem; max-height: 60vh; overflow: auto; }
.template-item { border: 1px solid var(--line); border-radius: 14px; padding: .9rem; background: white; }
.template-item h4 { margin: 0 0 .35rem; }
.template-item p { margin: .25rem 0; color: var(--ink-soft); font-size: .8rem; }
.template-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .7rem; }
.template-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .45rem .7rem; cursor: pointer; }
.compact-form { padding: 0; }
.compact-form label { display: grid; gap: .35rem; }
.recurrence-grid { display: grid; gap: .6rem; margin-top: .7rem; }
.reports-layout { padding: 1.3rem 1.6rem 1.6rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.reports-layout h3 { margin: 0 0 .7rem; }
.report-wide { grid-column: 1 / -1; }
.report-panel { border: 1px solid var(--line); background: white; border-radius: 14px; padding: 1rem; min-height: 7rem; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: .6rem; }
.metric { background: #ece8df; border-radius: 12px; padding: .75rem; }
.metric strong { display: block; font-size: 1.5rem; }
.metric small { color: var(--ink-soft); }
.digest-list { padding-left: 1.1rem; margin-bottom: 0; }
.digest-list li { margin: .35rem 0; }
.report-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.report-heading > div { display: flex; gap: .5rem; }
.report-heading input { width: auto; }
.workload-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.workload-table th, .workload-table td { padding: .55rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .8rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.detail-box { background: #ece8df; border-radius: 12px; padding: .9rem; }
.detail-box small { display: block; color: var(--ink-soft); margin-bottom: .35rem; }
.attachment-list { display: grid; gap: .45rem; margin-bottom: .7rem; }
.attachment-list button { display: flex; width: 100%; justify-content: space-between; gap: .8rem; border: 1px solid var(--line); border-radius: 9px; padding: .55rem; color: var(--ink); text-align: left; cursor: pointer; background: white; }
.attachment-list span { color: var(--ink-soft); font-size: .7rem; }
#attachment-form { display: flex; gap: .55rem; align-items: center; }
#attachment-form input { min-width: 0; }
#attachment-form button { white-space: nowrap; }
.transition-row { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .6rem; }
.transition-row button { border: 1px solid var(--line); background: white; border-radius: 999px; padding: .55rem .8rem; cursor: pointer; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--ink); color: white; padding: .85rem 1rem; border-radius: 12px; opacity: 0; transform: translateY(1rem); pointer-events: none; transition: .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { min-height: 35vh; padding: 5rem 1.5rem 2rem; }
  .login-story h1 { font-size: clamp(2.5rem, 12vw, 4.4rem); }
  .login-card { min-height: 65vh; padding: 2rem 1.5rem; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 260px; left: -280px; transition: left .2s; box-shadow: 20px 0 50px rgba(0,0,0,.24); }
  .sidebar.open { left: 0; }
  .mobile-menu { display: inline-grid; }
  .sync-state, .top-actions .button { display: none; }
  .page-heading { align-items: start; flex-direction: column; }
  .view-switch { align-self: stretch; }
  .view-switch button { flex: 1; }
  .kanban { grid-template-columns: repeat(5, minmax(82vw, 1fr)); }
  .kanban:has(.column:only-child) { grid-template-columns: 1fr; }
  .column { min-height: 320px; }
  .form-grid, .detail-grid, .template-layout, .reports-layout { grid-template-columns: 1fr; }
  .report-wide { grid-column: auto; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .report-heading { align-items: stretch; flex-direction: column; }
  .report-heading > div { flex-wrap: wrap; }
  .filter-row { align-items: stretch; flex-wrap: wrap; }
  .compact-select, .calendar-month { flex: 1 1 9rem; }
  .compact-select select, .calendar-month input { flex: 1; min-width: 0; }
  .filter-spacer { display: none; }
  .calendar-view { overflow-x: auto; }
  .calendar-weekdays, .calendar-grid { min-width: 780px; }
}

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