/* =====================================================================
   PROJECT-SHARDANI · design system
   Dark-first, high-contrast, no external fonts or CDNs: the application must
   work on a locked-down shared host and behind strict CSP.
   ===================================================================== */

:root {
  --bg:        #0b0f14;
  --bg-2:      #10161e;
  --panel:     #141b24;
  --panel-2:   #1a232e;
  --line:      #223040;
  --text:      #e6edf3;
  --muted:     #8ea1b4;
  --accent:    #4fb8a8;
  --accent-2:  #7ad9c9;
  --danger:    #e5686f;
  --warn:      #e3b341;
  --ok:        #58c08a;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 18px 40px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f3f6;
  --line: #dde3ea;
  --text: #10161e;
  --muted: #5b6b7c;
  --shadow: 0 12px 28px rgba(16, 22, 30, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

h1, h2, h3 { line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 .4rem; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 0 0 .35rem; }
p  { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.mono  { font-family: var(--mono); }

/* ---------------------------------------------------------------- header */
.public { display: flex; flex-direction: column; min-height: 100vh; }

.public-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: inline-block;
  background: conic-gradient(from 140deg, var(--accent), #2b6d8f, var(--accent-2), var(--accent));
  box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(79, 184, 168, .25);
}
.brand-text strong { display: block; font-size: 1rem; }
.brand-text small { display: block; color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.public-nav a { margin-left: 1rem; font-weight: 550; }

.public-main { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 4vw, 3rem); }
.public-footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--line);
  color: var(--muted); font-size: .82rem;
}

/* ------------------------------------------------------------------ hero */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; margin-bottom: .6rem; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 46ch; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0 1.25rem; }
.hero-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; color: var(--muted); font-size: .92rem; }
.hero-facts span { color: var(--accent); margin-right: .5rem; }

.hero-art { display: flex; justify-content: center; }
.art-device {
  width: min(100%, 380px); border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2)); box-shadow: var(--shadow); overflow: hidden;
}
.art-bar { display: flex; gap: .4rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.art-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; }
.art-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: 1rem; }
.art-grid span {
  display: block; aspect-ratio: 4 / 3; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--panel-2)), var(--panel-2));
  border: 1px solid var(--line);
}
.art-caption { padding: .6rem 1rem 1rem; color: var(--muted); font-size: .78rem; }

/* -------------------------------------------------------------- sections */
.features, .how, .contact { margin-top: clamp(2.5rem, 6vw, 4.5rem); }
.section-lede { color: var(--muted); max-width: 68ch; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; }
.feature-icon { font-size: 1.35rem; color: var(--accent); margin-bottom: .5rem; }
.feature p { color: var(--muted); margin: 0; font-size: .93rem; }

.steps { list-style: none; counter-reset: step; margin: 1.5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.steps li { counter-increment: step; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; position: relative; }
.steps li::before {
  content: counter(step); position: absolute; top: -14px; left: 1.1rem;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #04120f; font-weight: 700; font-size: .85rem;
}
.steps p { color: var(--muted); margin: 0; font-size: .93rem; }

/* ---------------------------------------------------------------- forms */
label { display: block; margin-bottom: .9rem; }
label > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .35rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="search"], select, textarea {
  width: 100%; padding: .72rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  font-family: inherit; font-size: .95rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; transition: transform .06s ease, background .15s ease;
}
.btn:hover { background: var(--panel); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04120f; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #180708; }
.btn.small { padding: .4rem .7rem; font-size: .85rem; }

/* ------------------------------------------------------------ auth card */
.card {
  max-width: 460px; margin: 0 auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 2rem); box-shadow: var(--shadow);
}
.card h1 { font-size: 1.5rem; }
.card .lede { font-size: .95rem; }
.card-footer { margin-top: 1rem; font-size: .88rem; color: var(--muted); }

