/* BARBIPA admin — light/dark via tokens. data-theme on <html> overrides the system setting. */
:root {
  --bg: #f5f2ef;
  --surface: #ffffff;
  --surface-2: #f9f7f5;
  --line: #e6e0db;
  --ink: #221c19;
  --ink-2: #6c625c;
  --accent: #9c6b5a;
  --accent-ink: #ffffff;
  --accent-soft: #f3e6df;
  --ok: #2f7a4f;       --ok-soft: #e4f2ea;
  --warn: #9a6512;     --warn-soft: #fbf0dc;
  --err: #b23a3a;      --err-soft: #f9e3e3;
  --focus: #9c6b5a66;
  --shadow: 0 1px 2px rgb(30 20 15 / 6%), 0 4px 16px rgb(30 20 15 / 5%);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141110; --surface: #1d1917; --surface-2: #242019; --line: #322c28;
    --ink: #eee7e2; --ink-2: #a89d96; --accent: #d4a491; --accent-ink: #1a1412; --accent-soft: #3a2b25;
    --ok: #7fcf9f; --ok-soft: #1d3326; --warn: #e8b660; --warn-soft: #3a2e17; --err: #f08b8b; --err-soft: #3d1f1f;
    --focus: #d4a49166; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141110; --surface: #1d1917; --surface-2: #242019; --line: #322c28;
  --ink: #eee7e2; --ink-2: #a89d96; --accent: #d4a491; --accent-ink: #1a1412; --accent-soft: #3a2b25;
  --ok: #7fcf9f; --ok-soft: #1d3326; --warn: #e8b660; --warn-soft: #3a2e17; --err: #f08b8b; --err-soft: #3d1f1f;
  --focus: #d4a49166; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.theme-anim, .theme-anim * { transition: background-color .3s, color .3s, border-color .3s !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); padding: .05em .35em; border-radius: 5px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.h2 { font-size: 1.5rem; } .h3 { font-size: 1.05rem; }
.muted { color: var(--ink-2); } .small, small { font-size: .85em; }
.lead { color: var(--ink-2); margin: 0 0 1.25rem; max-width: 70ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--ink-2); margin: 0 0 .25rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Shell ---------- */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 650; letter-spacing: .08em; padding: .2rem .5rem 1.2rem; }
.brand small { font-weight: 400; letter-spacing: 0; color: var(--ink-2); }
.brand-lg { font-size: 1.1rem; padding: 0 0 1.25rem; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--bg); font: italic 600 18px/1 Georgia, serif; letter-spacing: 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; justify-content: space-between; padding: .55rem .7rem; border-radius: 9px; color: var(--ink); text-decoration: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav-item.is-soon { color: var(--ink-2); cursor: default; }
.nav-item small { font-size: .7rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 .45rem; }
.side-foot { border-top: 1px solid var(--line); padding-top: .6rem; }

.main-wrap { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .85rem 1.75rem; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 1.15rem; flex: 1; }
.topbar-tools { display: flex; align-items: center; gap: .75rem; }
.topbar-tools form { margin: 0; }
.who { color: var(--ink-2); font-size: .9rem; }
.menu-btn { display: none; background: none; border: 0; color: var(--ink); padding: .3rem; cursor: pointer; }
.menu-btn svg { width: 24px; height: 24px; }
.content { padding: 1.75rem; max-width: 1180px; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow); }
  .menu-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .who { display: none; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.35rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-title { font-size: 1rem; font-weight: 650; margin: 0 0 .9rem; }
details.card > summary { cursor: pointer; margin: 0; list-style: none; }
details.card > summary::before { content: "+ "; color: var(--accent); }
details.card[open] > summary { margin-bottom: 1rem; }
details.card[open] > summary::before { content: "– "; }
.card-link { display: inline-block; margin-top: .75rem; font-size: .9rem; text-decoration: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.cards .card { margin: 0; }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 1.25rem; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: .2rem .7rem; font-size: .9rem; }
.chip code { border: 0; background: none; padding: 0; color: var(--ink-2); }

.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .6rem; border-radius: 99px; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-muted { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

.alert { border-radius: 10px; padding: .75rem 1rem; margin: 0 0 1.1rem; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-err { background: var(--err-soft); color: var(--err); }
.alert form.inline { display: inline; margin-left: .5rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .92rem;
  padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); background: transparent; }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.6rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--ink-2); }
.field > span { font-weight: 550; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: .55rem .7rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input.num { width: 5rem; }
.code-input { font-family: var(--mono); font-size: 1.35rem !important; letter-spacing: .35em; text-align: center; max-width: 12rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem 1rem; }
.grid-form .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-start; margin-top: .25rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin: .5rem 0; }
.inline-form .field { min-width: 240px; }

.toggle-row { display: flex; gap: .85rem; align-items: flex-start; padding: .65rem 0; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--surface); border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }

/* Tables */
.table-wrap { overflow-x: auto; margin: -.25rem; padding: .25rem; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table input[type=text], .table select { padding: .35rem .5rem; min-width: 7.5rem; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.row-actions form { margin: 0; }

/* Two-factor */
.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.qr { width: 200px; height: 200px; margin: .75rem 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { display: inline-block; margin-top: .4rem; font-size: 1rem; letter-spacing: .05em; user-select: all; }

/* Theme toggle */
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 19px; height: 19px; grid-area: 1 / 1; opacity: 0; transform: rotate(-30deg) scale(.7); transition: opacity .2s, transform .25s; }
.theme-toggle:not([data-state]) .ti-system, .theme-toggle[data-state=system] .ti-system,
.theme-toggle[data-state=light] .ti-light, .theme-toggle[data-state=dark] .ti-dark { opacity: 1; transform: none; }

/* Auth / installer pages */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; box-shadow: var(--shadow); }
.auth-wide { max-width: 720px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; font-size: .92rem; }
.checklist .ok { color: var(--ok); } .checklist .bad { color: var(--err); font-weight: 600; }
.debug { white-space: pre-wrap; font: .8rem/1.4 var(--mono); background: var(--surface-2); padding: .75rem; border-radius: 8px; border: 1px solid var(--line); }

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