@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --navy: #12263A;
  --navy-deep: #0B1B2B;
  --line-blue: #2E4A66;
  --line-blue-soft: rgba(46, 74, 102, 0.35);
  --paper: #EDEFF1;
  --paper-card: #FFFFFF;
  --ink: #16232F;
  --muted: #5B6B7A;
  --muted-soft: #8B98A5;
  --border: #D8DEE3;
  --accent: #C2571C;
  --accent-hover: #A5480F;
  --accent-soft: rgba(194, 87, 28, 0.12);
  --status-not-started: #8A8F98;
  --status-not-started-soft: rgba(138, 143, 152, 0.16);
  --status-in-progress: #C99418;
  --status-in-progress-soft: rgba(201, 148, 24, 0.16);
  --status-done: #2E7D3D;
  --status-done-soft: rgba(46, 125, 61, 0.14);
  --status-complete: #2D5FA6;
  --status-complete-soft: rgba(45, 95, 166, 0.14);
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(18, 38, 58, 0.08);
  --shadow-md: 0 4px 16px rgba(18, 38, 58, 0.10);
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sidebar-w: 232px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--navy);
  color: #DCE4EA;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  padding: 1.5rem 1.25rem;
  background-image:
    linear-gradient(var(--navy), var(--navy)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 28px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px, transparent 1px, transparent 28px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 1.25rem;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  color: #9FB0BF;
  line-height: 1.4;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  color: #C3CFD9;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.nav-list a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.nav-list a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: var(--accent);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.legend-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7E90A0;
  margin-bottom: 0.55rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #C3CFD9;
  padding: 0.15rem 0;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-tagline {
  margin-top: 1rem;
  font-size: 0.7rem;
  color: #5C7285;
  line-height: 1.5;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--paper-card);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar .topbar-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-strip {
  display: flex;
  gap: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-strip strong {
  font-size: 0.95rem;
  color: var(--ink);
  margin-right: 0.3rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--paper-card);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.btn:hover { border-color: var(--muted-soft); background: #F7F8F9; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--ink); }

.btn-danger { color: #A82F1E; border-color: #EAC9C2; background: #FBF2F0; }
.btn-danger:hover { background: #F6E3DF; }

.btn-sm { padding: 0.32rem 0.6rem; font-size: 0.76rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Status pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }

.pill-not_started { background: var(--status-not-started-soft); color: #4C525A; }
.pill-not_started .dot { background: var(--status-not-started); }
.pill-in_progress { background: var(--status-in-progress-soft); color: #7A5C0A; }
.pill-in_progress .dot { background: var(--status-in-progress); }
.pill-done { background: var(--status-done-soft); color: #1E5A29; }
.pill-done .dot { background: var(--status-done); }
.pill-complete { background: var(--status-complete-soft); color: #1E3E70; }
.pill-complete .dot { background: var(--status-complete); }

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

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="search"],
.field textarea,
.field select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  background: #fff;
  font-size: 0.86rem;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 60px; }

.status-select-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.status-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.status-select-item .cat-name { font-size: 0.85rem; font-weight: 500; }
.status-toggle-group { display: flex; gap: 4px; }
.status-toggle {
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 4px;
  cursor: pointer;
}
.status-toggle.on-not_started.active { background: var(--status-not-started); border-color: var(--status-not-started); color: #fff; }
.status-toggle.on-in_progress.active { background: var(--status-in-progress); border-color: var(--status-in-progress); color: #4A3600; }
.status-toggle.on-done.active { background: var(--status-done); border-color: var(--status-done); color: #fff; }

/* ---------- Card ---------- */

.card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--muted);
  padding: 2rem;
  font-size: 0.88rem;
  line-height: 1.5;
}
.empty-state strong { color: var(--ink); font-size: 0.95rem; }

/* ---------- Scrollbars (subtle) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C7CFD6; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .main { margin-left: 0; }
  .app-shell { flex-direction: column; }
}

/* ---------- Dashboard ---------- */
.dash-grid { padding: 1.5rem 1.75rem; display: flex; flex-direction: column; gap: 1.25rem; }
.dash-top { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.big-metric-card { padding: 1.5rem 1.75rem; flex: 0 0 280px; display: flex; flex-direction: column; gap: 0.4rem; }
.big-metric-card .metric-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.big-metric-card .metric-value { font-family: var(--font-mono); font-size: 3rem; font-weight: 600; color: var(--accent); line-height: 1; }
.big-metric-card .metric-sub { font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.metric-bar { height: 10px; border-radius: 999px; background: #EEF1F3; overflow: hidden; margin-top: 0.3rem; }
.metric-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

.dash-secondary { flex: 1; min-width: 260px; padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.dash-secondary h3 { font-size: 0.85rem; font-weight: 600; }
.mini-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.83rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.mini-row:last-child { border-bottom: none; }

.dash-cards-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.dash-card { flex: 1; min-width: 260px; padding: 1.25rem 1.5rem; }
.dash-card h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.75rem; }
.region-bar-row { display: flex; flex-direction: column; gap: 0.5rem; }
.region-bar-item { display: flex; flex-direction: column; gap: 0.25rem; }
.region-bar-item .rb-top { display: flex; justify-content: space-between; font-size: 0.8rem; }
.region-bar-item .rb-track { height: 7px; border-radius: 999px; background: #EEF1F3; overflow: hidden; }
.region-bar-item .rb-fill { height: 100%; border-radius: 999px; }

.kanban-summary { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.kanban-summary-col { flex: 0 0 92px; text-align: center; padding: 0.7rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: #FAFBFC; }
.kanban-summary-col .ks-count { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 600; }
.kanban-summary-col .ks-label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

/* ---------- Regions page ---------- */
.region-item .bi-color-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-right: 0.4rem; flex-shrink: 0; }
.color-input-row { display: flex; align-items: center; gap: 0.6rem; }
.color-input-row input[type="color"] { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; }

/* ---------- Kanban board ---------- */
.kanban-board { padding: 1.5rem 1.75rem; flex: 1; display: flex; gap: 1rem; overflow-x: auto; align-items: flex-start; }
.kanban-col { width: 280px; flex-shrink: 0; background: #F0F2F4; border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 130px); }
.kanban-col-head { padding: 0.85rem 0.9rem 0.6rem; display: flex; align-items: center; justify-content: space-between; }
.kanban-col-head h3 { font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.kanban-col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.kanban-col-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted-soft); background: #fff; border-radius: 999px; padding: 0.05rem 0.5rem; }
.kanban-cards { flex: 1; overflow-y: auto; padding: 0 0.6rem 0.6rem; display: flex; flex-direction: column; gap: 0.55rem; min-height: 40px; }
.kanban-cards.drag-over { background: rgba(194,87,28,0.08); border-radius: var(--radius); }
.kanban-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem 0.75rem; cursor: grab; box-shadow: var(--shadow-sm); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .kc-title { font-size: 0.85rem; font-weight: 600; line-height: 1.35; }
.kanban-card .kc-desc { font-size: 0.76rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.4; white-space: pre-wrap; }
.kanban-card .kc-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.kanban-add-btn { margin: 0.4rem 0.6rem 0.7rem; }
.kanban-modal-backdrop { position: fixed; inset: 0; background: rgba(11,27,43,0.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.kanban-modal { width: 420px; max-width: 92vw; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.8rem; max-height: 88vh; overflow-y: auto; }
.kanban-modal h2 { font-size: 1rem; font-weight: 600; }

/* ---------- Subtask checklist (on card) ---------- */

.kc-subtask-progress { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.5rem; }
.kc-subtask-bar { flex: 1; height: 5px; border-radius: 999px; background: #E4E7EB; overflow: hidden; }
.kc-subtask-bar-fill { height: 100%; background: var(--status-done, #2E7D3D); border-radius: 999px; }
.kc-subtask-count { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); flex-shrink: 0; }

.kc-checklist { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.45rem; }
.kc-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
}
.kc-checklist-item input[type="checkbox"] { margin-top: 0.18rem; flex-shrink: 0; cursor: pointer; }
.kc-checklist-item span { word-break: break-word; }
.kc-checklist-item.done span { color: var(--muted); text-decoration: line-through; }

/* ---------- Subtask editor (in modal) ---------- */

.subtask-editor-list { display: flex; flex-direction: column; gap: 0.4rem; }
.subtask-editor-row { display: flex; align-items: center; gap: 0.4rem; }
.subtask-editor-row .se-done { flex-shrink: 0; cursor: pointer; }
.subtask-editor-row .se-text {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  background: #fff;
}
.subtask-editor-row .se-text:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.subtask-editor-row .se-remove {
  flex-shrink: 0;
  padding: 0.15rem 0.5rem;
  line-height: 1;
  font-size: 0.9rem;
}

/* ---------- Marker size field ---------- */
.range-row { display: flex; align-items: center; gap: 0.6rem; }
.range-row input[type="range"] { flex: 1; }
.range-row .range-val { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); width: 34px; text-align: right; }