:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --review: #4a3aa7;
  --good-text: #006300;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --review: #9085e9;
    --good-text: #0ca30c;
  }
}

* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.login-sub { color: var(--ink-2); margin: 6px 0 20px; }

.logo { font-weight: 700; font-size: 18px; }
.logo span { color: var(--accent); }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface-1); border-right: 1px solid var(--grid);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left; background: none; border: none; padding: 10px 12px; border-radius: 8px;
  font-size: 15px; color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.nav-item:hover { background: var(--page); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sidebar-footer { border-top: 1px solid var(--grid); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; flex-direction: column; }
.me small { color: var(--muted); text-transform: capitalize; }

.main { flex: 1; padding: 28px 32px; max-width: 1100px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 24px; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 15px; margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- controls ---------- */
.btn {
  font-family: inherit; font-size: 14px; border-radius: 8px; padding: 9px 16px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--grid); }
.btn-danger { background: transparent; border-color: var(--critical); color: var(--critical); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--baseline); border-radius: 8px; background: var(--surface-1); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--critical); font-size: 13px; margin-bottom: 10px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select { width: auto; margin-top: 0; }
.chip {
  font-family: inherit; font-size: 13px; padding: 7px 14px; border-radius: 99px;
  border: 1px solid var(--baseline); background: var(--surface-1); color: var(--ink-2); cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- kanban board ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.kcol { background: var(--page); border: 1px solid var(--grid); border-radius: 12px; min-height: 200px; }
.kcol-head {
  font-weight: 700; font-size: 13.5px; padding: 12px 14px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--grid);
}
.kcol-head::before { content: ""; width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.kcol-Open::before { background: var(--warning); }
.kcol-InProgress::before { background: var(--accent); }
.kcol-NeedReview::before { background: var(--review); }
.kcol-Done::before { background: var(--good); }
.kcount { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kcard {
  background: var(--surface-1); border: 1px solid var(--border); border-left-width: 3px; border-radius: 10px;
  padding: 12px 14px; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.kcard:hover { border-color: var(--accent); border-left-color: inherit; box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.kcard.dragging { opacity: .45; cursor: grabbing; }
.kcard-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.kcard-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.kcard-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.cat-chip {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--grid); color: var(--ink-2);
}
.prio-edge-Low { border-left-color: var(--baseline); }
.prio-edge-Medium { border-left-color: var(--accent); }
.prio-edge-High { border-left-color: var(--serious); }
.prio-edge-Urgent { border-left-color: var(--critical); }
.kcol.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcol.drop-target .kcol-body { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.kempty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.btn-link {
  background: none; border: none; color: var(--accent); font-family: inherit; font-size: 13.5px;
  cursor: pointer; margin-top: 12px; display: block; width: 100%; text-align: center;
}
.detail-head-actions { display: flex; gap: 6px; flex-shrink: 0; }

.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill-open       { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--ink); border: 1px solid var(--warning); }
.pill-inprogress { background: color-mix(in srgb, var(--accent) 15%, transparent);  color: var(--ink); border: 1px solid var(--accent); }
.pill-done       { background: color-mix(in srgb, var(--good) 15%, transparent);    color: var(--ink); border: 1px solid var(--good); }
.pill-neutral    { background: var(--grid); color: var(--ink-2); }
.prio { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.prio-Urgent::before { content: "⚠ "; }
.prio-High { font-weight: 700; }
.hours-badge { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; white-space: nowrap; }

/* ---------- cards / tables ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px;
}
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--grid);
}
.table td { padding: 10px; border-bottom: 1px solid var(--grid); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- stat tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
}
.stat .v { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

/* ---------- bar list chart ---------- */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: 10px; align-items: center; }
.bar-row .name { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: transparent; height: 18px; position: relative; }
.bar-track::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--baseline); }
.bar-fill {
  height: 100%; background: var(--accent); border-radius: 0 4px 4px 0;
  min-width: 2px; transition: width .3s ease;
}
.bar-row .val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }

/* ---------- modals ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 7vh 16px; z-index: 50; overflow-y: auto;
}
.modal {
  background: var(--surface-1); border-radius: 14px; padding: 24px; width: 100%; max-width: 440px;
  border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-wide { max-width: 580px; }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-actions.space-between { justify-content: space-between; margin-top: 16px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head h2 { margin-bottom: 4px; }
.detail-meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.detail-desc { color: var(--ink-2); margin-bottom: 14px; white-space: pre-wrap; }
.detail-desc:empty { display: none; }

.status-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.status-switch .chip.active[data-s="Open"] { background: var(--warning); border-color: var(--warning); color: #0b0b0b; }
.status-switch .chip.active[data-s="Need Review"] { background: var(--review); border-color: var(--review); }
.status-switch .chip.active[data-s="Done"] { background: var(--good); border-color: var(--good); }

.time-form { display: grid; grid-template-columns: 90px 140px 1fr auto; gap: 8px; align-items: center; margin-bottom: 12px; }
.time-form input { margin-top: 0; }
.time-list { display: flex; flex-direction: column; }
.time-entry {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 2px;
  border-bottom: 1px solid var(--grid); font-size: 13.5px;
}
.time-entry:last-child { border-bottom: none; }
.time-entry .h { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; }
.time-entry .d { color: var(--muted); min-width: 84px; }
.time-entry .n { color: var(--ink-2); flex: 1; }
.time-entry .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.time-entry .del:hover { color: var(--critical); }

.temp-pass {
  font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: 2px; text-align: center;
  background: var(--page); border: 1px dashed var(--baseline); border-radius: 10px;
  padding: 14px; margin: 14px 0; user-select: all;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page); padding: 10px 20px; border-radius: 99px;
  font-size: 14px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; }
  .sidebar nav { flex-direction: row; }
  .sidebar .logo { display: none; }
  .sidebar-footer { border: none; padding: 0; flex-direction: row; align-items: center; margin-left: auto; }
  .me small { display: none; }
  .main { padding: 18px 14px; }
  .kanban { grid-template-columns: 1fr; }
  .time-form { grid-template-columns: 1fr 1fr; }
  .time-form button { grid-column: span 2; }
  .bar-row { grid-template-columns: 90px 1fr 50px; }
}
