/* ===================================================================
   Formula-Y Progress — styles
   Calm, corporate, low-clutter. Light + dark. Brand: blue #2f5fc0,
   accent red #e2402e (used sparingly).
   =================================================================== */

:root {
  --bg: #f4f7fc;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #e8f0fe 0%, rgba(232,240,254,0) 60%), var(--bg);
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --surface-3: #e6edf8;
  --text: #17233b;
  --text-dim: #5a6a86;
  --text-faint: #8a99b4;
  --border: #e4eaf3;
  --border-strong: #d3dcec;
  --brand: #2f5fc0;
  --brand-strong: #244c9e;
  --brand-soft: #e8effb;
  --red: #e2402e;
  --red-soft: #fdecea;
  --green: #2e9e6b;
  --green-soft: #e6f6ee;
  --amber: #d98324;
  --amber-soft: #fbf0e0;
  --ring-track: #e6edf8;
  --shadow-sm: 0 1px 2px rgba(23,35,59,.06), 0 1px 3px rgba(23,35,59,.05);
  --shadow-md: 0 4px 16px rgba(23,35,59,.10);
  --shadow-lg: 0 18px 48px rgba(23,35,59,.20);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1180px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="dark"] {
  --bg: #0e1524;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #16233f 0%, rgba(22,35,63,0) 60%), var(--bg);
  --surface: #151e30;
  --surface-2: #1b2740;
  --surface-3: #223052;
  --text: #e9eef8;
  --text-dim: #9db0d0;
  --text-faint: #6f82a5;
  --border: #253350;
  --border-strong: #31436a;
  --brand: #5f8bec;
  --brand-strong: #7aa0f2;
  --brand-soft: #1c2c4d;
  --red: #f06a5b;
  --red-soft: #3a2020;
  --green: #4fbe8a;
  --green-soft: #16302440;
  --amber: #e6a049;
  --amber-soft: #33260f;
  --ring-track: #263450;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text);
  background: var(--bg-grad); background-attachment: fixed;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-size: 15px; line-height: 1.45;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
::selection { background: var(--brand-soft); }

/* ---------- Buttons / fields ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 15px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: transform .06s ease, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field textarea, .field select, .inp {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus, .inp:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field .hint, .hint { display: block; margin-top: 5px; font-size: 12px; color: var(--text-faint); }
.field code, code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* ---------- Auth ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  grid-template-rows: 1fr auto;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 30px 28px; align-self: center;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo { width: 62px; height: 62px; }
.auth-title { font-size: 22px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.auth-sub { color: var(--text-dim); font-size: 13px; }
.auth-h { font-size: 18px; margin-bottom: 16px; }
.auth-note, .auth-foot { color: var(--text-dim); font-size: 13px; }
.auth-note { margin: -6px 0 16px; }
.auth-foot { text-align: center; padding: 16px; }
.auth-error { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 16px;
  padding: 10px clamp(12px, 3vw, 24px); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar-logo { width: 30px; height: 30px; }
.topbar-name { font-weight: 800; letter-spacing: -.02em; font-size: 16px; }
.topnav { display: flex; gap: 4px; margin: 0 auto; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.topnav-btn {
  border: 0; background: transparent; color: var(--text-dim); font-weight: 600; font-size: 14px;
  padding: 7px 16px; border-radius: 9px; transition: .15s;
}
.topnav-btn:hover { color: var(--text); }
.topnav-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  border: 0; background: transparent; color: var(--text-dim); width: 38px; height: 38px;
  border-radius: 10px; font-size: 17px; display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); transition: .2s; }
.sync-dot.is-syncing { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.sync-dot.is-offline { background: var(--text-faint); box-shadow: 0 0 0 3px var(--surface-2); }
.avatar-btn { border: 0; background: transparent; padding: 2px; border-radius: 50%; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px; background: var(--brand); user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }

/* ---------- View container ---------- */
.view { max-width: var(--maxw); margin: 0 auto; padding: clamp(14px, 2.5vw, 26px) clamp(12px, 3vw, 24px) 90px; }
.view-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--text-dim); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); font-size: 12.5px; font-weight: 600; border: 1px solid transparent;
}
.pill.is-active { background: var(--brand); color: #fff; }
.select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
}
.searchbar { flex: 1 1 200px; max-width: 320px; position: relative; }
.searchbar input { padding-left: 34px; }
.searchbar::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 16px; }

