/* ── Design tokens ─────────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #17203a;
  --muted: #667085;
  --line: #e6e9f2;
  --brand: #2348c8;
  --brand-dark: #16265e;
  --sidebar: #0e1a3a;
  --sidebar-ink: #aeb9d8;
  --sidebar-active: #1d2f63;
  --green: #12805c; --green-bg: #e4f5ee;
  --red: #c23434; --red-bg: #fbeaea;
  --amber: #a96800; --amber-bg: #fdf3e2;
  --blue: #1d5fd1; --blue-bg: #e8f0fd;
  --purple: #6c3fd1; --purple-bg: #f1ebfd;
  --orange: #c2540a; --orange-bg: #fdefe6;
  --gray: #5b6474; --gray-bg: #eef0f5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell ─────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
  overflow-y: auto; z-index: 40; transition: transform .25s ease;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b64f0, #16265e); color: #fff; font-weight: 800; letter-spacing: .5px;
}
.brand-name { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.25; }
.brand-sub { font-size: 11.5px; color: var(--sidebar-ink); }
.nav { padding: 14px 12px; flex: 1; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: #6c7ca6; margin: 18px 10px 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0;
  color: var(--sidebar-ink); border-radius: 9px; font-size: 13.5px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.chip-role { font-size: 12px; color: #9fb0d8; background: rgba(255,255,255,.07); padding: 6px 10px; border-radius: 8px; text-align: center; }

.main { flex: 1; margin-left: 264px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.page-title { font-weight: 700; font-size: 17px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  border: none; background: transparent; font-size: 19px; cursor: pointer; color: var(--muted);
  position: relative; padding: 6px;
}
.icon-btn:hover { color: var(--ink); }
.bell-dot {
  position: absolute; top: 0; right: -2px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.user-meta { line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); }
.content { padding: 26px 28px 60px; max-width: 1360px; width: 100%; }

/* ── Auth ──────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% -10%, #2b4bd8 0%, #16265e 45%, #0e1a3a 100%);
}
.auth-card {
  width: 420px; max-width: 92vw; background: var(--surface); border-radius: 20px;
  padding: 36px 34px; box-shadow: 0 24px 70px rgba(6,14,40,.4);
}
.auth-logo { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.auth-logo .brand-mark { width: 46px; height: 46px; }
.auth-title { font-size: 22px; font-weight: 800; }
.auth-sub { color: var(--muted); margin: 4px 0 24px; }

/* ── Cards & grid ──────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 700; font-size: 15px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr);} .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 760px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ── Stat tiles ────────────────────────────────────────── */
.stat { padding: 18px 20px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 27px; font-weight: 800; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .stat-ico { float: right; font-size: 22px; opacity: .35; }

/* ── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; padding: 11px 16px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line);
  background: #fafbfe; white-space: nowrap;
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafbfe; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--muted); }

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  border-radius: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; font-family: var(--font); transition: .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #1c3aa8; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f2f4fa; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-warn { background: #fff; color: var(--orange); border-color: #f3c89f; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────── */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field label .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid #d4d9e6; border-radius: 9px;
  font-size: 14px; font-family: var(--font); background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35,72,200,.12); }
textarea.input { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.inline-form { display: inline; }

/* ── Flash ─────────────────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--green-bg); color: var(--green); border-color: #bfe6d5; }
.flash-error { background: var(--red-bg); color: var(--red); border-color: #f1c4c4; }
.flash-info { background: var(--blue-bg); color: var(--blue); border-color: #c3d6f5; }

/* ── Pipeline / lifecycle tracker ─────────────────────── */
.pipeline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pipe-stage {
  display: flex; flex-direction: column; align-items: center; min-width: 92px;
  padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.pipe-stage .n { font-size: 20px; font-weight: 800; }
.pipe-stage .l { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pipe-arrow { color: #b8c0d4; font-size: 15px; }
.pipe-stage.hot { border-color: #f0b48c; background: var(--orange-bg); }
.pipe-stage.done { border-color: #9fd8c0; background: var(--green-bg); }

.step-track { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.step-pill {
  padding: 5px 11px; border-radius: 999px; background: var(--gray-bg); color: var(--gray); font-weight: 600;
}
.step-pill.done { background: var(--green-bg); color: var(--green); }
.step-pill.now { background: var(--blue-bg); color: var(--blue); box-shadow: 0 0 0 2px rgba(29,95,209,.2); }
.step-pill.bad { background: var(--red-bg); color: var(--red); }
.step-sep { color: #c4cbdd; }

/* ── Description list ─────────────────────────────────── */
.dl { display: grid; grid-template-columns: 200px 1fr; row-gap: 10px; column-gap: 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }
@media (max-width: 640px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }

/* ── Misc ──────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mono { font-family: "Consolas", "Courier New", monospace; font-size: 12.5px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; }
.bar { background: var(--gray-bg); border-radius: 6px; height: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 90px; gap: 10px; align-items: center; margin: 7px 0; font-size: 12.5px; }
.score-cell { font-variant-numeric: tabular-nums; font-weight: 600; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px 8px; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line);
}
.tl-item.dim::before { background: #c4cbdd; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-sub { font-size: 12px; color: var(--muted); }

.kbd { background: var(--gray-bg); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.doc-tree { font-family: "Consolas", monospace; font-size: 12.5px; line-height: 1.7; white-space: pre; }

/* ── Responsive sidebar ───────────────────────────────── */
#menuToggle { display: none; }
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  #menuToggle { display: block; }
  .content { padding: 18px 14px 50px; }
  .user-meta { display: none; }
}
