/* DHEP CIO Command Center — purple continuous with landing */
:root {
  --accent: #6b46c1;
  --accent-2: #8b6df0;
  --accent-soft: #ede7fa;
  --accent-mist: #f7f3fd;
  --accent-deep: #4c2db8;
  --bg: #faf8f5;
  --bg-tint: #f3eef7;
  --surface: #ffffff;
  --ink: #14101f;
  --ink-2: #4a4458;
  --ink-3: #7a7488;
  --line: #e8e2f0;
  --line-2: #d8d0e6;
  --gold: #b88a3a;
  --amber: #c47a2c;
  --ok: #2e8a5e;
  --warn: #c47a2c;
  --err: #b8324a;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px;
  --shadow-1: 0 1px 2px rgba(20,16,31,.06);
  --shadow-2: 0 8px 24px rgba(76,45,184,.10);
  --shadow-3: 0 24px 60px rgba(76,45,184,.18);

  --f-display: "General Sans", system-ui, sans-serif;
  --f-body: "Satoshi", system-ui, sans-serif;
  --f-serif: "Instrument Serif", Georgia, serif;
  --f-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--f-body);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.vh { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); margin-left: 6px; font-weight: 500; }
.micro { font-size: 12px; }
.error { color: var(--err); font-size: 13px; margin-top: 8px; }

/* ─── Login gate ─── */
.gate {
  position: fixed; inset: 0;
  background: radial-gradient(60% 60% at 20% 0%, var(--accent-soft) 0%, transparent 60%),
              radial-gradient(50% 50% at 100% 100%, var(--bg-tint) 0%, transparent 60%),
              var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 32px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-3);
}
.gate h1 { font: 600 28px/1.2 var(--f-display); margin: 16px 0 6px; }
.gate p { margin: 0 0 18px; }
.gate input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--bg);
  font: 500 16px/1 var(--f-body); letter-spacing: 0.06em;
}
.gate input + input { margin-top: 10px; }
.gate input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent-deep); font: 700 18px/1 var(--f-display); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-md); padding: 10px 16px;
  font: 600 14px/1 var(--f-display); cursor: pointer; transition: all .12s ease;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.btn:hover { box-shadow: var(--shadow-1); transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); box-shadow: var(--shadow-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; color: var(--err); border-color: rgba(184,50,74,.3); }
.btn.link { background: transparent; border: 0; color: var(--ink-2); padding: 8px; }
.btn.link:hover { color: var(--ink); }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: var(--r-sm); }

/* ─── App shell ─── */
#app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 0 6px 4px; color: var(--accent-deep); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 0; background: transparent; border-radius: var(--r-md);
  color: var(--ink-2); font: 600 14px/1 var(--f-display);
  cursor: pointer; text-align: left;
}
.nav-btn .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
.nav-btn:hover { background: var(--accent-mist); color: var(--ink); }
.nav-btn[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-deep); }
.nav-btn[aria-selected="true"] .dot { background: var(--accent); }
.sidebar-foot { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ─── Main area ─── */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: rgba(250,248,245,.85);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.search-wrap { flex: 1; max-width: 520px; }
#search {
  width: 100%; padding: 10px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  font: 400 14px/1 var(--f-body);
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; gap: 8px; }
.filters select {
  padding: 9px 12px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); font: 500 13px/1 var(--f-display); color: var(--ink); cursor: pointer;
}
.view { padding: 24px; flex: 1; }

/* ─── Dashboard ─── */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1);
}
.card h2 { font: 600 13px/1 var(--f-display); margin: 0 0 12px;
           color: var(--ink-3); text-transform: uppercase; letter-spacing: .12em; }
.card h3 { font: 600 16px/1.3 var(--f-display); margin: 0 0 8px; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; grid-column: span 12; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.kpi .value { font: 600 32px/1.05 var(--f-display); color: var(--ink); margin-top: 6px; }
.kpi .delta { font-size: 12px; color: var(--accent-deep); margin-top: 6px; }

.phase-list { display: grid; gap: 10px; }
.phase-row { display: grid; grid-template-columns: 36px 1fr 60px; gap: 12px; align-items: center; }
.phase-tag { font: 700 11px/1 var(--f-mono); padding: 4px 6px; border-radius: 6px; color: white; text-align: center; }
.phase-bar { height: 8px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; position: relative; }
.phase-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.phase-count { text-align: right; font: 600 13px/1 var(--f-mono); color: var(--ink-2); }

.today-list { display: grid; gap: 8px; }
.today-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center;
              padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); cursor: pointer; background: var(--surface); }