.alert { border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.alert.error   { border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.alert.notice  { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.alert.warning { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* --------------------------------------------------------- wizard steps */
.wizard { display: grid; grid-template-columns: 260px 1fr; gap: clamp(1.25rem, 3vw, 2.5rem); }
.wizard-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; align-content: start; }
.wizard-steps li { display: flex; gap: .65rem; align-items: center; padding: .55rem .7rem; border-radius: var(--radius-sm); color: var(--muted); font-size: .9rem; }
.wizard-steps li.current { background: var(--panel-2); color: var(--text); }
.wizard-steps li.done { color: var(--accent); }
.wizard-steps b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; border: 1px solid var(--line); }
.wizard-steps li.current b { background: var(--accent); color: #04120f; border-color: var(--accent); }

.wizard-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.1rem, 3vw, 1.8rem); }
.checklist { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .4rem; }
.checklist li { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; }
.checklist .mark { font-family: var(--mono); }
.checklist .ok .mark { color: var(--ok); }
.checklist .bad .mark { color: var(--danger); }
.checklist .optional { color: var(--muted); }

/* ------------------------------------------------------------ app shell */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 1rem .8rem; display: flex; flex-direction: column; gap: 1rem; }
.sidebar nav { display: grid; gap: .15rem; }
.sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--muted); font-size: .92rem; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--panel); color: var(--text); }
.sidebar .group-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: .8rem .6rem .2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem clamp(1rem, 3vw, 1.75rem); border-bottom: 1px solid var(--line); background: var(--bg-2); }
.content { padding: clamp(1rem, 3vw, 1.75rem); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; }
.stat .value { font-size: 1.5rem; font-weight: 650; margin-top: .25rem; }

