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

:root {
  --p:  #060852;
  --p2: #1a1875;
  --p3: #3730a3;
  --p4: #a5b4fc;
  --p5: #e0e7ff;
  --bg: #f8f8f8;
  --s:  #ffffff;
  --bd: #dde1f5;
  --t:  #1e293b;
  --m:  #6b7280;
  /* Status colours are reserved for document and run state, always paired with a label. */
  --ok-bg: #dcfce7;   --ok-fg: #166534;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad-bg: #fee2e2;  --bad-fg: #991b1b;
  --mute-bg: #f1f5f9; --mute-fg: #475569;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--t);
  background: var(--bg);
}
a { color: var(--p3); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; color: var(--p); margin: 0; }
h2 { font-size: 15px; font-weight: 600; color: var(--p); margin: 0 0 .75rem; }
h3 { font-size: 13px; font-weight: 600; margin: 1rem 0 .4rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: 'DM Mono', ui-monospace, monospace; font-size: 12.5px; }
.muted { color: var(--m); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
#sidebar { background: var(--p); width: 240px; flex: 0 0 240px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
#sidebar-header { background: #fff; border-bottom: 3px solid var(--p); padding: 1rem 1.1rem; }
#sidebar-header .client { margin-top: .5rem; font-size: 11px; color: var(--m); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
#sidebar nav { padding: .9rem .7rem; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 700; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .8px; padding: .8rem .6rem .25rem; }
.chip { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.06); color: rgba(255,255,255,.75); transition: all .15s; }
.chip:hover { background: rgba(255,255,255,.13); color: #fff; text-decoration: none; }
.chip.active { background: rgba(165,180,252,.18); border-color: rgba(165,180,252,.45); color: #fff; }
.chip .count { font-size: 11px; font-weight: 700; background: rgba(255,255,255,.14); color: #fff; padding: 1px 7px; border-radius: 20px; }
.chip .count.alert { background: #fde68a; color: #78350f; }
#sidebar-footer { padding: .8rem .7rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
#sidebar-footer .small { color: rgba(255,255,255,.5); padding: 0 .6rem .5rem; }

main { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; max-width: 1280px; }
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.section-label { font-size: 11px; color: var(--m); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

/* ---- components ---- */
.card { background: var(--s); border: 1px solid var(--bd); border-radius: 14px; padding: 1.25rem 1.5rem; box-shadow: 0 1px 3px rgba(6,8,82,.05); margin-bottom: 1.25rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 1.1rem 1.5rem 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.25rem; }
.grid .card { margin-bottom: 0; }

.tile { display: block; background: var(--s); border: 1px solid var(--bd); border-radius: 14px; padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(6,8,82,.05); color: var(--t); transition: all .15s; }
a.tile:hover { border-color: var(--p4); text-decoration: none; }
.tile .label { font-size: 11px; font-weight: 600; color: var(--m); text-transform: uppercase; letter-spacing: .6px; }
.tile .value { font-size: 32px; font-weight: 700; color: var(--p); line-height: 1.15; margin-top: .3rem; }
.tile .hint { font-size: 12px; color: var(--m); margin-top: .2rem; }
.tile.alert { border-left: 4px solid #d97706; }

.btn, .btn-primary { display: inline-flex; align-items: center; gap: .4rem; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .5rem 1rem; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--p); color: #fff; border: 1.5px solid var(--p); }
.btn-primary:hover { background: var(--p2); border-color: var(--p2); text-decoration: none; }
.btn { background: var(--s); color: var(--t); border: 1.5px solid var(--bd); }
.btn:hover { background: var(--p5); border-color: var(--p4); text-decoration: none; }
.btn.danger { color: var(--bad-fg); }
.btn.sm, .btn-primary.sm { padding: .3rem .7rem; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; background: var(--p5); color: var(--p3); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge.mute { background: var(--mute-bg); color: var(--mute-fg); }

.info-banner { background: var(--p5); border-left: 3px solid var(--p3); border-radius: 8px; padding: .85rem 1rem; font-size: 13px; color: var(--p2); margin-bottom: 1.25rem; }
.info-banner.ok { background: var(--ok-bg); border-left-color: var(--ok-fg); color: var(--ok-fg); }
.info-banner.error { background: var(--bad-bg); border-left-color: var(--bad-fg); color: var(--bad-fg); }
.info-banner.warn { background: var(--warn-bg); border-left-color: #d97706; color: var(--warn-fg); }
.info-banner ul { margin: .4rem 0 0; padding-left: 1.2rem; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--m); text-transform: uppercase; letter-spacing: .5px; padding: .6rem .75rem; border-bottom: 1px solid var(--bd); background: #fbfbfe; white-space: nowrap; }
td { padding: .6rem .75rem; border-bottom: 1px solid #eef0fa; vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafaff; }
th.right, td.right { text-align: right; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 1.5rem; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 1.5rem; }
.table-wrap { overflow-x: auto; }
.empty { padding: 2rem 1.5rem; text-align: center; color: var(--m); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem 1.5rem; }
.facts dt { font-size: 11px; font-weight: 600; color: var(--m); text-transform: uppercase; letter-spacing: .5px; }
.facts dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }

.issues { list-style: none; margin: 0; padding: 0; }
.issues li { display: flex; gap: .6rem; align-items: baseline; padding: .45rem 0; border-bottom: 1px solid #eef0fa; }
.issues li:last-child { border-bottom: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid #eef0fa; }
.timeline li:last-child { border-bottom: none; }
.timeline .when { font-size: 12px; color: var(--m); white-space: nowrap; }
.timeline .error { color: var(--bad-fg); }
.timeline .warning { color: var(--warn-fg); }

pre.file { background: #0b0d3a; color: #e0e7ff; border-radius: 10px; padding: 1rem; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-all; margin: 0; }
details { margin-top: .5rem; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--p3); }
details pre { margin-top: .6rem; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--t); margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--bd); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13.5px; color: var(--t); padding: .5rem .7rem; background: #fff; transition: all .15s; }
textarea { font-family: 'DM Mono', ui-monospace, monospace; font-size: 12.5px; min-height: 140px; }
input:focus, select:focus, textarea:focus { border-color: var(--p3); box-shadow: 0 0 0 3px rgba(55,48,163,.1); outline: none; }
.field { margin-bottom: 1rem; }
.field .help { font-size: 12px; color: var(--m); margin-top: .3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1.25rem; }
.switch { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid #eef0fa; }
.switch:last-child { border-bottom: none; }
.switch input { margin-top: .2rem; width: 16px; height: 16px; accent-color: var(--p3); }
.switch label { margin: 0; font-size: 13.5px; }
.switch .help { font-size: 12px; color: var(--m); font-weight: 400; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 150px; }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: 1rem 1.5rem; border-bottom: 1px solid var(--bd); }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.5rem; border-top: 1px solid var(--bd); font-size: 12.5px; color: var(--m); }

.status-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid #eef0fa; }
.status-row:last-child { border-bottom: none; }
.status-row .name { font-weight: 600; }
.status-row .desc { font-size: 12px; color: var(--m); }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  #sidebar { width: 100%; flex: none; height: auto; position: static; }
  #sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  main { padding: 1.25rem 1rem 2rem; }
  .timeline li { grid-template-columns: 1fr; gap: 0; }
}