.today-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.today-id { font: 600 11px/1 var(--f-mono); color: var(--accent-deep); }
.today-title { font: 500 14px/1.3 var(--f-display); color: var(--ink); }
.priority-chip { font: 700 10px/1 var(--f-mono); padding: 3px 6px; border-radius: 4px; }
.priority-chip.P1 { background: rgba(184,50,74,.1); color: var(--err); }
.priority-chip.P2 { background: rgba(196,122,44,.1); color: var(--amber); }
.priority-chip.P3 { background: rgba(74,68,88,.1); color: var(--ink-2); }

.pulse-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
             padding: 10px 0; border-bottom: 1px solid var(--line); }
.pulse-row:last-child { border: 0; }
.stage-bar { display: flex; gap: 4px; }
.stage-cell {
  width: 30px; height: 18px; border-radius: 4px;
  background: var(--accent-soft); display: grid; place-items: center;
  font: 700 9px/1 var(--f-mono); color: var(--ink-3);
}
.stage-cell.active { background: var(--accent); color: white; }
.stage-cell.done { background: var(--ok); color: white; }
.stage-cell.failed { background: var(--err); color: white; }

/* ─── Board ─── */
.board { display: grid; grid-template-columns: repeat(6, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 20px; }
.column {
  background: var(--bg-tint); border-radius: var(--r-lg); padding: 14px; min-height: 60vh;
  border: 1px solid var(--line);
}
.col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.col-head h3 { font: 600 13px/1 var(--f-display); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); margin: 0; }
.col-count { font: 700 11px/1 var(--f-mono); color: var(--ink-3); }
.col-list { display: grid; gap: 8px; min-height: 50px; }
.col-list.drag-over { background: var(--accent-mist); border-radius: var(--r-md); outline: 2px dashed var(--accent); }

.task-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px; cursor: grab; transition: all .12s ease;
}
.task-card:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.task-card.dragging { opacity: .4; }
.task-card .tc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-card .tc-id { font: 700 10px/1 var(--f-mono); color: var(--accent-deep); }
.task-card .tc-title { font: 500 13px/1.35 var(--f-display); margin: 6px 0; }
.task-card .tc-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.phase-pill { font: 700 9px/1 var(--f-mono); padding: 3px 5px; border-radius: 4px; color: white; }

/* ─── Task list table ─── */
.list-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table th { text-align: left; font: 600 11px/1 var(--f-display); text-transform: uppercase;
                 letter-spacing: .1em; color: var(--ink-3); padding: 12px; border-bottom: 1px solid var(--line); background: var(--bg-tint); }
.list-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list-table tr { cursor: pointer; }
.list-table tr:hover td { background: var(--accent-mist); }
.list-table td.id { font: 600 11px/1 var(--f-mono); color: var(--accent-deep); }
.list-table td.title { font: 500 14px/1.3 var(--f-display); max-width: 460px; }
.status-pill { font: 700 10px/1 var(--f-mono); padding: 4px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-deep); text-transform: uppercase; letter-spacing: .06em; }
.status-pill.done { background: rgba(46,138,94,.12); color: var(--ok); }
.status-pill.blocked { background: rgba(184,50,74,.12); color: var(--err); }
.status-pill.in_progress { background: var(--accent); color: white; }

/* ─── CI/CD view ─── */
.pipeline { display: grid; gap: 12px; }
.pipeline-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px;
  display: grid; grid-template-columns: 90px 1fr 360px; gap: 14px; align-items: center;
}
.pipeline-row .meta-id { font: 700 11px/1 var(--f-mono); color: var(--accent-deep); }
.pipeline-row .meta-title { font: 500 14px/1.3 var(--f-display); }
.pipeline-stages { display: flex; gap: 6px; align-items: center; }
.stage-pill {
  flex: 1; text-align: center; padding: 8px 6px; border-radius: 6px;
  font: 700 10px/1 var(--f-mono); background: var(--accent-soft); color: var(--ink-3);
  border: 1px solid transparent;
}
.stage-pill.active { background: var(--accent); color: white; box-shadow: 0 0 0 3px rgba(107,70,193,.18); }
.stage-pill.done { background: rgba(46,138,94,.15); color: var(--ok); border-color: rgba(46,138,94,.3); }
.stage-pill.failed { background: rgba(184,50,74,.12); color: var(--err); border-color: rgba(184,50,74,.3); }