.bar { height: 9px; border-radius: 99px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar.warn > i { background: linear-gradient(90deg, var(--warn), #f0cf7a); }
.bar.danger > i { background: linear-gradient(90deg, var(--danger), #f0909a); }

table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th, table.grid td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
table.grid th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 99px; font-size: .74rem; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

.droppable { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--muted); }
.droppable.hot { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.media-grid figure { margin: 0; position: relative; border-radius: var(--radius-sm); overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.media-grid figcaption { font-size: .72rem; color: var(--muted); padding: .35rem .45rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .wizard { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; gap: .25rem; }
  .sidebar .group-title { display: none; }
  .brand-text small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Brand, installer and diagnostics
   Added with the installation work: the logo lockup, the requirement audit,
   the database test panel and the diagnostics report.
   ===================================================================== */

/* ------------------------------------------------------------------ brand */
.brand-logo {
  height: 46px;
  width: auto;
  display: block;
}
.public-header .brand { gap: .4rem; padding: .2rem .3rem; border-radius: var(--radius-sm); }
.public-header .brand:hover .brand-logo { filter: brightness(1.08); }

/* -------------------------------------------------------------- installer */
.wizard-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.wizard-head .eyebrow { margin: 0; }
.wizard-head h1 { margin: 0; flex: 1 1 auto; }

.audit-summary {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1rem 0 1.5rem;
}
.audit-score {
  display: flex;
  align-items: baseline;
  gap: .15rem;
  font-weight: 700;
  line-height: 1;
}
.audit-score strong { font-size: 2.4rem; letter-spacing: -.02em; }
.audit-score span { color: var(--muted); font-size: .95rem; }
.audit-score.ok strong { color: var(--ok); }
.audit-score.bad strong { color: var(--danger); }
.audit-summary ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; font-size: .92rem; color: var(--muted); }
.audit-summary b { color: var(--text); }

.audit-group {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 1.6rem 0 .5rem;
}

.checklist li b { font-weight: 600; }
.checklist li.bad .mark { color: var(--danger); }
.checklist li.optional .mark { color: var(--warn); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.checkline {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  margin-bottom: .55rem;
}
.checkline input[type="checkbox"] { margin-top: .3rem; }
.checkline > span { margin: 0; color: var(--text); font-size: .94rem; }
.checkline small { color: var(--muted); }

.hint { font-size: .86rem; color: var(--muted); margin: -.35rem 0 .9rem; }
.hint.ok { color: var(--ok); }
.hint.warn { color: var(--warn); }

.hint-box {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin: 1.1rem 0;
  font-size: .9rem;
}
.hint-box ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.hint-box li { margin-bottom: .2rem; }

.wizard-actions {
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.25rem;
}

.db-test-result {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  font-size: .92rem;
  background: var(--panel-2);
}
.db-test-result.pending { color: var(--muted); }
.db-test-result.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.db-test-result.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.db-test-result table.grid { margin-top: .6rem; font-size: .88rem; }
.db-test-result table.grid th { width: 40%; }

ul.plain { list-style: none; margin: .5rem 0; padding: 0; font-size: .9rem; color: var(--muted); }
ul.plain li { margin-bottom: .3rem; }
ul.warn-list li { color: var(--warn); }

/* ------------------------------------------------------------ diagnostics */
.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.diagnostics .panel h2 { margin-top: 0; }
.diagnostics table.grid th { width: 38%; color: var(--muted); font-weight: 500; font-size: .82rem; text-transform: none; letter-spacing: 0; }
.diagnostics table.grid td.mono { font-size: .82rem; word-break: break-word; }

/* ----------------------------------------------------------------- alerts */
.alerts { display: grid; gap: .6rem; margin-bottom: 1.1rem; }
.alert { display: flex; gap: .65rem; align-items: flex-start; }
.alert-icon {
  flex: 0 0 auto;
  width: 1.35rem; height: 1.35rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: .8rem;
  border: 1px solid currentColor;
  margin-top: .1rem;
}
.alert.error { color: var(--danger); }
.alert.success { color: var(--ok); }
.alert.warning { color: var(--warn); }
.alert.info { color: var(--accent); }
.alert-text { color: var(--text); }

.badge.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.form-note.ok { color: var(--ok); }

/* =====================================================================
   App shell + dashboard additions
   ---------------------------------------------------------------------
   Everything below is additive: the classes above already style the shell,
   these fill in the pieces the dashboard and the authenticated layout use.
   No external fonts, no images, no JS-driven layout - a locked-down shared
   host must be able to render this from one CSS file.
   ===================================================================== */

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--panel); color: var(--text); padding: .6rem .9rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.skip-link:focus { left: .6rem; top: .6rem; }

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

.icon { flex: 0 0 auto; vertical-align: -3px; }
.nav-off {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  color: var(--muted); font-size: .92rem; opacity: .55; cursor: not-allowed;
}
.nav-off .badge { margin-left: auto; font-size: .62rem; padding: .05rem .35rem; }
.sidebar nav a .badge { margin-left: auto; }
.sidebar-foot {
  margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.inline-form, .account-panel form { margin: 0; }
.link-button {
  background: none; border: 0; padding: 0; color: var(--muted);
  font: inherit; font-size: .85rem; cursor: pointer; text-align: left;
}
.link-button:hover { color: var(--text); text-decoration: underline; }

.topbar-search { position: relative; display: flex; align-items: center; gap: .5rem; flex: 1 1 320px; max-width: 520px; }
.topbar-search input {
  width: 100%; padding: .5rem .8rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit;
}
.topbar-search input:disabled { opacity: .6; cursor: not-allowed; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.storage-indicator {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .7rem;
  border: 1px solid var(--line); border-radius: 99px; background: var(--panel);
  color: var(--text); text-decoration: none; font-size: .85rem;
}
.storage-indicator .bar { width: 72px; height: 7px; }
.storage-indicator .storage-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.storage-indicator .storage-value { font-variant-numeric: tabular-nums; }
.storage-indicator.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.storage-indicator.danger { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

.icon-button {
  position: relative; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; text-decoration: none;
}
.icon-button:hover { color: var(--text); border-color: var(--accent); }
.icon-button .count {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
  display: grid; place-items: center; border-radius: 99px; padding: 0 4px;
  background: var(--accent); color: #04120f; font-size: .66rem; font-weight: 700;
}

.account-menu { position: relative; }
.account-menu > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .3rem .55rem; border: 1px solid var(--line); border-radius: 99px; background: var(--panel);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent);
  font-size: .78rem; font-weight: 700;
}
.account-name { font-size: .88rem; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30;
  min-width: 220px; display: grid; gap: .1rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .45rem; box-shadow: var(--shadow);
}
.account-panel a, .account-panel .link-button { display: block; padding: .45rem .6rem; border-radius: var(--radius-sm); font-size: .88rem; }
.account-panel a { color: var(--text); text-decoration: none; }
.account-panel a:hover, .account-panel .link-button:hover { background: var(--panel-2); text-decoration: none; }

.app-footer {
  margin-top: auto; padding: .9rem clamp(1rem, 3vw, 1.75rem);
  border-top: 1px solid var(--line); display: flex; gap: 1rem;
  justify-content: space-between; flex-wrap: wrap;
}

/* ------------------------------------------------------------- dashboard */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.page-title { font-size: clamp(1.35rem, 2.6vw, 1.85rem); margin: 0 0 .25rem; letter-spacing: -.01em; }
.page-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: .4rem; }

.dash-block { margin-top: 1.1rem; }
.dash-grid.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.1rem; margin-top: 1.1rem; }
.dash-grid.two .dash-block { margin-top: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.block-head h2 { margin: 0; font-size: 1.02rem; letter-spacing: .01em; }
.block-head a { text-decoration: none; }
.block-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .9rem; }
.btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.alert-band { display: grid; gap: .5rem; margin-top: .9rem; }

.storage-total { margin-bottom: 1rem; }
.storage-total-figure { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .45rem; }
.storage-total-figure .value { font-size: 1.6rem; font-weight: 650; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .7rem; }
.stat-row .stat { padding: .8rem .85rem; }
.stat-row .stat .label { display: flex; align-items: center; gap: .35rem; }
.stat-row .stat .value { font-size: 1.35rem; }
.stat-row .stat .value.small-value { font-size: 1rem; font-weight: 600; word-break: break-word; }

.kv { margin: 1rem 0 0; display: grid; gap: .45rem; }
.kv > div { display: flex; align-items: baseline; gap: .6rem; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: .45rem; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; text-align: right; font-size: .9rem; display: flex; align-items: baseline; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }

.cell-bar { min-width: 130px; }
.cell-bar .bar { display: inline-block; width: 78px; vertical-align: middle; margin-right: .4rem; }

.hint { color: var(--muted); font-size: .84rem; margin: .9rem 0 0; line-height: 1.5; }
.hint.warn { color: var(--warn); }
.hint.bad { color: var(--danger); }
.muted.small, .small { font-size: .8rem; }
.bad.small { color: var(--danger); }
.mono { font-family: var(--mono); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.timeline li { display: flex; gap: .6rem; align-items: flex-start; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; background: var(--accent); flex: 0 0 auto; }
.timeline .sev-warning .dot { background: var(--warn); }
.timeline .sev-error .dot, .timeline .sev-critical .dot { background: var(--danger); }
.timeline-action { margin: 0; font-size: .9rem; }
.timeline p { margin: 0; }

.mini-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .35rem; }
.mini-list li { display: flex; justify-content: space-between; gap: .6rem; border-bottom: 1px dashed var(--line); padding-bottom: .3rem; }

.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.recent-list li { display: flex; align-items: center; gap: .7rem; padding: .45rem .1rem; border-bottom: 1px solid var(--line); }
.recent-list li:last-child { border-bottom: 0; }
.recent-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--panel-2); color: var(--muted); flex: 0 0 auto; }
.recent-body { display: grid; min-width: 0; }
.recent-name { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-flash { animation: dash-pulse 900ms ease-out 1; }
@keyframes dash-pulse { from { background-color: color-mix(in srgb, var(--accent) 12%, transparent); } to { background-color: transparent; } }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  .sidebar .group-title { width: 100%; }
  .topbar { flex-wrap: wrap; }
  .account-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dash-flash { animation: none; }
}

/* ---------------------------------------------------------------------------
   One-time secrets (pairing codes, rotated agent tokens - see partials/alerts).
   They are shown exactly once, so they have to be readable, selectable and
   obviously not part of the conversation around them.
   --------------------------------------------------------------------------- */
.alert.secret {
  border-color: color-mix(in srgb, var(--warn, #d9a441) 60%, transparent);
  background: color-mix(in srgb, var(--warn, #d9a441) 12%, transparent);
}
.alert.secret .alert-text code,
.selectable {
  display: inline-block;
  margin-top: .35rem;
  padding: .35rem .6rem;
  font-size: .95rem;
  letter-spacing: .04em;
  user-select: all;
  -webkit-user-select: all;
}

/* Admin screens: a compact, honest table. Numbers are monospaced so columns
   line up, and a storage bar never guesses at a percentage it does not have. */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.admin-table th,
.admin-table td {
  padding: .6rem .5rem;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  vertical-align: top;
}
.admin-table th {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .7;
  font-weight: 600;
}
.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table tr.archived { opacity: .55; }
.admin-table .row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.admin-table .row-actions form { display: inline; }
.admin-note {
  margin: 0 0 1rem;
  padding: .7rem .85rem;
  border-radius: .5rem;
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  font-size: .9rem;
}
.admin-note.dynamic { border-style: dashed; }
.admin-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: .75rem;
}
.admin-facts div { display: flex; flex-direction: column; gap: .15rem; }
.admin-facts dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; opacity: .65; }
.admin-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .admin-table thead { display: none; }
  .admin-table tr { display: block; border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent); padding: .5rem 0; }
  .admin-table td { display: block; border: 0; padding: .2rem 0; }
  .admin-table td.num { text-align: left; }
}

/* =====================================================================
   Installer - the ten-step wizard, made easy to fill in
   ---------------------------------------------------------------------
   Everything here exists for one reason: the installer is the first screen
   anybody sees, and a first screen that is confusing is read as "this product
   is confusing". Large labels, obvious required markers, grouped questions,
   help that says where to find the answer, and a progress bar that tells you
   how much is left.
   ===================================================================== */

.wizard-progress { margin: 0 0 1.1rem; }
.wizard-progress-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  font-size: .84rem; color: var(--muted); margin-bottom: .45rem;
}
.wizard-progress-head b { color: var(--text); font-weight: 600; }
.wizard-progress-bar { height: 7px; border-radius: 99px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.wizard-progress-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.wizard-steps li a { display: flex; align-items: center; gap: .65rem; color: inherit; }
.wizard-steps li:hover { background: color-mix(in srgb, var(--panel-2) 70%, transparent); color: var(--text); }
.wizard-steps li b { flex: 0 0 auto; }
.wizard-steps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wizard-steps li.locked { opacity: .45; }

/* A question, as a block: title, why it is asked, then the fields. */
.field-group {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem .35rem;
  margin: 0 0 1rem; background: color-mix(in srgb, var(--panel-2) 45%, transparent);
}
.field-group > header { margin-bottom: .85rem; }
.field-group h3 { margin: 0 0 .2rem; font-size: .98rem; }
.field-group p { margin: 0; font-size: .86rem; color: var(--muted); }
.field-group .field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 1rem; }

label > span > .req { color: var(--accent); margin-left: .25rem; }
.field-hint { display: block; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.field-hint.warn { color: var(--warn); }
.field-hint.ok { color: var(--ok); }

.input-wrap { position: relative; display: flex; align-items: center; gap: .4rem; }
.input-wrap input { flex: 1 1 auto; }
.input-wrap .btn.icon {
  flex: 0 0 auto; padding: .55rem .7rem; font-size: .82rem; line-height: 1;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: color-mix(in srgb, var(--danger) 65%, transparent); }

.meter { display: flex; gap: .25rem; margin-top: .45rem; }
.meter i { flex: 1 1 auto; height: 5px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); }
.meter i.on-1 { background: var(--danger); border-color: transparent; }
.meter i.on-2 { background: var(--warn); border-color: transparent; }
.meter i.on-3 { background: var(--accent); border-color: transparent; }
.meter i.on-4 { background: var(--ok); border-color: transparent; }

.copy-row { display: flex; align-items: center; gap: .5rem; }
.copy-row code {
  flex: 1 1 auto; font-family: var(--mono); font-size: .82rem; padding: .5rem .6rem;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre;
}

.choice { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .5rem; background: var(--bg-2); }
.choice input { margin-top: .2rem; }
.choice span { font-size: .92rem; }
.choice small { display: block; color: var(--muted); font-size: .82rem; margin-top: .15rem; }

.wizard-actions {
  display: flex; align-items: center; gap: .6rem; margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.wizard-actions .spacer { flex: 1 1 auto; }
.wizard-actions .btn { min-height: 44px; }   /* a comfortable target on a phone */

.step-note { font-size: .86rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: .7rem; margin: 1rem 0; }
.install-summary { display: grid; gap: .3rem; margin: .9rem 0 0; }
.install-summary div { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; border-bottom: 1px dashed var(--line); padding-bottom: .3rem; }
.install-summary dt { color: var(--muted); }
.install-summary dd { margin: 0; font-family: var(--mono); font-size: .86rem; }

@media (max-width: 900px) {
  .wizard-steps { display: flex; overflow-x: auto; gap: .3rem; padding-bottom: .3rem; }
  .wizard-steps li { flex: 0 0 auto; border: 1px solid var(--line); }
  .wizard-steps li span { display: none; }
  .wizard-steps li.current span { display: inline; }
}

@media (max-width: 640px) {
  .wizard-actions { flex-wrap: wrap; }
  .wizard-actions .btn { flex: 1 1 100%; }
  .field-group { padding: .9rem .85rem .3rem; }
}

/* Audit groups became collapsible: eleven rows of green ticks are reassuring,
   but they must not push the two red ones off the screen. */
details.audit-group > summary {
  cursor: pointer; font-size: .95rem; font-weight: 600; padding: .5rem .1rem;
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--line); margin-bottom: .5rem; list-style: none;
}
details.audit-group > summary::-webkit-details-marker { display: none; }
details.audit-group > summary::after { content: '▾'; color: var(--muted); font-size: .8rem; }
details.audit-group[open] > summary::after { content: '▴'; }
details.audit-group > summary:hover { color: var(--accent); }
.hint-box { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: 1rem 0; background: var(--bg-2); }
.hint-box b { display: block; margin-bottom: .35rem; }
.hint-box ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .9rem; }
.db-test-result { border-radius: var(--radius-sm); padding: .8rem 1rem; margin-top: .8rem; font-size: .9rem; border: 1px solid var(--line); }
.db-test-result.ok  { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.db-test-result.bad { border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.db-test-result ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.db-test-result table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.db-test-result th, .db-test-result td { text-align: left; font-size: .85rem; padding: .2rem .4rem; border-bottom: 1px solid var(--line); }

/* =====================================================================
   Installer · verdict banners and the audit legend
   ---------------------------------------------------------------------
   The wizard shows two kinds of finding and they are NOT the same thing:
   a ✘ blocks installation, a ○ is a note. Before this existed, both read
   as errors in the same list, and people stopped at "sodium is missing"
   believing they could not continue.
   ===================================================================== */
.verdict {
  margin: 0 0 1rem;
  padding: .9rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  line-height: 1.55;
}
.verdict.ok  { border-left: 3px solid var(--ok); }
.verdict.bad { border-left: 3px solid var(--danger); }
.verdict b   { color: var(--fg); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.1rem;
  margin: 0 0 1rem;
  font-size: .82rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend b { color: var(--ok); }
.legend b.bad { color: var(--danger); }

.checklist li.optional .mark { color: var(--muted); }

/* The audit groups are <details>: give the summary a proper affordance. */
details.audit-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: .35rem .9rem .6rem;
  margin-bottom: .7rem;
}
details.audit-group > summary {
  cursor: pointer;
  padding: .5rem .1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  list-style: none;
}
details.audit-group > summary::-webkit-details-marker { display: none; }
details.audit-group > summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform .15s ease;
}
details.audit-group[open] > summary::before { transform: rotate(90deg); }
details.audit-group > summary > span { margin-left: auto; }
