:root {
  --bg: #0f1216;
  --bg-2: #151a21;
  --panel: #181e26;
  --panel-2: #1e2530;
  --line: #262f3b;
  --line-soft: #202833;
  --text: #e6ebf2;
  --muted: #8b98a9;
  --dim: #64707f;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --todo: #7a8899;
  --wip: #d99a4e;
  --done: #4fb286;
  --danger: #e0798c;
  --urgent: #e0798c;
  --high: #d99a4e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3442; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 16px;
  font-weight: 650; font-size: 15px; letter-spacing: -0.01em;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #8f7ae5);
  display: grid; place-items: center; font-size: 14px;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--dim); letter-spacing: 0; }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--dim); padding: 16px 10px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--muted); background: none; border: 0; width: 100%;
  text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #cddcfb; font-weight: 550; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: #9db8ee; }
.nav-item .pill-badge {
  margin-left: auto; background: var(--danger); color: #1a0d11;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 9px;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 22, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .sub { color: var(--dim); font-size: 12.5px; }
.spacer { flex: 1; }

.content { padding: 20px 24px 60px; flex: 1; }

/* ---------- controls ---------- */

.btn {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #263041; border-color: #33415a; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn-primary:hover { background: #6f9bf3; border-color: #6f9bf3; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger:hover { background: rgba(224, 121, 140, 0.16); border-color: var(--danger); color: var(--danger); }

.input, .select, .textarea {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%238b98a9' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }

/* ---------- composer ---------- */

.composer { position: relative; margin-bottom: 18px; }
.composer-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-input {
  flex: 1; background: none; border: 0; outline: 0;
  padding: 6px 0; font-size: 14.5px; resize: none;
  min-height: 32px; max-height: 160px; line-height: 1.5; overflow-y: auto;
}
.composer-hint { font-size: 11.5px; color: var(--dim); margin-top: 7px; padding-left: 2px; }
.composer-hint code {
  font-family: var(--mono); background: var(--panel-2); padding: 1px 5px;
  border-radius: 4px; color: var(--muted); font-size: 11px;
}

.mention-menu {
  position: absolute; z-index: 60; min-width: 250px; max-height: 264px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px;
}
.mention-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.mention-item.active { background: var(--accent-soft); }
.mention-item .handle { color: var(--dim); font-size: 12px; margin-left: auto; font-family: var(--mono); }

/* ---------- avatars & chips ---------- */

.avatar {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  color: #0d1117; letter-spacing: 0.02em; user-select: none;
}
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar.xl { width: 62px; height: 62px; font-size: 21px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -6px; border: 2px solid var(--panel); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.chip.status-todo { color: var(--todo); }
.chip.status-wip { color: var(--wip); border-color: rgba(217, 154, 78, 0.35); background: rgba(217, 154, 78, 0.1); }
.chip.status-done { color: var(--done); border-color: rgba(79, 178, 134, 0.35); background: rgba(79, 178, 134, 0.1); }
.chip.prio-high { color: var(--high); border-color: rgba(217, 154, 78, 0.4); }
.chip.prio-urgent { color: var(--urgent); border-color: rgba(224, 121, 140, 0.45); background: rgba(224, 121, 140, 0.1); font-weight: 600; }
.chip.overdue { color: var(--danger); border-color: rgba(224, 121, 140, 0.45); background: rgba(224, 121, 140, 0.1); }

.mention-tag {
  color: #9db8ee; background: var(--accent-soft);
  padding: 0 4px; border-radius: 4px; font-weight: 550;
}

/* ---------- board ---------- */

.board { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 14px; align-items: start; }

.column {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  min-height: 220px; transition: border-color 0.15s, background 0.15s;
}
.column.drag-over { border-color: var(--accent); background: rgba(91, 141, 239, 0.05); }
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
}
.column-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.column-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.column-head .n {
  margin-left: auto; font-size: 11.5px; color: var(--dim);
  background: var(--panel); padding: 1px 8px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px;
  cursor: pointer; transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.card:hover { border-color: #35435a; box-shadow: 0 3px 12px rgba(0,0,0,0.3); }
.card.dragging { opacity: 0.45; transform: rotate(1.5deg); }
.card-title { font-size: 13.5px; line-height: 1.45; margin-bottom: 9px; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card-meta .when { font-size: 11px; color: var(--dim); margin-left: auto; }
.card-assignee { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.card-sub { font-size: 11px; color: var(--dim); display: flex; gap: 10px; margin-top: 7px; }

.empty {
  text-align: center; color: var(--dim); font-size: 12.5px;
  padding: 26px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
}

/* ---------- dashboard ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px;
}
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .v { font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.stat.accent .v { color: var(--accent); }
.stat.warn .v { color: var(--wip); }
.stat.good .v { color: var(--done); }
.stat.bad .v { color: var(--danger); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-head .sub { font-size: 11.5px; color: var(--dim); margin-left: auto; }
.panel-body { padding: 13px 15px; }
/* Wide content (the throughput table) scrolls inside the panel instead of pushing the page sideways. */
.panel-body.flush { padding: 0; overflow-x: auto; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 15px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; font-size: 13px;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--panel-2); }
.row-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .when { font-size: 11px; color: var(--dim); white-space: nowrap; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark .bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: 0.85; }
.spark .bar.zero { background: var(--line); opacity: 1; }

.workload-row { display: flex; align-items: center; gap: 11px; padding: 9px 15px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.workload-row:last-child { border-bottom: 0; }
.workload-row:hover { background: var(--panel-2); }
.workload-row .who { width: 168px; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.workload-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; display: flex; height: 16px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.bar-seg { transition: width 0.25s; }
.bar-seg.todo { background: var(--todo); }
.bar-seg.wip { background: var(--wip); }
.bar-seg.done { background: var(--done); }
.workload-row .nums { width: 128px; text-align: right; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* ---------- history / activity ---------- */

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.feed-item .quote {
  margin-top: 5px; padding: 6px 9px; background: var(--bg);
  border-left: 2px solid var(--line); border-radius: 0 5px 5px 0;
  color: var(--muted); font-size: 12.5px;
}
.feed-item .task-ref { color: var(--muted); cursor: pointer; }
.feed-item .task-ref:hover { color: var(--accent); }

/* ---------- drawer ---------- */

#overlay:empty { display: none; }
.backdrop {
  position: fixed; inset: 0; background: rgba(6, 8, 11, 0.62);
  z-index: 90;
}
.backdrop.anim-in { animation: fade 0.14s ease; }
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--bg-2); border-left: 1px solid var(--line);
  z-index: 100; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,0.4);
}
.drawer.anim-in { animation: slide 0.18s cubic-bezier(0.2,0.8,0.3,1); }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 12px 18px; background: var(--panel); }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; z-index: 100; box-shadow: var(--shadow); padding: 22px;
}

.detail-title {
  font-size: 19px; font-weight: 600; line-height: 1.35;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 5px 8px; margin: -5px -8px 12px; width: calc(100% + 16px);
  background: none; letter-spacing: -0.01em;
}
.detail-title:hover { border-color: var(--line); }
.detail-title:focus { border-color: var(--accent); outline: 0; background: var(--bg); }

.meta-grid { display: grid; grid-template-columns: 104px 1fr; gap: 9px 14px; align-items: center; font-size: 13px; margin-bottom: 18px; }
.meta-grid .lbl { color: var(--dim); font-size: 12px; }

.status-switch { display: flex; gap: 5px; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--line); }
.status-switch button {
  flex: 1; padding: 6px 8px; border: 0; background: none;
  color: var(--muted); border-radius: 6px; font-size: 12.5px; font-weight: 550;
}
.status-switch button:hover { background: var(--panel-2); color: var(--text); }
.status-switch button.on { color: #0d1117; }
.status-switch button.on[data-s="todo"] { background: var(--todo); }
.status-switch button.on[data-s="wip"] { background: var(--wip); }
.status-switch button.on[data-s="done"] { background: var(--done); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none; border: 0; padding: 8px 12px; color: var(--muted);
  font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 550; }

.comment { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.comment:last-child { border-bottom: 0; }
.comment .who { font-size: 12.5px; font-weight: 600; }
.comment .when { font-size: 11px; color: var(--dim); font-weight: 400; margin-left: 7px; }
.comment .text { margin-top: 3px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------- login ---------- */

.center-page {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
  background: radial-gradient(1100px 560px at 50% -10%, #1a2233 0%, var(--bg) 62%);
}
.card-panel {
  width: min(680px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: var(--shadow);
}
.card-panel h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.card-panel .lede { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; line-height: 1.6; }

.login-panel { width: min(420px, 100%); }
.auth-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  font-weight: 650; letter-spacing: -0.02em;
}
.auth-brand small { display: block; font-size: 11px; color: var(--dim); font-weight: 500; letter-spacing: 0; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11.5px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px;
}
.btn-block { width: 100%; justify-content: center; margin-top: 14px; }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.person-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: left; transition: border-color 0.12s, background 0.12s;
}
.person-btn:hover { border-color: var(--accent); background: #232c3a; }
.person-btn .nm { font-size: 13px; font-weight: 550; }
.person-btn .hd { font-size: 11px; color: var(--dim); font-family: var(--mono); }

/* ---------- misc ---------- */

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 20px; z-index: 200;
  box-shadow: var(--shadow); font-size: 13px; animation: rise 0.18s ease;
}
.toast.err { border-color: var(--danger); color: #f4b8c4; }
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--dim); padding: 9px 15px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.table td { padding: 10px 15px; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--panel-2); }
.num { font-variant-numeric: tabular-nums; }

.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar .input { width: auto; min-width: 200px; }
.filter-bar .select { width: auto; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row;
    flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; }
  .nav-label, .brand small { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .nav-item { width: auto; }
  .board { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
}