/* ─── Drawer ─── */
[hidden] { display: none !important; }
.drawer { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: 1fr min(640px, 100%); }
.drawer-backdrop { background: rgba(20,16,31,.42); }
.drawer-panel {
  background: var(--surface); height: 100vh; overflow-y: auto;
  padding: 26px 28px; box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; gap: 14px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer h2 { font: 600 22px/1.25 var(--f-display); margin: 0; }
.drawer .id-line { font: 600 11px/1 var(--f-mono); color: var(--accent-deep); margin-bottom: 6px; }
.drawer .meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.drawer .meta-grid label { font: 600 10px/1 var(--f-display); color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.drawer .meta-grid select, .drawer .meta-grid input {
  width: 100%; padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--line);
  font: 500 13px/1 var(--f-body); background: var(--surface);
}
.drawer textarea {
  width: 100%; min-height: 200px; padding: 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg-tint);
  font: 400 13px/1.55 var(--f-mono); resize: vertical;
}
.drawer textarea.title-input { min-height: 0; padding: 8px 10px; font-family: var(--f-display); font-size: 18px; font-weight: 600; }
.ac-list { padding-left: 20px; margin: 6px 0; }
.ac-list li { margin: 4px 0; color: var(--ink-2); }
.drawer .deps { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip { font: 600 10px/1 var(--f-mono); padding: 4px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-deep); cursor: pointer; }
.dep-chip:hover { background: var(--accent); color: white; }
.section { border-top: 1px solid var(--line); padding-top: 14px; }
.section h3 { font: 600 12px/1 var(--f-display); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; align-items: center; }

/* ─── Settings ─── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 920px; }
.settings-grid .card { padding: 22px; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: white; padding: 12px 18px;
  border-radius: var(--r-md); box-shadow: var(--shadow-3); z-index: 100;
  font: 500 13px/1 var(--f-body);
}

/* ─── Responsive ─── */
@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav-btn { padding: 8px 10px; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; border: 0; padding: 0; }
  .sidebar-foot .btn { width: auto; margin: 0; }
  .topbar { flex-wrap: wrap; padding: 12px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid > .card { grid-column: span 12 !important; }
  .board { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
  .pipeline-row { grid-template-columns: 1fr; }
  .drawer { grid-template-columns: 0 1fr; }
}

/* ============ Gate (login / first-run / recovery / reset) ============ */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background:
  radial-gradient(1200px 600px at 20% 10%, rgba(107,70,193,0.10), transparent 60%),
  radial-gradient(900px 500px at 80% 90%, rgba(237,231,250,0.20), transparent 60%); }
.gate-card { width: 100%; max-width: 460px; background: var(--bg-elev, #fff); border: 1px solid var(--border, #e6e3ee);
  border-radius: 18px; padding: 32px; box-shadow: 0 30px 60px -20px rgba(40,20,80,0.25); }
.gate-card .brand-line { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 600; }
.gate-card .logo-dot { width: 14px; height: 14px; border-radius: 50%; background: #6b46c1; box-shadow: 0 0 0 4px rgba(107,70,193,0.12); }
.gate-card h1 { font-family: 'Instrument Serif', Georgia, serif; font-style: italic; font-size: 32px; line-height: 1.1; margin: 0 0 6px; }
.gate-card p.muted { margin: 0 0 18px; color: var(--muted, #6b6480); }
.gate-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.gate-card form input[type="password"], .gate-card form input[type="email"], .gate-card form input[type="text"] {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border, #e6e3ee);
  background: #fff; font-size: 15px; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.gate-card form input:focus { outline: none; border-color: #6b46c1; box-shadow: 0 0 0 3px rgba(107,70,193,0.15); }
.gate-card form button { padding: 12px 14px; border-radius: 12px; font-weight: 600; cursor: pointer; }
.gate-card .err { color: #b42318; font-size: 14px; min-height: 18px; margin: 4px 0 0; }
.gate-card .check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--muted, #6b6480); margin: 8px 0; cursor: pointer; }
.gate-card .check input { margin-top: 3px; }
.gate-card .recovery-code { font-family: 'JetBrains Mono', 'Menlo', monospace; font-size: 15px; letter-spacing: 0.5px;
  background: #f7f5fc; border: 1px dashed #c9bfe6; border-radius: 12px; padding: 14px 16px; margin: 12px 0;
  word-break: break-all; user-select: all; }
.gate-card .gate-links { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; margin-top: 14px;
  font-size: 14px; }
.gate-card .gate-links a, .gate-card .gate-links button.link { background: none; border: 0; padding: 0; color: #6b46c1;
  cursor: pointer; text-decoration: underline; font: inherit; }
.gate-card .micro { font-size: 12px; color: var(--muted, #6b6480); margin-top: 14px; }

/* ============ Phones (≤640px) ============ */
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: 100%; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-card .kpi-value { font-size: 24px; }
  .board { grid-template-columns: 1fr; }
  .list-table { font-size: 13px; }
  .list-table td.title { max-width: 100%; }
  .list-table th:nth-child(4), .list-table td:nth-child(4),
  .list-table th:nth-child(5), .list-table td:nth-child(5) { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .drawer .drawer-panel { width: 100vw; max-width: 100vw; }
  .sidebar { padding: 10px; }
  .brand-line, .brand { font-size: 14px; }
  .gate-card { padding: 24px 20px; border-radius: 14px; }
  .gate-card h1 { font-size: 26px; }
  .pipeline-card { padding: 14px; }
}
