:root {
  --bg: #f6f7fb; --surface: #fff; --text: #1c1f2a; --muted: #6a7085; --line: #e3e6ef; --primary: #4f46e5; --primary-text: #fff;
  --danger: #d92d3a; --ok: #1a7f4b; --shadow: 0 1px 3px rgba(20,24,40,.08), 0 4px 14px rgba(20,24,40,.05); --radius: 12px;
  --lw: 150px; --nav-h: 58px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11131a; --surface: #1b1e28; --text: #e8eaf2; --muted: #9aa1b8; --line: #2c3040; --primary: #7c78ff; --primary-text: #0d0e18; --danger: #ff6b76; --ok: #4cc58a; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; } h2 { font-size: 1.1rem; margin: 0 0 .5rem; } h3 { margin: 0 0 .5rem; font-size: .95rem; }
a { color: var(--primary); } .muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.boot { padding: 2rem; text-align: center; color: var(--muted); }
.ok { color: var(--ok); } .hint { background: color-mix(in srgb, var(--primary) 12%, transparent); padding: .7rem .9rem; border-radius: 8px; }

.shell { min-height: 100vh; }
#view { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav .brand, .nav .who { display: none; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 4px; min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .75rem; position: relative; }
.nav a.active { color: var(--primary); font-weight: 600; }
.ico { display: inline-flex; }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 10px; min-width: 18px; padding: 0 5px; font-size: .72rem; text-align: center; line-height: 18px; }
@media (min-width: 860px) {
  :root { --lw: 240px; }
  .nav { top: 0; right: auto; bottom: 0; width: 220px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 16px 10px; }
  .nav .brand { display: block; font-weight: 700; font-size: 1.15rem; padding: 4px 12px 16px; color: var(--primary); }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; min-height: 0; border-radius: 8px; font-size: .95rem; }
  .nav a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
  .badge { position: static; margin-left: auto; }
  .nav .who { display: block; margin-top: auto; padding: 10px 12px; color: var(--muted); font-size: .85rem; }
  #view { margin-left: 220px; max-width: none; padding: 24px 32px 40px; }
  #view > .view { max-width: 1200px; }
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; min-height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); } .btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); } .btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; } .btn.block { width: 100%; margin-top: .4rem; }
.btn.left { margin-right: auto; } .icon-btn { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 10px; min-height: 36px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-height: 40px; }
input[type=checkbox] { width: auto; min-height: 0; } :focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; flex: 1; min-width: 0; } .field > span { font-size: .85rem; color: var(--muted); font-weight: 600; }
select.small-select { width: auto; min-height: 32px; padding: 3px 6px; font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; } .row.end { justify-content: flex-end; margin: 8px 0; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; } .row > .field { margin-bottom: 12px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; } .project-card { text-decoration: none; color: inherit; display: block; margin: 0; } .project-card:hover { border-color: var(--primary); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: .2rem 0 .5rem; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.page-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; } .page-head > div { flex: 1; min-width: 200px; } .page-head h1 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.alert { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 9px 12px; border-radius: 8px; margin: 8px 0; }
.pill { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); font-weight: 600; vertical-align: middle; }
.pill.admin { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); } .pill.manager { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.st-done { color: var(--ok); }
.progress { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0; } .progress > div { height: 100%; background: var(--ok); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.15); } .dots { display: inline-flex; gap: 3px; }
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.center-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 100%; max-width: 400px; box-shadow: var(--shadow); } .center-card h1 { text-align: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; } .tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.chip.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); font-weight: 600; } .chip.static { cursor: default; color: var(--muted); } .chip:disabled { cursor: default; opacity: .8; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; } .swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; } .swatch.on { box-shadow: 0 0 0 3px var(--primary); }
.checks { display: flex; flex-direction: column; gap: 6px; } .check { display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; } .seg button { border: 0; background: var(--surface); color: var(--text); padding: 7px 14px; font: inherit; cursor: pointer; } .seg button.on { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.sublist { list-style: none; padding: 0; margin: 0 0 8px; } .sublist li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); }

dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); max-height: 92vh; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog.modal::backdrop { background: rgba(10,12,20,.5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); } .modal-head h2 { margin: 0; }
.modal-body { padding: 16px; }
.toast { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 92vw; } .toast.err { background: var(--danger); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

.kanban { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 760px) { .kanban { grid-template-columns: repeat(3, 1fr); align-items: start; } }
.kcol { background: color-mix(in srgb, var(--line) 45%, transparent); border-radius: var(--radius); padding: 10px; min-height: 90px; } .kcol.over { outline: 2px dashed var(--primary); }
.count { margin-left: 8px; font-weight: 400; color: var(--muted); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; } .kcard.done .kt { text-decoration: line-through; color: var(--muted); } .kt { font-weight: 600; word-break: break-word; } .kprog { display: flex; align-items: center; gap: 8px; } .kprog .progress { flex: 1; margin: 0; }
.crumbs { margin: 4px 0; } .tree { list-style: none; padding: 0; margin: 8px 0; }
.trow { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px calc(10px + var(--d) * 22px); border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; } .trow .ttitle { flex: 1; min-width: 120px; color: var(--text); text-decoration: none; font-weight: 500; } .trow.done .ttitle { text-decoration: line-through; color: var(--muted); }
.members { list-style: none; padding: 0; margin: 8px 0; } .member { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .member select { width: auto; } .color-select { padding-left: 6px; }
.invite-text { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: .9rem/1.5 ui-monospace, monospace; word-break: break-word; }

/* Gantt */
.g-controls { margin-top: 4px; }
.gantt { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 70vh; position: relative; }
.g-inner { position: relative; width: max-content; min-width: 100%; }
.g-head { display: flex; position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line); height: 52px; }
.g-corner, .g-label { position: sticky; left: 0; z-index: 5; width: var(--lw); flex: none; background: var(--surface); border-right: 1px solid var(--line); }
.g-scale { position: relative; flex: none; } .g-h1, .g-h2 { position: relative; height: 26px; } .g-h1 { border-bottom: 1px solid var(--line); }
.g-cell { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding: 3px 4px; font-size: .75rem; color: var(--muted); overflow: hidden; white-space: nowrap; line-height: 20px; }
.g-row { display: flex; height: 36px; border-bottom: 1px solid var(--line); position: relative; } .g-row.dim { opacity: .45; } .g-row.g-ms { height: 44px; background: color-mix(in srgb, var(--line) 25%, var(--surface)); }
.g-label { display: flex; align-items: center; gap: 4px; overflow: hidden; font-size: .88rem; padding-right: 6px; }
.g-title { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .g-row.done .g-title { color: var(--muted); }
.caret { width: 22px; height: 24px; flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.g-tl { position: relative; flex: none; height: 100%; }
.g-bar { position: absolute; top: 7px; height: 22px; border: 0; border-radius: 6px; padding: 0; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.25); z-index: 1; background: none; }
.g-bar .stripes { display: flex; flex-direction: column; height: 100%; } .g-bar i { flex: 1; } .g-bar.done { opacity: .5; }
.g-bar .check { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; text-shadow: 0 0 3px #000; font-size: .85rem; }
.g-diamond-wrap { position: absolute; top: 6px; height: 32px; display: flex; align-items: center; gap: 5px; background: none; border: 0; padding: 0; cursor: pointer; z-index: 3; color: var(--text); font: inherit; font-size: .8rem; white-space: nowrap; }
.g-diamond { width: 14px; height: 14px; background: #f59e0b; transform: rotate(45deg); border: 1px solid rgba(0,0,0,.3); margin: 0 2px; } .g-mtitle { font-weight: 600; }
.g-overlay { position: absolute; left: var(--lw); top: 52px; bottom: 0; pointer-events: none; z-index: 2; }
.g-mline { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #f59e0b; } .g-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--danger); }

.g-h1 .g-cell { overflow: visible; } .g-sticky { position: sticky; left: calc(var(--lw) + 6px); display: inline-block; }
.invites { border-color: var(--primary); } .invite-row { padding: 6px 0; } .invite-row + .invite-row { border-top: 1px solid var(--line); }
.offline-banner { position: fixed; z-index: 90; top: 0; left: 0; right: 0; background: #7a5200; color: #fff; text-align: center; font-size: .85rem; padding: 4px 12px; }
.offline-banner[hidden] { display: none; }
body.has-banner { padding-top: 26px; }
