:root {
  --primary: #0F766E; --primary-strong: #115E59; --on-primary: #fff;
  --primary-soft: #CCFBF1; --accent: #EA580C; --accent-soft: #FFEDD5;
  --bg: #F0FDFA; --card: #fff; --fg: #134E4A; --text: #0F172A;
  --muted: #E8F1F4; --muted-fg: #475569; --border: #D5E7E4;
  --danger: #DC2626; --danger-soft: #FEE2E2; --ok: #15803D; --ok-soft: #DCFCE7; --warn: #B45309; --warn-soft: #FEF3C7;
  --col-planned: #6366F1; --col-ongoing: #EA580C; --col-done: #15803D;
  --radius: 14px; --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #2DD4BF; --primary-strong: #5EEAD4; --on-primary: #042F2E;
    --primary-soft: #134E4A; --accent: #FB923C; --accent-soft: #431407;
    --bg: #0B1416; --card: #13201F; --fg: #CCFBF1; --text: #E2E8F0;
    --muted: #1B2B2A; --muted-fg: #94A3B8; --border: #22393A;
    --danger: #F87171; --danger-soft: #450A0A; --ok: #4ADE80; --ok-soft: #052E16; --warn: #FBBF24; --warn-soft: #422006;
    --col-planned: #818CF8; --col-ongoing: #FB923C; --col-done: #4ADE80;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.5;
  background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px; border-bottom: 1px solid var(--border);
}
.top-row { display: flex; align-items: center; gap: 12px; max-width: 1200px; margin: 0 auto; }
.top h1 { font-size: 20px; font-weight: 800; margin: 0; flex: 1; color: var(--fg); letter-spacing: -.01em; }
.page { max-width: 1200px; margin: 0 auto; padding: 16px; }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--border); padding-bottom: var(--safe-b); height: calc(var(--nav-h) + var(--safe-b));
}
.nav button {
  flex: 1; max-width: 120px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted-fg); min-height: 48px; position: relative;
}
.nav button[aria-current="page"] { color: var(--primary); }
.nav button[aria-current="page"]::before { content: ''; position: absolute; top: 0; width: 32px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
.nav .dot { position: absolute; top: 8px; margin-left: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
@media (min-width: 900px) {
  .shell { padding-bottom: 24px; padding-left: 92px; }
  .nav { top: 0; right: auto; width: 80px; height: 100dvh; flex-direction: column; justify-content: flex-start; gap: 8px; padding: 20px 0; border-top: 0; border-right: 1px solid var(--border); }
  .nav button { max-width: none; flex: 0; min-height: 64px; }
  .nav button[aria-current="page"]::before { top: 12px; bottom: 12px; left: 0; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
}

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent; background: var(--primary); color: var(--on-primary); font-weight: 700;
  transition: background .15s, opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:hover { background: var(--primary-strong); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn.ghost:hover { background: var(--muted); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--fg); }
.icon-btn:hover { background: var(--muted); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; color: var(--fg); }
.field .hint { font-size: 13px; color: var(--muted-fg); }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--card);
  font-size: 16px; transition: border-color .15s;
}
.input:focus { border-color: var(--primary); outline: none; }
textarea.input { min-height: 110px; resize: vertical; }
.err { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1em; margin: 0 0 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--muted); color: var(--muted-fg); white-space: nowrap;
}
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.orange { background: var(--warn-soft); color: var(--warn); }
.chip.green { background: var(--ok-soft); color: var(--ok); }
.chip.teal { background: var(--primary-soft); color: var(--fg); }
.chip svg.i { width: 14px; height: 14px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--primary-soft); color: var(--fg); font-weight: 800; font-size: 15px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.muted { color: var(--muted-fg); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2.section { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-fg); margin: 24px 0 10px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted-fg); font-size: 14px; }

/* ---------- people switcher ---------- */
.people { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 2px; scrollbar-width: none; max-width: 1200px; margin: 0 auto; }
.people::-webkit-scrollbar { display: none; }
.person-pill {
  display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--card); font-weight: 700; font-size: 14px; white-space: nowrap; min-height: 44px;
}
.person-pill[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--fg); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px 22px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 48px; height: 48px; }
.brand h1 { margin: 0; font-size: 22px; color: var(--fg); }
.brand p { margin: 0; font-size: 14px; color: var(--muted-fg); }

