/* ===========================================================================
   Kanari Suite — application stylesheet.

   Hand-written and shipped compiled: shared hosts have no build step, so
   there is no Tailwind pipeline to run and no npm install to forget.
   Brand tokens are overridden at runtime from the settings registry, so
   changing a colour never needs a deploy (FR-CMS-04).
   ======================================================================== */

:root {
  --brand:          #0d6156;
  --brand-ink:      #094a41;
  --brand-soft:     #e0efeb;
  --accent:         #b23a22;
  --accent-soft:    #f8e8e3;

  --ground:         #f7f5f1;
  --panel:          #ffffff;
  --panel-2:        #f1eee8;
  --rule:           #ddd8cc;
  --rule-soft:      #e9e5dc;

  --ink:            #1c2320;
  --ink-2:          #4f574f;
  --ink-3:          #7d857c;

  --ok:             #3d6b2c;
  --ok-soft:        #e7efe0;
  --warn:           #97640f;
  --warn-soft:      #f9efdb;
  --danger:         #a03028;
  --danger-soft:    #f9e5e2;
  --info:           #2c5c78;
  --info-soft:      #e4eef4;

  --sans: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 3px;
  --shadow: 0 1px 2px rgba(28, 35, 32, .07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand:       #4fbfa9;
    --brand-ink:   #8fdccb;
    --brand-soft:  #14302b;
    --accent:      #e08363;
    --accent-soft: #33211a;

    --ground:      #14171a;
    --panel:       #1b1f22;
    --panel-2:     #23282c;
    --rule:        #333a3f;
    --rule-soft:   #282e32;

    --ink:         #e8eae6;
    --ink-2:       #a7afaa;
    --ink-3:       #79817b;

    --ok:          #8fc172;
    --ok-soft:     #1f2c19;
    --warn:        #d9a44d;
    --warn-soft:   #322817;
    --danger:      #e08379;
    --danger-soft: #341f1c;
    --info:        #7fb2cf;
    --info-soft:   #1b2830;

    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.012em; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 12px; }

code, .mono { font-family: var(--mono); font-size: .88em; }
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- structure */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--panel-2);
  border-right: 1px solid var(--rule);
  padding: 18px 14px 40px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  font-weight: 800; font-size: 13px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink); padding: 0 8px 2px;
}
.sidebar .brand em { color: var(--brand); font-style: normal; }
.sidebar .tenant {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  padding: 0 8px 18px; word-break: break-word;
}
.nav-group {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 8px 5px;
}
.nav-item {
  display: block; padding: 6px 9px; border-radius: var(--radius);
  color: var(--ink-2); font-size: 13.5px; border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
  background: var(--panel); color: var(--ink); font-weight: 600;
  border-left-color: var(--brand);
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--rule); background: var(--panel);
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--ink-3); }

.content { padding: 22px clamp(16px, 3vw, 32px) 64px; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }
.page-head p { color: var(--ink-2); max-width: 72ch; margin: 6px 0 0; }

/* ----------------------------------------------------------------- cards */

.panel {
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel__head {
  padding: 11px 16px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0;
}
.panel__head .spacer { flex: 1; }
.panel__head h2 { font-size: 14px; }
.panel__body { padding: 16px; }
.panel__body--flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 13px 15px; }
.stat .label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: 5px;
}
.stat .value { font-family: var(--mono); font-size: 25px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--ink-3); }
.stat--warn { border-color: var(--warn); }
.stat--danger { border-color: var(--danger); }
.stat--danger .value { color: var(--danger); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3);
  padding: 9px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap;
  background: var(--panel-2); position: sticky; top: 0;
}
table.data td { padding: 8px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data .sub { font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 2px; white-space: nowrap;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--rule);
}
.badge--ok      { background: var(--ok-soft);     color: var(--ok);     border-color: var(--ok); }
.badge--warn    { background: var(--warn-soft);   color: var(--warn);   border-color: var(--warn); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.badge--info    { background: var(--info-soft);   color: var(--info);   border-color: var(--info); }
.badge--brand   { background: var(--brand-soft);  color: var(--brand-ink); border-color: var(--brand); }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--ink);
}
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.45; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], input[type="file"], select, textarea {
  width: 100%; padding: 7px 10px; font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 2px var(--brand-soft); }
