/* Samba Conductor: mobile-first, light/dark, no JavaScript. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f4; --fg: #17202a; --muted: #5b6673;
  --border: #d5dbe1; --accent: #0f766e; --accent-fg: #ffffff; --accent-soft: #d7f0ec;
  --danger: #b42318; --danger-soft: #fde7e5; --ok: #146c43; --ok-soft: #dcf3e6;
  --warn: #8a5a00; --warn-soft: #fff1cc; --focus: #2563eb; --code: #f1f3f6;
  --radius: 10px; --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #161d24; --surface-2: #1d2630; --fg: #e6eaee; --muted: #9aa6b2;
    --border: #2c3742; --accent: #2dd4bf; --accent-fg: #062925; --accent-soft: #123b37;
    --danger: #f97066; --danger-soft: #3b1715; --ok: #4ade80; --ok-soft: #12321f;
    --warn: #fbbf24; --warn-soft: #3a2c06; --focus: #60a5fa; --code: #10161c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #161d24; --surface-2: #1d2630; --fg: #e6eaee; --muted: #9aa6b2;
  --border: #2c3742; --accent: #2dd4bf; --accent-fg: #062925; --accent-soft: #123b37;
  --danger: #f97066; --danger-soft: #3b1715; --ok: #4ade80; --ok-soft: #12321f;
  --warn: #fbbf24; --warn-soft: #3a2c06; --focus: #60a5fa; --code: #10161c;
  --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

/* Header and navigation: a scrollable row on phones, wraps on desktop. */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--fg); text-decoration: none; font-weight: 650; }
.brand img { display: block; }
.who { margin-left: auto; color: var(--muted); font-size: .875rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Grouped sidebar on desktop; on phones a native <details> "Menu" (no JavaScript). */
.shell { width: 100%; max-width: 1200px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.shell main { max-width: none; margin: 0; min-width: 0; }
.sidenav { background: var(--surface); border-bottom: 1px solid var(--border); }
.sidenav-box > summary {
  list-style: none; cursor: pointer; padding: .7rem 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem;
}
.sidenav-box > summary::-webkit-details-marker { display: none; }
.sidenav-box > summary::before { content: ""; width: 1.1rem; height: .8rem; flex: none;
  background: linear-gradient(var(--fg) 0 2px, transparent 2px 6px, var(--fg) 6px 8px, transparent 8px 12px, var(--fg) 12px 14px) center / 100% 14px no-repeat; }
.sidenav-box[open] > summary { border-bottom: 1px solid var(--border); }
.sidenav-body { padding: .5rem 1rem 1rem; }
.nav-group { margin-top: .75rem; }
.nav-heading { margin: 0 0 .15rem; padding: 0 .5rem; font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.sidenav a, .sidenav button {
  display: block; width: 100%; text-align: left; padding: .55rem .5rem; color: var(--muted); text-decoration: none; font: inherit; font-size: .95rem;
  border: 0; border-left: 3px solid transparent; background: none; cursor: pointer; border-radius: 6px;
}
.sidenav a[aria-current="page"] { color: var(--fg); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.sidenav a:hover, .sidenav button:hover { color: var(--fg); background: var(--surface-2); }
.sidenav form { margin: 0; }
.nav-foot { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--border); }
@media (min-width: 900px) {
  .shell.has-nav { max-width: 1440px; flex-direction: row; align-items: flex-start; gap: 1.25rem; padding: 0 1rem; }
  .shell.has-nav main { flex: 1; padding: 1rem 0; }
  .sidenav { flex: 0 0 14.5rem; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; border: 0; background: none; padding-top: .75rem; }
  .sidenav-box > summary { display: none; }
  /* The sidebar is always open on a wide screen: show the content of a closed <details>. */
  .sidenav-box::details-content { content-visibility: visible; display: block; }
  .sidenav-body { padding: 0; }
  .nav-group:first-child { margin-top: 0; }
}

main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1rem; flex: 1; }
.shell main { padding: 1rem; }
footer { color: var(--muted); font-size: .85rem; padding: 1rem; text-align: center; border-top: 1px solid var(--border); }
footer a { color: var(--muted); }
footer .prefs { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; margin-bottom: .25rem; }

h1 { font-size: 1.45rem; margin: .25rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono, code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: var(--code); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; overflow-wrap: anywhere; }
pre { background: var(--code); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; overflow-x: auto; font-size: .85rem; white-space: pre; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2:first-child { margin-top: 0; }
.narrow { max-width: 28rem; margin: 2rem auto; }
.grid { display: grid; gap: 1rem; }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; text-decoration: none; color: var(--fg); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .875rem; }

.flash { border-radius: var(--radius); padding: .65rem .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-error, .alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash-info, .alert-info { background: var(--accent-soft); color: var(--fg); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-error, .alert-info, .alert-warn { border-radius: var(--radius); padding: .65rem .9rem; margin: .75rem 0; }

form { margin: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label, .label { font-weight: 600; font-size: .925rem; }
.hint { color: var(--muted); font-size: .825rem; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=date], select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; width: 100%; min-height: 44px;
}
input:focus, select:focus { border-color: var(--accent); }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .9rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row > .grow { flex: 1 1 12rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.actions form { display: inline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--fg); font: inherit;
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .875rem; }
.btn-block { width: 100%; }

.badge { display: inline-block; border-radius: 999px; padding: .1rem .55rem; font-size: .775rem; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* Tables become stacked cards on phones. */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--border); }
.table td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
@media (max-width: 719px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; padding: .3rem .25rem; }
  .table td { border: 0; padding: .15rem .5rem; font-size: .925rem; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .table td:first-child { font-weight: 600; }
  .table td:first-child::before { content: none; }
}
dl.props { display: grid; grid-template-columns: 1fr; gap: .15rem .75rem; margin: 0; }
dl.props dt { color: var(--muted); font-size: .825rem; margin-top: .5rem; }
dl.props dd { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
.tree .d1 { padding-left: 1.25rem; } .tree .d2 { padding-left: 2.5rem; } .tree .d3 { padding-left: 3.75rem; }
.tree .d4 { padding-left: 5rem; } .tree .d5 { padding-left: 6.25rem; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; padding: 0; list-style: none; }
.codes li { background: var(--code); border: 1px solid var(--border); border-radius: 6px; padding: .4rem; text-align: center; font-family: ui-monospace, monospace; }
.qr { display: block; width: 220px; max-width: 100%; height: auto; margin: .5rem auto; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.secret { font-family: ui-monospace, monospace; letter-spacing: .08em; word-break: break-all; }
.filters { display: grid; gap: .5rem; grid-template-columns: 1fr; margin-bottom: 1rem; }

@media (min-width: 720px) {
  main { padding: 1.5rem; }
  h1 { font-size: 1.7rem; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dl.props { grid-template-columns: minmax(9rem, max-content) 1fr; }
  dl.props dt { margin-top: 0; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .codes { grid-template-columns: repeat(2, 10rem); }
}
@media (min-width: 1024px) {
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
details summary { cursor: pointer; color: var(--muted); }

/* P2 additions. */
[hidden] { display: none !important; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .55rem .75rem; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"], .tabs a[aria-current="step"] { color: var(--fg); border-bottom-color: var(--accent); }
input[type=file] { font: inherit; max-width: 100%; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
details pre { margin-top: .5rem; max-height: 24rem; }
.table td .actions { margin-top: 0; }

/* File servers: ACL diffs in previews. */
ul.diff { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
ul.diff li { display: flex; gap: .5rem; align-items: baseline; padding: .35rem .6rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
ul.diff li:last-child { border-bottom: 0; }
ul.diff .diff-mark { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; width: 1ch; }
ul.diff .diff-add { background: var(--ok-soft); }
ul.diff .diff-add .diff-mark { color: var(--ok); }
ul.diff .diff-del { background: var(--danger-soft); text-decoration: line-through; }
ul.diff .diff-del .diff-mark { color: var(--danger); }
ul.folders li { align-items: center; }
ul.diff .grow { flex: 1 1 auto; }

/* Branding: the generated /branding/theme.css sets the custom properties
   (--accent, --brand-accent...) and the background image; these rules
   place the branded blocks. Text from the branding keeps its line breaks. */
.brand img.logo { height: 32px; width: auto; max-width: 11rem; object-fit: contain; }
.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
.topbar.branded { border-bottom: 3px solid var(--brand-accent, var(--border)); }
.brand-notice { background: var(--brand-accent, var(--warn-soft)); color: var(--brand-accent-fg, var(--warn)); border-radius: var(--radius);
  padding: .65rem .9rem; margin-bottom: 1rem; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
.brand-text { white-space: pre-line; overflow-wrap: anywhere; }
.brand-footer { max-width: 40rem; margin: 0 auto .75rem; display: grid; gap: .35rem; }
.brand-footer p { margin: 0; }
.brand-links, .brand-support { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; }
.brand-help { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.brand-help .row { gap: .25rem 1rem; }
body.brand-bg { background-color: var(--bg); }
body.brand-bg footer, body.brand-bg .topbar { background: var(--surface); }
body.brand-bg .card { box-shadow: 0 8px 30px rgb(0 0 0 / 25%); }

/* Settings > Branding: image thumbnails and the preview cards (light and
   dark, styled by /admin/branding/preview.css). */
.slot-thumb { display: block; max-width: 12rem; max-height: 4rem; object-fit: contain; padding: 4px; border: 1px solid var(--border);
  border-radius: 6px; background: repeating-conic-gradient(#d5dbe1 0 25%, #ffffff 0 50%) 50% / 12px 12px; }
.preview-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
@media (min-width: 900px) { .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.brand-preview { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.brand-preview a { color: var(--accent); }
.brand-preview .preview-label { padding: .35rem 1rem; font-size: .75rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.brand-preview .topbar { background: var(--surface); }
.brand-preview .brand { color: var(--fg); }
.brand-preview .preview-body { padding: 1rem; }
.brand-preview .preview-card { max-width: 22rem; margin: 0 auto; background: var(--surface); }
.brand-preview .preview-title { margin-top: 0; font-size: 1.2rem; }
.brand-preview .preview-input { display: block; min-height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.brand-preview .preview-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; text-align: center; display: grid; gap: .25rem; }
.brand-preview .preview-footer p { margin: 0; }
.brand-preview:not(.preview-dark) .brand .logo-light { display: block; }
.brand-preview:not(.preview-dark) .brand .logo-dark { display: none; }
.brand-preview.preview-dark .brand .logo-light { display: none; }
.brand-preview.preview-dark .brand .logo-dark { display: block; }
