/* ─────────────────────────────────────────────────────────────
   CODEON — admin shell (sidebar + content) and admin page parts.
   Builds on the tokens and components in style.css.
   ───────────────────────────────────────────────────────────── */

/* ─── Shell ─── */
.shell { display: flex; min-height: 100vh; width: 100%; }
.sidebar {
  position: sticky; top: 0; align-self: flex-start; height: 100vh; width: 248px; flex: none;
  display: flex; flex-direction: column; gap: 22px; padding: 22px 16px 18px;
  background: var(--bg-2); border-inline-end: 1px solid var(--border);
}
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 8px; }
.sidebar .brand-logo { width: 132px; height: 30px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav .group { font-size: .66rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); color: var(--text-2); text-decoration: none; font-weight: 500; font-size: .92rem; transition: background .15s, color .15s; }
.nav-item svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.is-active { background: var(--accent-glow); color: var(--accent); font-weight: 600; }
.nav-item.is-active svg { color: var(--accent); }
.nav-item .count { margin-inline-start: auto; font-size: .74rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.who-row { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-green); color: #fff; font-weight: 800; font-size: .85rem; display: grid; place-items: center; flex: none; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who b { font-size: .88rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: .74rem; color: var(--muted); }
.foot-actions { display: flex; gap: 8px; align-items: center; }
.foot-actions form { flex: 1; }
.foot-actions .btn-secondary { width: 100%; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page.wide { max-width: 1260px; padding: 30px 32px 60px; margin: 0; }
.admin .footer-bottom { max-width: none; padding: 14px 32px 18px; }
.mobile-bar { display: none; position: sticky; top: 0; z-index: 40; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.mobile-bar .brand-logo { width: 120px; height: 28px; }
#nav-toggle { display: none; }
.burger { width: 38px; height: 38px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.burger span { width: 16px; height: 2px; background: var(--text-2); position: relative; }
.burger span::before, .burger span::after { content: ""; position: absolute; left: 0; width: 16px; height: 2px; background: var(--text-2); }
.burger span::before { top: -5px; } .burger span::after { top: 5px; }
@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; height: 100dvh; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  #nav-toggle:checked ~ .shell .sidebar, #nav-toggle:checked ~ .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
  #nav-toggle:checked ~ .scrim { display: block; }
  .mobile-bar { display: flex; }
  .page.wide { padding: 20px 16px 48px; }
  .admin .footer-bottom { padding: 14px 16px; }
}

/* ─── Page header ─── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { margin-top: 4px; color: var(--muted); font-size: .92rem; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .84rem; margin-bottom: 10px; }
.crumbs a { text-decoration: none; color: var(--muted); } .crumbs a:hover { color: var(--accent); }
.crumbs span { color: var(--border-strong); }

/* ─── Section nav (tenant page) ─── */
.subnav { position: sticky; top: 0; z-index: 30; display: flex; gap: 2px; margin: 0 0 20px; padding: 6px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 999px; overflow-x: auto; width: fit-content; max-width: 100%; }
.subnav a { padding: 6px 13px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.subnav a:hover { background: var(--surface-hover); color: var(--text); }
.subnav a b { color: var(--muted); font-weight: 600; margin-inline-start: 4px; }
@media (max-width: 960px) { .subnav { top: 60px; } }

/* ─── Layout helpers ─── */
.grid-2 { display: grid; grid-template-columns: 7fr 5fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.grid-2-even { grid-template-columns: 1fr 1fr; }
.grid-2 > * { min-width: 0; }  /* lets a wide table inside scroll instead of widening the page */
.grid-2 > .card, .grid-2 + .card, .card + .grid-2, .stack > .card + .card { margin-top: 0; }
@media (max-width: 900px) { .grid-2, .grid-2-even { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 18px; }
section.card { margin-bottom: 18px; }
section.card:last-child { margin-bottom: 0; }
.stats-5 { grid-template-columns: repeat(5, 1fr); }
.stats-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1150px) { .stats-6 { grid-template-columns: repeat(3, 1fr); } .stats-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .stats-6, .stats-5 { grid-template-columns: repeat(2, 1fr); } }

/* ─── Login ─── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60rem 30rem at 50% -10%, var(--accent-glow), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 32px; }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 20px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn-primary { width: 100%; margin-top: 20px; padding: 12px; }
.login-foot { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); }

/* ─── Tenants list ─── */
.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filterbar .search { flex: 1 1 240px; max-width: 360px; padding: 9px 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 600; text-decoration: none; text-transform: capitalize; white-space: nowrap; }
.chip b { color: var(--muted); font-weight: 700; margin-inline-start: 4px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-on { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }
.chip-on b { color: rgba(255,255,255,.8); }
.tenant-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tenant-cell .title { white-space: nowrap; }
.tenant-cell .sub { white-space: normal; max-width: 360px; line-height: 1.35; }
.tile { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; background: #fff; padding: 4px; border: 1px solid var(--border); flex: none; }
.tile-text { display: inline-flex; align-items: center; justify-content: center; background: var(--brand-green); color: #fff; font-weight: 800; padding: 0; }
table.tenants td { vertical-align: middle; }
td.addons > div { width: 160px; }
td.addons .sub { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addon-cell { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: .8rem; color: var(--muted); }
.state-current .addon-cell, .state-current .tpl-state { color: var(--ok); }
.state-behind .addon-cell, .state-behind .tpl-state { color: var(--warn); }
.state-failed .addon-cell, .state-failed .tpl-state { color: var(--error); }

/* ─── Add-on code panel ─── */
.deploy-card { display: flex; flex-direction: column; gap: 18px; }
.deploy-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.deploy-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.repo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.repo { border: 1px solid var(--border); border-inline-start: 3px solid var(--border-strong); border-radius: var(--r-lg); padding: 12px 16px; background: var(--surface-2); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.repo-ok { border-inline-start-color: var(--ok); }
.repo-behind { border-inline-start-color: var(--warn); }
.repo-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.repo-name { font-weight: 700; font-size: .95rem; }
.repo-state { font-size: .74rem; font-weight: 700; white-space: nowrap; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.repo-ok .repo-state { color: var(--ok); }
.repo-behind .repo-state { color: var(--warn); }
.repo-commit { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: .85rem; }
.sha { font-family: var(--mono); font-size: .78rem; padding: 1px 7px; border-radius: 6px; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-2); }
.repo-when { color: var(--muted); white-space: nowrap; }
.repo-subject { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.repo-hint { font-size: .82rem; color: var(--warn); }
.tpl { display: flex; flex-direction: column; gap: 8px; }
.tpl-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.tpl-head .muted { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: .82rem; }
.tpl-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); }
.tpl-row { display: grid; grid-template-columns: 14px minmax(180px, 260px) 150px minmax(0, 1fr); align-items: center; gap: 12px; padding: 9px 16px; font-size: .88rem; }
.tpl-row + .tpl-row { border-top: 1px solid var(--border); }
.tpl-name { font-weight: 600; display: flex; flex-direction: column; min-width: 0; }
.tpl-name code { font-weight: 400; font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-state { font-weight: 700; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tpl-detail { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.deploy-foot { color: var(--muted); font-size: .8rem; }
@media (max-width: 720px) { .tpl-row { grid-template-columns: 14px minmax(0, 1fr); row-gap: 2px; } .tpl-row .tpl-state, .tpl-row .tpl-detail { grid-column: 2; } }

/* ─── Ship updates ─── */
.ship-card { padding: 0; overflow: hidden; }
.ship-card summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; padding: 16px 26px; font-weight: 700; }
.ship-card summary::-webkit-details-marker { display: none; }
.ship-card summary::before { content: "▸"; color: var(--accent); font-size: .9rem; }
.ship-card[open] summary::before { content: "▾"; }
.ship-card summary .muted { font-weight: 500; font-size: .88rem; }
.ship-form { padding: 6px 26px 22px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.ship-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ship-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
@media (max-width: 720px) { .ship-fields { grid-template-columns: 1fr; } }

/* ─── Tenant page ─── */
.hero-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.hero-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hero-row h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.hero-logo { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; background: #fff; padding: 6px; border: 1px solid var(--border); flex: none; }
.hero-logo-text { display: inline-flex; align-items: center; justify-content: center; background: var(--brand-green); color: #fff; font-weight: 800; font-size: 1.4rem; }
.hero-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: .88rem; }
.hero-url { color: var(--accent); text-decoration: none; font-weight: 500; }
.hero-url:hover { text-decoration: underline; }
.action-rows { display: flex; flex-direction: column; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.action-row:first-child { border-top: 0; padding-top: 0; }
.action-row:last-child { padding-bottom: 0; }
.action-row > div:first-child { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.action-row strong { font-size: .93rem; }
.action-row .muted { font-size: .8rem; }
.action-row form { flex: none; display: inline-flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.action-row input[type=number] { width: 72px; padding: 7px 8px; }
.action-row select { padding: 7px 30px 7px 10px; width: auto; }
.action-row input[type=password], .action-row input[type=text] { padding: 7px 10px; width: 200px; }
.danger-card { border-color: color-mix(in srgb, var(--error) 35%, transparent); }
.danger-card summary { cursor: pointer; font-weight: 700; color: var(--error); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; list-style: none; }
.danger-card summary::-webkit-details-marker { display: none; }
.danger-card summary .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.danger-card p { margin: 12px 0; }
.danger-card input { width: auto; }
.tab-empty { display: none; }
.addons:has(#tab-installed:checked) tr[data-bucket]:not([data-bucket="installed"]) { display: none; }
.addons:has(#tab-missing:checked) tr[data-bucket]:not([data-bucket="missing"]) { display: none; }
.addons:has(#tab-updates:checked) tr[data-bucket]:not([data-update="yes"]) { display: none; }
.addons:has(#tab-updates:checked) tbody:not(:has(tr[data-update="yes"])) .tab-empty,
.addons:has(#tab-missing:checked) tbody:not(:has(tr[data-bucket="missing"])) .tab-empty,
.addons:has(#tab-installed:checked) tbody:not(:has(tr[data-bucket="installed"])) .tab-empty { display: table-row; }
.btn-install { border-color: var(--accent); color: var(--accent); }
.btn-install:hover { background: var(--accent-glow); }
.backup-status { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 14px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); }
.backup-status > div:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.backup-status .dot { width: 10px; height: 10px; }
.backup-ok .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.backup-failed { border-color: var(--error); }
.backup-failed .dot { background: var(--error); box-shadow: 0 0 0 4px var(--error-bg); }
.backup-next { text-align: end; font-size: .82rem; line-height: 1.35; }
.backup-next strong { color: var(--text); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: .88rem; align-items: baseline; }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline li.muted { display: block; }
.tl-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-ip { font-size: .78rem; }
.job { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 14px; margin-bottom: 10px; background: var(--surface-2); }
.job summary { cursor: pointer; color: var(--text-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
table.steps { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .88rem; }
table.steps td { padding: 5px 8px; border-top: 1px solid var(--border); color: var(--text-2); }
.step-icon { width: 20px; font-weight: 700; }
.step-ok .step-icon { color: var(--ok); }
.step-failed .step-icon { color: var(--error); }
.step-running .step-icon { color: var(--accent); }
.error-log { background: #121417; color: #f2c9c4; border: 1px solid var(--border); padding: 12px; border-radius: var(--r); font-size: .78rem; overflow-x: auto; white-space: pre-wrap; margin: 10px 0 0; }

/* ─── New tenant form ─── */
.form-card { max-width: 920px; }
.form-section { padding: 22px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section > header h2 { font-size: .95rem; font-weight: 700; margin-bottom: 4px; }
.form-section > header p { color: var(--muted); font-size: .84rem; }
.form-foot { display: flex; align-items: center; gap: 16px; padding-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 760px) { .form-section { grid-template-columns: 1fr; gap: 12px; } }

/* ─── Verification ─── */
.station { display: flex; align-items: center; gap: 16px; }
.station .big-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.station-online .big-dot { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-bg); }
.station-offline .big-dot { background: var(--error); box-shadow: 0 0 0 5px var(--error-bg); }
.station h3 { font-size: 1.05rem; font-weight: 800; }
.station-online h3 { color: var(--ok); } .station-offline h3 { color: var(--error); }
.station p { color: var(--muted); font-size: .86rem; }
.copy-list { display: grid; gap: 8px; margin: 0; }
.copy-row { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.copy-row dt { font-size: .82rem; color: var(--muted); }
.copy-row dd { margin: 0; min-width: 0; }
.copy-row code { display: block; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.copy-btn { font-size: .76rem; padding: 4px 10px; }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }
@media (max-width: 720px) { .copy-row { grid-template-columns: 1fr; gap: 4px; } .copy-row .copy-btn { justify-self: start; } }
.settings-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto; gap: 10px; align-items: end; }
@media (max-width: 760px) { .settings-form { grid-template-columns: 1fr; } }
.jobs-table td pre { margin: 6px 0 0; max-width: 360px; white-space: pre-wrap; font-size: .76rem; color: var(--text-2); background: var(--surface-2); padding: 8px; border-radius: var(--r-sm); border: 1px solid var(--border); }
.jobs-table details summary { cursor: pointer; color: var(--accent); font-size: .82rem; }
.client-form { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 960px) { .client-form { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .client-form { grid-template-columns: 1fr; } }
.num { font-variant-numeric: tabular-nums; }

/* ── Server page ───────────────────────────────────────────────────────────── */
.auto-refresh { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; }
.auto-refresh .chip { padding: 4px 10px; text-transform: none; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 9px 10px; border-radius: var(--r); }
.check .dot { margin-top: 7px; }
.check-ok { background: transparent; }
.check-bad { background: var(--error-bg); }
.check-body { flex: 1 1 auto; min-width: 0; }
.check-name { font-weight: 600; font-size: .92rem; }
.check-detail { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.check-bad .check-detail { color: var(--text); }
.check-ms { font-size: .78rem; font-variant-numeric: tabular-nums; flex: none; margin-top: 3px; }
.sub-title { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 20px 0 10px; }
.disk-list { display: grid; gap: 12px; }
.disk-row { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; margin-bottom: 6px; }
.disk-row code { font-size: .8rem; }
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.meter.warn i { background: var(--warn); }
.meter.bad i { background: var(--error); }
table.data td .meter { margin-top: 5px; max-width: 220px; height: 5px; }
@media (max-width: 960px) { .auto-refresh { flex-wrap: wrap; } }