input[type="color"] { width: 54px; height: 32px; padding: 2px; border: 1px solid var(--rule); background: var(--panel); border-radius: var(--radius); }
textarea { min-height: 74px; resize: vertical; }
input[disabled], select[disabled] { background: var(--panel-2); color: var(--ink-3); }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.check input { margin-top: 3px; flex: none; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--tight { gap: 6px; }
.row .spacer { flex: 1; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block; font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.93); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 4px 9px; font-size: 12px; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* -------------------------------------------------------------- messages */

.alert {
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
  border-left: 3px solid var(--ink-3); background: var(--panel-2); font-size: 13.5px;
}
.alert--success { border-left-color: var(--ok);     background: var(--ok-soft);     color: var(--ok); }
.alert--error   { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.alert--warning { border-left-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }
.alert--info    { border-left-color: var(--info);   background: var(--info-soft);   color: var(--info); }
.alert strong { font-weight: 700; }
.alert code { background: rgba(0,0,0,.05); padding: 1px 4px; border-radius: 2px; }

/* ------------------------------------------------------------- installer */

.installer { max-width: 760px; margin: 0 auto; padding: 40px 22px 80px; }
.installer__mark {
  font-weight: 800; font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 6px;
}
.installer h1 { font-size: 26px; margin-bottom: 8px; }
.installer .lede { color: var(--ink-2); font-size: 15px; max-width: 62ch; }

.steps { display: flex; flex-wrap: wrap; gap: 0; margin: 26px 0 24px; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.steps .step {
  flex: 1 1 90px; padding: 8px 10px; font-size: 11.5px; text-align: center;
  border-right: 1px solid var(--rule); background: var(--panel); color: var(--ink-3);
}
.steps .step:last-child { border-right: 0; }
.steps .step.is-done { background: var(--brand-soft); color: var(--brand-ink); }
.steps .step.is-current { background: var(--brand); color: #fff; font-weight: 700; }

.check-list { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.check-list__row {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start;
  padding: 9px 13px; border-bottom: 1px solid var(--rule-soft); background: var(--panel); font-size: 13px;
}
.check-list__row:last-child { border-bottom: 0; }
.check-list__row .mark { font-weight: 700; }
.check-list__row.is-ok   .mark { color: var(--ok); }
.check-list__row.is-fail .mark { color: var(--danger); }
.check-list__row .fix { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }
.check-list__row .actual { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--rule); }
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .25s ease; }
@media (prefers-reduced-motion: reduce) { .progress > i { transition: none; } }

.log-box {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65; background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 12px 14px; max-height: 260px; overflow: auto; white-space: pre-wrap; color: var(--ink-2);
}

/* ------------------------------------------------------------ public page */

.public { max-width: 620px; margin: 0 auto; padding: 44px 22px 80px; }
.verdict {
  border: 2px solid var(--rule); border-radius: var(--radius);
  padding: 18px 20px; background: var(--panel); margin-bottom: 18px;
}
.verdict__label { font-size: 19px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.verdict__note { color: var(--ink-2); margin: 7px 0 0; font-size: 13.5px; }
.verdict--ok      { border-color: var(--ok); }
.verdict--ok      .verdict__label { color: var(--ok); }
.verdict--danger  { border-color: var(--danger); }
.verdict--danger  .verdict__label { color: var(--danger); }
.verdict--warn    { border-color: var(--warn); }
.verdict--warn    .verdict__label { color: var(--warn); }
.verdict--info    { border-color: var(--info); }
.verdict--info    .verdict__label { color: var(--info); }

.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th { text-align: left; font-weight: 500; color: var(--ink-3); padding: 6px 0; width: 42%; vertical-align: top; }
.kv td { padding: 6px 0; font-weight: 600; }

.masked { background: var(--panel-2); border: 1px dashed var(--rule); border-radius: var(--radius); padding: 13px 15px; margin-top: 14px; }
.masked .lockline { font-size: 12.5px; color: var(--ink-3); margin-bottom: 9px; }
.masked .blur { color: var(--ink-3); letter-spacing: .16em; font-family: var(--mono); }

/* ----------------------------------------------------------------- misc */

.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.divider { height: 1px; background: var(--rule); margin: 14px 0; border: 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

.matrix-wrap { overflow: auto; max-height: 70vh; }
table.matrix { border-collapse: collapse; font-size: 12.5px; width: 100%; }
table.matrix th, table.matrix td { border: 1px solid var(--rule-soft); padding: 5px 8px; }
table.matrix thead th { position: sticky; top: 0; background: var(--panel-2); z-index: 2; font-size: 11px; }
table.matrix tbody th {
  position: sticky; left: 0; background: var(--panel); text-align: left; font-weight: 500;
  font-family: var(--mono); font-size: 11px; white-space: nowrap; z-index: 1;
}
table.matrix td { text-align: center; }
table.matrix tr.module-head th { background: var(--panel-2); font-family: var(--sans); font-weight: 700; font-size: 11.5px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sidebar .nav-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  body { background: #fff; }
}
