:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --canvas: #f6f7f3;
  --surface: #fff;
  --ink: #18271f;
  --muted: #607166;
  --line: #e1e8e0;
  --green: #215942;
  --accent: #286849;
  --mint: #e4efe5;
  --light: #eff4ed;
  --danger: #b43d37;
  --shadow: 0 18px 52px #223b2c10;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
button, input, textarea, select { outline-offset: 3px; }
:focus-visible { outline: 2px solid #438b69; }
button { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, label, input { -webkit-tap-highlight-color: transparent; }

.login { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 34px; padding: 28px 16px; background: radial-gradient(ellipse at 50% 21%, #e5efe2, transparent 56%), var(--canvas); }
.login-brand, .sidebar-brand { display: flex; gap: 11px; align-items: center; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--green); flex: none; }
.brand-mark svg { stroke-width: 2.6; }
.brand-name { font-size: 1.26rem; font-weight: 770; letter-spacing: -.07em; white-space: nowrap; }
.connect-card { width: min(100%, 430px); padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.connect-icon { display: grid; place-items: center; color: var(--green); width: 48px; height: 48px; border-radius: 15px; background: var(--mint); margin-bottom: 20px; }
.connect-card h1 { font-size: 1.6rem; letter-spacing: -.065em; margin-bottom: 9px; }
.connect-card p { line-height: 1.6; color: var(--muted); font-size: .92rem; word-break: keep-all; }
.connect-card form { display: grid; gap: 9px; margin-top: 25px; }
.connect-card .primary { justify-content: center; margin-top: 3px; }
.connect-card .form-message:empty { display: none; }
.connect-card .form-message { margin-top: 12px; color: var(--danger); }
.login footer { font-size: .82rem; color: var(--muted); }

.workspace { display: grid; min-height: 100dvh; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 24px 15px 16px; overflow-y: auto; }
.sidebar-brand { padding: 2px 13px 28px; }
.sidebar-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.sidebar nav { display: grid; gap: 4px; }
.nav-button { border: 0; border-radius: 9px; min-height: 42px; background: transparent; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 12px; color: #52645a; font-size: .91rem; }
.nav-button:hover { background: var(--light); color: var(--green); }
.nav-button.active { background: var(--mint); color: var(--green); font-weight: 730; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: .77rem; min-width: 19px; text-align: center; color: #617b69; font-variant-numeric: tabular-nums; }
.nav-button.nested { padding-left: 26px; }
.collection-heading { margin: 23px 10px 3px 12px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; font-size: .79rem; font-weight: 680; }
.collections-empty { padding: 6px 12px; font-size: .82rem; color: var(--muted); }
.sidebar-footer { display: grid; gap: 5px; margin-top: auto; padding: 18px 0 0; }
.footer-profile { display: flex; gap: 9px; align-items: center; border-top: 1px solid var(--line); padding: 13px 7px 0; font-size: .84rem; }
.footer-profile .icon-button:last-child { margin-left: auto; }
.profile-glyph { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--green); background: var(--light); }

.workspace-body { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 2; min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px clamp(18px, 4.1vw, 66px); border-bottom: 1px solid var(--line); background: #ffffffee; backdrop-filter: blur(12px); }
.search { color: var(--muted); display: flex; align-items: center; gap: 9px; width: min(100%, 333px); border: 1px solid #e8eee6; background: #f7f9f6; border-radius: 10px; padding: 8px 10px; }
.search input { color: var(--ink); min-width: 0; background: transparent; width: 100%; border: 0; padding: 0; outline: none; font-size: .9rem; }
.search:focus-within { border-color: #81ad91; }
.search kbd { font-family: inherit; display: grid; place-items: center; width: 22px; height: 23px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); font-size: .75rem; }
.topbar-actions { display: flex; gap: 12px; align-items: center; flex: none; }
.primary, .secondary, .sync-button, .text-button, .icon-button { display: inline-flex; gap: 7px; align-items: center; justify-content: center; border-radius: 9px; border: 0; background: transparent; padding: 9px 13px; white-space: nowrap; font-size: .88rem; font-weight: 650; }
.primary { color: #fff; background: var(--green); border: 1px solid var(--green); min-height: 42px; }
.primary:hover { background: #174633; }
.secondary { background: #fff; border: 1px solid var(--line); min-height: 39px; }
.secondary:hover, .icon-button:hover, .text-button:hover { background: var(--light); }
.sync-button { color: var(--muted); padding-inline: 8px; font-size: .83rem; }
.sync-button:hover { color: var(--green); background: var(--light); }
.icon-button { width: 34px; height: 34px; padding: 7px; color: var(--muted); }
.mobile-only { display: none; }

.stage { width: min(100%, 1470px); margin-inline: auto; padding: 43px clamp(18px, 4.1vw, 66px) 55px; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(235px, 282px); gap: 26px; align-items: start; }
.main-tasks { min-width: 0; }
.page-date { font-size: .9rem; font-weight: 650; color: var(--green); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: 7px; margin-bottom: 24px; }
.page-heading h1 { font-size: clamp(2.1rem, 4vw, 3.4rem); letter-spacing: -.09em; line-height: 1.11; margin-bottom: 7px; overflow-wrap: anywhere; }
.page-heading p { color: var(--muted); font-size: .95rem; }
.sort-control { position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); padding-left: 9px; }
.sort-control select { appearance: none; border: 0; background: transparent; padding: 8px 26px 8px 0; cursor: pointer; color: #45574a; font-size: .83rem; }
.sort-control .chevron { position: absolute; right: 6px; pointer-events: none; }

.task-section { margin-bottom: 20px; }
.section-heading { display: flex; align-items: center; gap: 7px; margin: 0 0 10px 2px; font-size: .93rem; color: #344d3c; }
.section-heading span { color: var(--muted); background: #e9efe7; border-radius: 6px; padding: 2px 6px; font-size: .76rem; font-weight: 600; }
.task-list { display: grid; border: 1px solid var(--line); background: #fff; border-radius: 15px; }
.task-row { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; align-items: start; gap: 11px; padding: 13px; min-height: 68px; }
.task-row + .task-row { border-top: 1px solid #eef0ec; }
.task-row:first-child { border-radius: 14px 14px 0 0; }
.task-row:last-child { border-radius: 0 0 14px 14px; }
.task-row:only-child { border-radius: 14px; }
.task-row:hover { background: #fbfdf9; }
.task-open { display: grid; text-align: left; min-width: 0; align-content: center; padding: 0; min-height: 40px; border: 0; background: transparent; gap: 7px; }
.task-title { font-size: .96rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.task-row.completed .task-title { color: var(--muted); text-decoration: line-through; }
.complete-check { width: 23px; height: 23px; border: 1.5px solid #aebfb1; border-radius: 50%; background: #fff; display: grid; place-items: center; color: #fff; padding: 0; margin-top: 3px; }
.complete-check:hover { border-color: #448564; background: #eef5ed; }
.completed .complete-check { background: #468464; border-color: #468464; }
.complete-check svg { width: 14px; height: 14px; stroke-width: 2.5; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; font-size: .79rem; color: var(--muted); }
.meta-item { display: inline-flex; align-items: center; gap: 4px; }
.meta-item svg { width: 14px; height: 14px; }
.meta-date.overdue { color: var(--danger); }
.priority { color: #a84925; }
.tag-pill { display: inline-flex; color: #3c674e; background: #edf4ed; padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere; }
.task-end { display: flex; align-items: center; margin-top: -1px; }
.task-end .pin-on { color: #487958; background: #eaf2e8; }
.inline-add { margin-top: 6px; }
.empty { border: 1px dashed #c5d7c8; border-radius: 16px; background: #f9fbf8; padding: 32px 24px; text-align: center; }
.empty-glyph { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 17px; margin: 0 auto 12px; color: var(--green); background: var(--mint); }
.empty h2 { font-size: 1.11rem; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: .9rem; line-height: 1.55; }
.empty .secondary, .empty .primary { margin-top: 18px; }

.rail { display: grid; gap: 13px; padding-top: 9px; min-width: 0; }
.rail-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.rail-header { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rail-header h2 { font-size: .91rem; }
.rail-controls { display: flex; gap: 3px; }
.rail-controls .icon-button { width: 26px; height: 26px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.calendar-day, .calendar-label { min-height: 30px; font-variant-numeric: tabular-nums; font-size: .80rem; padding: 2px; }
.calendar-label { color: var(--muted); line-height: 26px; }
.calendar-day { display: grid; place-items: center; position: relative; border: 0; background: transparent; border-radius: 7px; }
.calendar-day:hover { background: var(--light); }
.calendar-day.other { color: #74847a; }
.calendar-day.today { color: var(--green); background: var(--mint); font-weight: 760; }
.calendar-day.selected { color: #fff; background: var(--green); }
.calendar-day.due::after { content: ""; position: absolute; bottom: 3px; width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.deadline-list { display: grid; }
.deadline-link { min-width: 0; display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 9px; align-items: center; padding: 9px 0; border: 0; border-top: 1px solid #eef0ec; background: none; text-align: left; }
.deadline-link:hover .deadline-name { color: var(--green); text-decoration: underline; }
.deadline-link svg { color: var(--green); background: var(--light); padding: 6px; width: 30px; height: 30px; border-radius: 8px; }
.deadline-name { display: block; font-size: .84rem; overflow-wrap: anywhere; }
.deadline-date { display: block; color: var(--muted); font-size: .76rem; margin-top: 3px; }
.rail-empty { color: var(--muted); font-size: .86rem; line-height: 1.5; }

dialog { border: 1px solid var(--line); color: var(--ink); background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 0; max-width: calc(100vw - 24px); }
dialog::backdrop { background: #162e2360; }
.task-dialog { width: 590px; max-height: min(90dvh, 880px); }
.small-dialog { width: 410px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 23px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 1; }
.dialog-header h2 { font-size: 1.12rem; line-height: 1.25; }
.task-form { display: grid; gap: 16px; padding: 20px 23px; }
.task-form label, .connect-card label, .small-form label { display: grid; gap: 5px; font-size: .85rem; font-weight: 650; color: #395143; }
.task-form input:not([type=checkbox]):not([type=file]), .task-form select, .task-form textarea, .connect-card input, .small-form input { min-width: 0; width: 100%; border: 1px solid #cddbd1; border-radius: 8px; background: #fff; color: var(--ink); padding: 9px 10px; font-size: .91rem; }
.task-form textarea { resize: vertical; min-height: 86px; }
.task-form select { appearance: none; padding-right: 30px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2357685e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; }
.task-form .check-label { display: flex; align-items: center; gap: 7px; }
input[type=checkbox] { accent-color: var(--green); inline-size: 16px; block-size: 16px; flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.form-grid.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-stack { display: grid; gap: 9px; }
.form-section { border-top: 1px solid var(--line); padding-top: 13px; }
.form-section summary { cursor: pointer; color: var(--green); font-size: .89rem; font-weight: 700; }
.form-section[open] summary { margin-bottom: 10px; }
.form-section .text-button { justify-self: start; color: var(--green); }
.inline-checks { display: flex; flex-wrap: wrap; gap: 7px 10px; }
.form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; }
.form-footer .danger { margin-right: auto; }
.danger { color: var(--danger); }
.form-message { color: var(--danger); font-size: .87rem; line-height: 1.5; white-space: pre-line; }
.form-message:empty { display: none; }
.task-form .file-item, .task-form .step-item { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 8px; align-items: center; }
.task-form .file-item button { justify-content: flex-start; text-overflow: ellipsis; overflow: hidden; display: block; max-width: 100%; }
.small-form { padding: 18px 23px 23px; display: grid; gap: 12px; }
.small-form p { font-size: .92rem; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: min(400px, calc(100% - 40px)); padding: 11px 15px; border-radius: 10px; color: #fff; background: #173c2b; box-shadow: var(--shadow); font-size: .91rem; line-height: 1.5; }

@media (max-width: 1060px) {
  .workspace { grid-template-columns: 205px minmax(0,1fr); }
  .stage, .topbar { padding-inline: 26px; }
  .dashboard { gap: 17px; grid-template-columns: minmax(0,1fr) 220px; }
  .rail-card { padding: 12px; }
}
@media (max-width: 860px) {
  .dashboard { grid-template-columns: minmax(0,1fr); }
  .rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 0; align-items: start; }
}
@media (max-width: 640px) {
  .workspace { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 4; width: min(82vw, 260px); transform: translateX(-100%); visibility: hidden; }
  .sidebar.visible { transform: translateX(0); visibility: visible; }
  .mobile-overlay { position: fixed; inset: 0; background: #13291e66; z-index: 3; }
  .mobile-only { display: inline-flex; flex: none; }
  .topbar { min-height: 59px; gap: 6px; padding: 8px 10px; }
  .topbar-actions { gap: 3px; }
  .topbar .primary { padding-inline: 8px; min-height: 38px; font-size: .78rem; gap: 3px; }
  .search { gap: 4px; padding-inline: 6px; flex: 1; }
  .search input { font-size: .85rem; }
  .search kbd, .sync-button span { display: none; }
  .sync-button { padding: 8px 4px; }
  .stage { padding: 23px 14px 28px; }
  .page-heading { margin-bottom: 17px; }
  .page-heading p { font-size: .84rem; }
  .task-row { gap: 7px; padding: 10px 9px; }
  .rail { grid-template-columns: minmax(0, 1fr); }
  .form-grid.triple { grid-template-columns: minmax(0,1fr); }
  .connect-card { padding: 27px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
.editor-fields { min-width: 0; display: grid; gap: 15px; margin: 0; padding: 0; border: 0; }
.primary.destructive { background: #a13430; border-color: #a13430; }
.connect-card > .text-button { margin-top: 12px; color: var(--green); }
.profile-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-profile .icon-button { flex: none; }
.tenant-form, .tenant-content { display: grid; gap: 12px; }
.tenant-content:empty { display: none; }
.tenant-content h3 { font-size: .95rem; overflow-wrap: anywhere; }
.tenant-code { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.tenant-code button { justify-self: start; }
.tenant-devices { list-style: none; margin: 0; padding: 0; }
.tenant-devices li { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px solid var(--line); }
.tenant-devices li span { overflow-wrap: anywhere; }