/* ---------- Progress bar / ring ---------- */
.pbar { height: 7px; border-radius: 999px; background: var(--ring-track); overflow: hidden; }
.pbar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .3s ease; }
.pbar.green > span { background: var(--green); }
.ring { --p: 0; width: 46px; height: 46px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--ring-track); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset .4s ease; }
.ring .lbl { font-size: 12px; font-weight: 800; fill: var(--text); }

/* ---------- Board ---------- */
.board-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.boardtabs { display: flex; gap: 6px; flex-wrap: wrap; }
.boardtab {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  padding: 7px 13px; border-radius: 10px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 7px;
}
.boardtab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.boardtab.is-active { color: var(--text); border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.boardtab .lock { font-size: 11px; color: var(--text-faint); }

/* Date strip */
.datebar { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; scrollbar-width: thin; }
.day {
  flex: none; min-width: 52px; text-align: center; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 8px 6px; color: var(--text-dim); transition: .12s;
}
.day .dow { font-size: 11px; font-weight: 600; }
.day .dnum { font-size: 17px; font-weight: 800; color: var(--text); }
.day.is-today { border-color: var(--brand); }
.day.is-sel { background: var(--brand); color: #fff; }
.day.is-sel .dnum, .day.is-sel .dow { color: #fff; }
.day .cnt { font-size: 10px; margin-top: 2px; }
.day .cnt b { color: var(--brand); }
.day.is-sel .cnt b { color: #fff; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.col.done-col { grid-column: 1 / -1; }
.col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.col-title { font-weight: 700; font-size: 14px; }
.col-count { color: var(--text-faint); font-size: 12px; font-weight: 700; background: var(--surface); padding: 1px 8px; border-radius: 999px; }
.col-collapse { margin-left: auto; }
.quick-add { display: flex; gap: 8px; margin-bottom: 10px; }
.quick-add input { flex: 1; padding: 9px 11px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface); }
.cards { display: flex; flex-direction: column; gap: 9px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
  box-shadow: var(--shadow-sm); position: relative; transition: box-shadow .15s, transform .06s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card.prio-high { border-left: 3px solid var(--red); }
.card.prio-medium { border-left: 3px solid var(--amber); }
.card.prio-low { border-left: 3px solid var(--text-faint); }
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; word-break: break-word; padding-right: 44px; }
.card.done .card-title { text-decoration: line-through; color: var(--text-dim); }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 11.5px; }
.chip.due { color: var(--amber); background: var(--amber-soft); }
.chip.due.overdue { color: var(--red); background: var(--red-soft); }
.chip.obj { color: var(--brand); background: var(--brand-soft); }
.chip.tag { color: var(--text-dim); }
.assignees { display: inline-flex; }
.assignees .avatar { margin-left: -6px; border: 2px solid var(--surface); }
.assignees .avatar:first-child { margin-left: 0; }
.card-prog { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.card-prog .pbar { flex: 1; }
.card-prog .pct { font-size: 11px; font-weight: 700; color: var(--text-dim); min-width: 30px; text-align: right; }
.card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: .15s; }
.card:hover .card-actions { opacity: 1; }
.card-actions button { border: 0; background: var(--surface-2); width: 26px; height: 26px; border-radius: 7px; color: var(--text-dim); font-size: 13px; }
.card-actions button:hover { background: var(--surface-3); color: var(--text); }
.card-move { display: flex; gap: 6px; margin-top: 9px; }
.card-move button { flex: 1; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 5px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.card-move button:hover { border-color: var(--brand); color: var(--brand); }
@media (hover: hover) { .card-move { display: none; } }
.card.done .card-fin { font-size: 11px; color: var(--text-faint); margin-top: 6px; }

/* ---------- OKRs ---------- */
.okr-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.cycletabs { display: flex; gap: 6px; flex-wrap: wrap; }
.summary-band { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 12px; flex: 1 1 160px; }
.stat .big { font-size: 24px; font-weight: 800; }
.stat .lab { font-size: 12px; color: var(--text-dim); }

.obj {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 12px; overflow: hidden;
}
.obj-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; }
.obj-head:hover { background: var(--surface-2); }
.obj-titlewrap { flex: 1; min-width: 0; }
.obj-title { font-weight: 700; font-size: 15.5px; }
.obj-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.obj-caret { color: var(--text-faint); transition: transform .2s; }
.obj.open .obj-caret { transform: rotate(90deg); }
.obj-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); display: none; }
.obj.open .obj-body { display: block; }
.kr { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.kr:last-child { border-bottom: 0; }
.kr-main { flex: 1; min-width: 0; }
.kr-title { font-size: 14px; font-weight: 600; }
.kr-metric { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.kr-metric .pbar { width: 120px; }
.kr-val { display: flex; align-items: center; gap: 6px; }
.kr-val input { width: 92px; text-align: right; padding: 6px 8px; }
.okr-tasklist { margin-top: 10px; }
.okr-sec-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin: 12px 0 6px; }
.okr-task { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; }
.okr-task .pbar { width: 90px; }
.okr-task .ot-title { flex: 1; }
.okr-task.done .ot-title { text-decoration: line-through; color: var(--text-dim); }

/* ---------- Team ---------- */
.member { display: flex; align-items: center; gap: 14px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 10px; }
.member .m-main { flex: 1; min-width: 0; }
.member .m-name { font-weight: 700; }
.member .m-sub { font-size: 12.5px; color: var(--text-dim); }
.role-badge { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.role-owner { background: var(--brand); color: #fff; }
.role-admin { background: var(--brand-soft); color: var(--brand); }
.role-manager { background: var(--amber-soft); color: var(--amber); }
.role-member { background: var(--surface-2); color: var(--text-dim); }
.role-viewer { background: var(--surface-2); color: var(--text-faint); }
.m-inactive { opacity: .5; }

/* ---------- Overlay / modal / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,22,38,.42); backdrop-filter: blur(2px); z-index: 60; opacity: 0; transition: opacity .2s; }
.overlay.show { opacity: 1; }
.modal {
  position: fixed; z-index: 70; top: 50%; left: 50%; transform: translate(-50%, -48%);
  width: min(560px, calc(100vw - 32px)); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 22px; opacity: 0; transition: opacity .2s, transform .2s;
}
.modal.show { opacity: 1; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; margin-bottom: 16px; }
.modal-head h2 { font-size: 17px; }
.modal-close { margin-left: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips-select { display: flex; flex-wrap: wrap; gap: 7px; }
.chips-select .opt { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.chips-select .opt.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-dim); }
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

.sheet {
  position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg); padding: 8px 18px calc(20px + var(--safe-b));
  max-height: 92vh; overflow: auto; transform: translateY(100%); transition: transform .25s ease;
}
.sheet.show { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 8px auto 14px; }

/* Menus (dropdowns) */
.menu { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--text); padding: 9px 11px; border-radius: 8px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu .mhead { padding: 9px 11px 4px; }
.menu .mhead .n { font-weight: 700; }
.menu .mhead .e { font-size: 12px; color: var(--text-dim); }

/* FAB + bottom nav */
.fab {
  position: fixed; z-index: 50; right: 18px; bottom: calc(78px + var(--safe-b)); width: 56px; height: 56px;
  border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 28px; font-weight: 300;
  box-shadow: var(--shadow-lg); display: grid; place-items: center; line-height: 1;
}
.fab:active { transform: scale(.95); }
.botnav { display: none; }

/* Toasts */
.toast-root { position: fixed; z-index: 90; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); color: #fff; }

.empty { text-align: center; color: var(--text-faint); padding: 30px 16px; font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .topnav { display: none; }
  .columns { grid-template-columns: 1fr; }
  .botnav {
    display: flex; position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 6px 8px calc(6px + var(--safe-b)); justify-content: space-around;
  }
  .botnav-btn { border: 0; background: transparent; color: var(--text-faint); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 14px; border-radius: 10px; }
  .botnav-btn .bn-ico { font-size: 19px; }
  .botnav-btn.is-active { color: var(--brand); }
  .view { padding-bottom: 96px; }
  .row2 { grid-template-columns: 1fr; }
  .modal { top: auto; bottom: 0; left: 0; transform: translateY(100%); width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .modal.show { transform: translateY(0); }
}
@media (min-width: 761px) { .fab { display: none !important; } }