/* ---------- team overview ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px; }
.kpi b { display: block; font-size: 26px; font-weight: 800; color: var(--fg); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted-fg); font-weight: 600; }
.members { display: grid; gap: 12px; }
@media (min-width: 900px) { .members { grid-template-columns: repeat(3, 1fr); } }
.member { padding: 16px; display: grid; gap: 14px; text-align: left; width: 100%; color: inherit; transition: border-color .15s; }
button.member:hover { border-color: var(--primary); }
.member-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.member-head p { margin: 0; font-size: 13px; color: var(--muted-fg); }
.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bar { border-radius: 10px; padding: 8px 10px; background: var(--muted); }
.bar b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar span { font-size: 12px; font-weight: 600; color: var(--muted-fg); }
.bar.planned b { color: var(--col-planned); } .bar.ongoing b { color: var(--col-ongoing); } .bar.done b { color: var(--col-done); }
.progress { height: 8px; border-radius: 99px; background: var(--muted); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }
.stats-line { display: flex; flex-wrap: wrap; gap: 6px; }
.heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--muted); }
.heat i.on { background: var(--primary); }
.heat i.off { background: var(--danger-soft); outline: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.heat i.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.heat i.pre { background: transparent; outline: 1px dashed var(--border); }
.feed { padding: 4px 0; }
.feed li { list-style: none; display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed ul { margin: 0; padding: 0; }

/* ---------- board ---------- */
.board {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 16px; margin: 0 -16px;
  scroll-padding: 16px; scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
.col { flex: 0 0 86%; scroll-snap-align: start; display: flex; flex-direction: column; background: var(--muted); border-radius: var(--radius); min-height: 60dvh; }
@media (min-width: 700px) { .col { flex-basis: calc(50% - 6px); } }
@media (min-width: 1024px) { .board { overflow: visible; } .col { flex: 1; } }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 800; }
.col-head .swatch { width: 10px; height: 10px; border-radius: 50%; }
.col-head .count { margin-left: auto; font-size: 13px; color: var(--muted-fg); background: var(--card); border-radius: 99px; padding: 1px 10px; }
.col-list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 14px; min-height: 120px; }
.col-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.col-tabs button { flex: 1; border: 0; border-radius: 10px; min-height: 40px; background: var(--card); font-weight: 700; font-size: 13px; color: var(--muted-fg); border: 1px solid var(--border); }
.col-tabs button.active { color: var(--fg); border-color: var(--primary); background: var(--primary-soft); }
@media (min-width: 1024px) { .col-tabs { display: none; } }

.task {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 8px;
  border-left: 4px solid var(--border); touch-action: manipulation; user-select: none; -webkit-user-select: none; text-align: left; width: 100%;
  transition: box-shadow .15s, border-color .15s;
}
.task:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.task.p-high { border-left-color: var(--danger); } .task.p-medium { border-left-color: var(--accent); } .task.p-low { border-left-color: var(--col-planned); }
.task h4 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.task .desc { margin: 0; font-size: 13px; color: var(--muted-fg); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task.ghost-drag { opacity: .35; }
.task.chosen { box-shadow: 0 10px 30px rgba(0,0,0,.18); transform: rotate(1.5deg); }
.live { font-variant-numeric: tabular-nums; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25;
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(234, 88, 12, .35); transition: transform .15s;
}
.fab:active { transform: scale(.94); }
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.5; }
@media (min-width: 900px) { .fab { bottom: 24px; right: 24px; } }

/* ---------- sheet (bottom sheet on mobile, dialog on desktop) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 20px 20px 0 0;
  background: var(--card); color: var(--text); overflow: auto; padding-bottom: var(--safe-b);
}
dialog.sheet::backdrop { background: rgba(2, 20, 20, .5); }
dialog.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 20px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.sheet-head h3 { margin: 0; flex: 1; font-size: 18px; font-weight: 800; }
.sheet-body { padding: 6px 20px 20px; }
.grab { width: 40px; height: 5px; border-radius: 99px; background: var(--border); margin: 8px auto 0; }
@media (min-width: 700px) { .grab { display: none; } }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 10px; border: 1.5px solid var(--border); font-weight: 700; font-size: 14px; cursor: pointer; }
.seg input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--fg); }
.seg input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; margin: 14px 0; }
.kv dt { color: var(--muted-fg); font-weight: 600; } .kv dd { margin: 0; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions .btn { flex: 1; }

/* ---------- logs ---------- */
.log-entry { padding: 14px; display: grid; gap: 6px; }
.log-entry.off { background: transparent; border-style: dashed; }
.log-entry p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.log-list { display: grid; gap: 10px; }

/* ---------- profile ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 16px; text-align: center; }
.avatar-edit { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 3px solid var(--card); }
.avatar-edit .cam svg.i { width: 16px; height: 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 24px); transform: translate(-50%, 20px); z-index: 100;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 40vh auto; }
@keyframes spin { to { transform: rotate(360deg); } }
