/* DashCal server apps (licensing server, sync server, JobManager), on top of dashcal.css. The shell follows Rental Tracker's rail
   (DashCal-Rental-Tracker/app/static/rental.css: caps group labels, 32px rows, accent-soft selection, a top bar and
   drawer on phones); sign-in pages use the Hub's split. Identical in DashCal-Avalonia licensing-server/static and
   server/static and DashCal-JobManager app/static. */

[hidden] { display: none !important; }
body { min-height: 100vh; }
* { scrollbar-width: thin; scrollbar-color: var(--input-border) transparent; }
button, input, select, textarea { font-family: inherit; }
b, strong { font-weight: 600; }
code, kbd, .code { font-family: var(--mono); font-size: 12px; }
code { padding: 1px 5px; border-radius: 3px; background: var(--button); color: var(--text); word-break: break-all; }
pre { margin: 0; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: 16px 0; }
a.link:hover, button.link:hover { text-decoration: underline; }
.link { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.dim { color: var(--text3); } .sub { color: var(--text2); }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); } .accent-text { color: var(--accent-text); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Shell ── */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 16px 12px 14px;
  background: var(--rail); border-right: 1px solid var(--line); }
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; min-width: 0; }
.rail .brand > div { min-width: 0; }
.rail .brand b { display: block; font-size: 13.5px; font-weight: 650; }
.rail .brand small { display: block; color: var(--text3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navgroup { margin: 16px 10px 6px; }
.nav { display: grid; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text2); font-size: 13px; font-weight: 500; }
.nav a > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: var(--button); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .n { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text3); font-variant-numeric: tabular-nums; }
.nav .n.warn { color: var(--warn); background: var(--warn-soft); padding: 1px 6px; border-radius: 9px; }
.nav .n.bad { color: var(--bad); background: var(--bad-soft); padding: 1px 6px; border-radius: 9px; }
.nav a.on .n { color: var(--accent-text); }
.rail .foot { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }
.railbox { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--r); background: var(--pane); border: 1px solid var(--hairline); font-size: 12px; min-width: 0; }
.railbox > div { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.railbox small { display: block; color: var(--text3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.railbox .btn { margin-left: auto; }
.me { display: flex; align-items: center; gap: 9px; padding: 8px 4px 0; border-top: 1px solid var(--hairline); min-width: 0; }
.me > div { min-width: 0; }
.me b { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { display: block; color: var(--text3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .prefs { margin-left: auto; }
.ilink { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 6px; font-size: 11.5px; }
.ilink a, .ilink button { color: var(--text3); background: none; border: 0; padding: 0; font-size: 11.5px; cursor: pointer; }
.ilink a:hover, .ilink button:hover { color: var(--text); }
.theme { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text2);
  display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none; }
.theme:hover { color: var(--text); }
.theme svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Settings gear (the theme_toggle macro; theme.js opens it): a small menu pinned to the viewport. */
.prefs { display: inline-flex; flex: none; }
.prefs.open .theme { color: var(--text); border-color: var(--text3); }
.prefs-menu { position: fixed; z-index: 90; display: grid; gap: 2px; min-width: 150px; padding: 4px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: left; }
.prefs-menu[hidden] { display: none; }
.prefs-cap { padding: 6px 10px 2px; font-size: 9.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); }
.prefs-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text2); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.prefs-menu button:hover { background: var(--button); color: var(--text); }
.prefs-menu svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
html:not(.light) .prefs-menu [data-theme-set="dark"], html.light .prefs-menu [data-theme-set="light"] { color: var(--accent-text); font-weight: 600; }
.m-licensing { background: #E65100; }

.main { min-width: 0; }
.page { padding: 24px 32px 56px; max-width: 1480px; }
.page.narrow { max-width: 1100px; }
.page.form-page { max-width: 980px; }
.mtop { display: none; }
.scrim { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: min(290px, 86vw); height: auto; transform: translateX(-102%);
    transition: transform .2s ease; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .rail.open { transform: none; box-shadow: var(--shadow); }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .5); }
  .mtop { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; background: var(--rail); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mtop b { font-size: 14px; font-weight: 650; }
  .mtop .menubtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r); background: var(--button); border: 0; color: var(--text); cursor: pointer; }
  .mtop .menubtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .mtop .right { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
  .page { padding: 16px 14px 40px; }
  .desk { display: none !important; }
}
@media (min-width: 761px) { .phone { display: none !important; } }

/* ── Page header: caps eyebrow (a back link on detail pages), title, one line of context, actions on the right ── */
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.phead > div:first-child { min-width: 0; }
.phead h1 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; margin-top: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phead .sub { margin-top: 3px; font-size: 13px; }
.phead .caps a { color: var(--text3); }
.phead .caps a:hover { color: var(--text); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { display: contents; }

/* ── Buttons (dashcal.css has .btn, .primary, .ghost, .outline, .block) ── */
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; gap: 6px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn.icon { width: 30px; padding: 0; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger.solid:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn.ghost:hover { background: var(--button); color: var(--text); }
.btn.outline:hover { background: var(--button); }
.btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: default; pointer-events: none; }
.btn.sm svg, .btn.xs svg { width: 14px; height: 14px; }

/* ── Inputs ── */
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input:hover:not(:focus), .select:hover:not(:focus) { border-color: var(--input-hover); }
.input:disabled, .select:disabled, .input[readonly] { opacity: .7; }
.input.sm, .select.sm { height: 32px; font-size: 13px; }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
textarea.input { height: auto; min-height: 76px; padding: 8px 11px; line-height: 1.45; resize: vertical; }
textarea.input.mono { line-height: 1.5; }
.select { appearance: none; height: 38px; padding: 0 30px 0 11px; background: var(--input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8984' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--input-border); border-radius: var(--r-sm); color: var(--text); font: 13.5px var(--font); max-width: 100%; }
.select[multiple] { height: auto; padding: 4px; background-image: none; }
.input[type="file"] { height: auto; padding: 7px 8px; font-size: 12.5px; }
.input[type="file"]::file-selector-button { margin-right: 10px; height: 26px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: var(--button); color: var(--text); font: 600 12px var(--font); cursor: pointer; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input[type="color"] { padding: 3px; width: 54px; }
input[type="checkbox"].cb, input[type="radio"].rb { appearance: none; width: 15px; height: 15px; border: 1px solid var(--input-border); background: var(--input-bg);
  display: inline-grid; place-items: center; margin: 0; cursor: pointer; flex: none; vertical-align: -2px; }
input[type="checkbox"].cb { border-radius: 3px; }
input[type="radio"].rb { border-radius: 50%; }
input[type="checkbox"].cb:checked, input[type="radio"].rb:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"].cb:checked::after { content: ""; width: 4px; height: 8px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
input[type="checkbox"].cb:indeterminate { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"].cb:indeterminate::after { content: ""; width: 7px; height: 2px; background: #fff; }
input[type="radio"].rb:checked::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; }
input.cb:focus-visible, input.rb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input.cb:disabled, input.rb:disabled { opacity: .5; cursor: default; }
/* On/off switch: <label class="switch"><input type="checkbox" ...><i></i>Label</label> */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { position: relative; width: 30px; height: 17px; border-radius: 9px; background: var(--input-border); flex: none; transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(13px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { cursor: pointer; }
.pw .input { padding-right: 52px; }
.pw .show { background: none; border: 0; padding: 4px; cursor: pointer; font-family: inherit; }
.pw .show:hover { color: var(--text); }
.check input { flex: none; }

/* ── Forms ── */
.field { min-width: 0; }
.field .hint, .frow .hint { margin-top: 2px; line-height: 1.45; }
.field label .dim, .frow > label .dim { font-weight: 400; }
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.fields.three { grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.fields .span { grid-column: 1 / -1; }
/* Label-left rows, as in DashCal desktop's settings and dialogs. */
.frows { display: grid; gap: 12px; }
.frow { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 4px 16px; align-items: start; }
.frow > label, .frow > .lbl { padding-top: 10px; font-size: 12.5px; color: var(--text2); font-weight: 500; }
.frow > .ctl { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.frow > .ctl.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.frow.tight > label, .frow.tight > .lbl { padding-top: 5px; }
.inline-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-fields .input, .inline-fields .select { width: auto; }
.inline-fields label { font-size: 12.5px; color: var(--text2); display: inline-flex; align-items: center; gap: 8px; }
.w-xs { width: 90px !important; } .w-sm { width: 140px !important; } .w-md { width: 260px !important; } .w-lg { width: 420px !important; max-width: 100%; }
.form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.form-foot .start { margin-right: auto; display: flex; gap: 10px; align-items: center; }
.sticky-foot { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 18px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.sticky-foot .start { margin-right: auto; font-size: 12px; color: var(--text3); }
@media (max-width: 760px) {
  .fields.two, .fields.three { grid-template-columns: 1fr; }
  .frow { grid-template-columns: minmax(0, 1fr); }
  .frow > label, .frow > .lbl { padding-top: 0; }
}

/* ── Notices ── */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); font-size: 12.5px; line-height: 1.45; margin-bottom: 14px; }
.notice > svg { width: 15px; height: 15px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.notice > span, .notice > div { flex: 1; min-width: 0; }
.notice b { font-weight: 600; }
.notice a { text-decoration: underline; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--text); }
.notice.info > svg { color: var(--accent-text); }
.notice .dismiss { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.notice .dismiss:hover { opacity: 1; }
.notice.flat { margin-bottom: 0; }

/* ── Pills (dashcal.css has ok, warn, accent, muted, outline) ── */
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.warnline { color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.badline { color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.sm { height: 17px; font-size: 9.5px; padding: 0 6px; }
.pill .dot { width: 6px; height: 6px; }
.pill.ok .dot { background: var(--ok); } .pill.warn .dot { background: var(--warn); } .pill.bad .dot { background: var(--bad); }
.pill.accent .dot { background: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--r-sm); background: var(--button); color: var(--text2); font-size: 11.5px; font-weight: 500; white-space: nowrap; }

/* ── Cards and sections ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.card > header h2 { font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card > header p { color: var(--text3); font-size: 12px; margin-top: 2px; }
.card > header .actions { margin-left: auto; }
.card > .body { padding: 16px; }
.card > .body + .body { border-top: 1px solid var(--hairline); }
.card > .tbl, .card > .tblscroll { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.tblscroll { overflow-x: auto; }
.card > .list { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.list > .row .end { margin-left: auto; color: var(--text3); }
.card > footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--hairline); background: var(--pane); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
.card > footer .start { margin-right: auto; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.card.danger > header h2 { color: var(--bad); }
.card.accent { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.stack { display: grid; gap: 18px; align-content: start; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.split-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
/* Un-boxed section: caps header with an optional aside, then content (desktop's Section pattern). */
.sect { display: grid; gap: 10px; min-width: 0; }
.sect + .sect { margin-top: 26px; }
.sect > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sect > header .hint { font-size: 12px; }
.sect > header .actions { margin-left: auto; }
/* Fact rows: label left, value right (Hub admin's side card). */
.facts { display: grid; }
.fact { display: grid; grid-template-columns: minmax(96px, 36%) minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; min-height: 44px; }
.fact:last-child { border-bottom: 0; }
.fact > span:first-child { color: var(--text2); font-size: 12.5px; }
.fact small { display: block; color: var(--text3); font-size: 11.5px; }
.fact > div { min-width: 0; }
.card > .body > .facts { margin: -10px 0; }

/* ── KPI strip ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { position: relative; overflow: hidden; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: grid; gap: 4px; align-content: start; min-width: 0; }
a.kpi:hover { border-color: var(--input-border); }
.kpi b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b small { font-size: 13px; font-weight: 500; color: var(--text3); letter-spacing: 0; }
.kpi p { font-size: 12px; color: var(--text3); }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); } .kpi.warn b { color: var(--warn); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); } .kpi.bad b { color: var(--bad); }
.kpi.ok b { color: var(--ok); }
.kpi.accent { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

/* ── Toolbar, filter chips, segmented control, search ── */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 12px; flex-wrap: wrap; }
.toolbar .search { flex: 1; max-width: 380px; min-width: 200px; }
.toolbar .end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.toolbar form { display: contents; }
.toolbar form.search { display: block; }
.toolbar form.end { display: flex; }
.toolbar .select, .toolbar .input { height: 34px; font-size: 13px; width: auto; }
.toolbar .search .input { width: 100%; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--text3); stroke-width: 2; pointer-events: none; }
.search .input { padding-left: 32px; height: 34px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips a, .chips button { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text2); font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.chips a:hover, .chips button:hover { color: var(--text); border-color: var(--input-border); }
.chips a.on, .chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chips b { font-weight: 600; font-size: 11.5px; opacity: .8; }
.chips .warn b { color: var(--warn); opacity: 1; } .chips .bad b { color: var(--bad); opacity: 1; }
.chips .on b { color: #fff; }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r); background: var(--button); }
.seg a, .seg button { height: 28px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: var(--r-sm); background: none; font-size: 12.5px; color: var(--text2); cursor: pointer; }
.seg a.on, .seg button.on, .seg .is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.count { color: var(--text3); font-weight: 500; font-size: 12.5px; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .chips a, .chips button { flex: none; }
  .toolbar .search { flex-basis: 100%; max-width: none; }
  .toolbar .end { margin-left: 0; }
}

/* ── In-page tabs (admin.js: data-tab-group / data-tab / data-tab-panel) ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs .tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border: 0; background: none; color: var(--text2);
  font: 500 13px var(--font); cursor: pointer; white-space: nowrap; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.is-active { color: var(--text); font-weight: 600; }
.tabs .tab.is-active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tabs .tab .n { font-size: 11px; font-weight: 600; color: var(--text3); }
.tabs .tab .n.warn { color: var(--warn); } .tabs .tab .n.bad { color: var(--bad); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ── Tables ── */
.tblwrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { height: 34px; padding: 0 12px; text-align: left; background: var(--pane); border-bottom: 1px solid var(--line);
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); white-space: nowrap; }
.tbl thead tr:first-child th:first-child { border-top-left-radius: var(--r-lg); } .tbl thead tr:first-child th:last-child { border-top-right-radius: var(--r-lg); }
.card .tbl thead th { border-radius: 0 !important; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl th.c, .tbl td.c { text-align: center; }
.tbl th.act, .tbl td.act { text-align: right; width: 1%; white-space: nowrap; }
.tbl td { height: 44px; padding: 6px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.go { cursor: pointer; }
.tbl tbody tr.go:hover td, .tbl tbody tr.hover:hover td { background: color-mix(in srgb, var(--text) 3.5%, var(--surface)); }
.tbl tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tbl tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl tr.accent td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tbl tr.muted td { color: var(--text3); }
.tbl td .t { font-weight: 600; color: var(--text); }
.tbl td .t:hover { color: var(--accent-text); }
.tbl td small, .tbl td .s { display: block; color: var(--text3); font-size: 11.5px; margin-top: 1px; }
.tbl td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.wrap { white-space: normal; }
.tbl td .row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.tbl td .row-actions form { display: contents; }
.tbl tfoot td { height: 38px; background: var(--pane); border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; font-size: 12.5px; }
.tbl .empty, td.empty { height: 96px; text-align: center; color: var(--text3); }
.tbl.compact td { height: 36px; padding: 4px 12px; }
.tbl.fixed { table-layout: fixed; }
.empty { padding: 34px 20px; text-align: center; color: var(--text3); font-size: 13px; }
.empty b { display: block; color: var(--text2); font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.tblwrap > .empty, .card > .empty { border: 0; }
div.empty.boxed { border: 1px dashed var(--input-border); border-radius: var(--r-lg); background: var(--surface); }

/* ── Overflow menu: <div class="menu-wrap"><button class="btn sm icon" data-menu>…</button><div class="menu">…</div></div> ── */
.menu-wrap { position: relative; display: inline-block; }
.menu-wrap > .menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px; padding: 4px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: left; }
.menu-wrap.open > .menu { display: grid; }
.menu-wrap > .menu.pinned { position: fixed; right: auto; bottom: auto; }
.menu form { display: block; margin: 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text2);
  font: 500 12.5px var(--font); cursor: pointer; text-align: left; white-space: nowrap; }
.menu a:hover, .menu button:hover { background: var(--button); color: var(--text); }
.menu .bad, .menu .danger { color: var(--bad); }
.menu .bad:hover, .menu .danger:hover { background: var(--bad-soft); color: var(--bad); }
.menu hr { margin: 4px 2px; }
.menu .caps { padding: 6px 10px 2px; font-size: 9.5px; }

/* ── Permission grid (licensing partials/_perm_grid.html): the permission tree; group rows with an n/m summary
   expand to their leaves and nested groups ── */
.perm-grid { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.perm-category-block + .perm-category-block { border-top: 1px solid var(--hairline); }
.perm-category-header { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 14px 6px 10px; cursor: pointer; }
.perm-category-header:hover, .perm-subgroup-header:hover { background: color-mix(in srgb, var(--text) 3.5%, var(--surface)); }
.perm-cat-arrow { display: inline-grid; place-items: center; width: 16px; color: var(--text3); transition: transform .15s; flex: none; }
.perm-cat-arrow .ico { width: 14px; height: 14px; }
.perm-cat-arrow.collapsed { transform: rotate(-90deg); }
.perm-cat-label { display: inline-flex; align-items: center; flex: none; cursor: pointer; }
.perm-cat-name { flex: none; padding: 0; border: 0; background: none; color: var(--text); font: 600 13px var(--font); cursor: pointer; text-align: left; white-space: nowrap; }
.perm-cat-desc { flex: 1; min-width: 0; color: var(--text3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-cat-summary { margin-left: auto; flex: none; min-width: 40px; padding: 1px 7px; border-radius: 9px; background: var(--button); color: var(--text2);
  font-size: 11.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.perm-cat-actions, .perm-subgroup-body { display: flex; flex-direction: column; gap: 1px; }
.perm-cat-actions { padding: 2px 14px 12px 40px; }
.perm-subgroup { border-left: 2px solid var(--hairline); padding-left: 10px; margin: 4px 0; }
.perm-subgroup-header { display: flex; align-items: center; gap: 10px; min-height: 30px; margin-left: -12px; padding: 2px 4px; border-radius: var(--r); cursor: pointer; }
.perm-subgroup-header .perm-cat-name { font-size: 12.5px; }
.perm-subgroup-body { padding: 2px 0 4px 22px; }
/* One permission per row: checkbox and name, its short description, then how many actions it covers. */
.perm-leaf { display: grid; grid-template-columns: minmax(180px, max-content) minmax(0, 1fr) auto; align-items: baseline; column-gap: 14px;
  padding: 4px 6px; border-radius: var(--r); color: var(--text2); font-size: 12.5px; }
.perm-leaf:hover { background: color-mix(in srgb, var(--text) 3%, var(--surface)); }
.perm-leaf[hidden], .perm-subgroup[hidden], .perm-category-block[hidden] { display: none; }
.perm-leaf-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; cursor: pointer; color: var(--text); }
.perm-leaf-main .cb { align-self: center; }
.perm-leaf-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text3); font-size: 12px; }
.perm-more { flex: none; padding: 1px 8px; border: 1px solid var(--line); border-radius: 9px; background: none; color: var(--text3);
  font: 500 11px var(--font); white-space: nowrap; cursor: pointer; }
.perm-more:hover, .perm-more[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }
.perm-ast { margin-left: 2px; color: var(--warn); font-weight: 700; cursor: help; }
.perm-badge { display: inline-block; margin-left: 2px; padding: 0 6px; border-radius: 8px; background: var(--button); color: var(--text3); font-size: 10.5px; font-weight: 600; white-space: nowrap; }
/* The opened row: full description, relationships (cross-group ones marked), and the actions it covers. */
.perm-detail { grid-column: 1 / -1; margin: 6px 0 4px 26px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: var(--r);
  background: var(--surface2, color-mix(in srgb, var(--text) 2.5%, var(--surface))); color: var(--text2); font-size: 12px; line-height: 1.45; }
.perm-group-detail { margin: 2px 14px 8px 40px; }
.perm-detail-desc { margin: 0 0 4px; color: var(--text); }
.perm-detail-key { display: inline-block; margin-bottom: 8px; color: var(--text3); font-size: 11px; }
.perm-detail-h { margin: 8px 0 4px; color: var(--text); font-weight: 600; font-size: 11.5px; }
.perm-rel ul, .perm-actions ul { margin: 0; padding: 0; list-style: none; }
.perm-rel li { position: relative; margin: 0 0 6px; padding-left: 12px; }
.perm-rel li::before { content: ""; position: absolute; left: 0; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--text3); }
.perm-rel-cross li::before { background: var(--warn); }
.perm-rel-why { display: block; color: var(--text3); }
.perm-rel-id { margin-left: 6px; color: var(--text3); font-size: 10.5px; }
.perm-actions li { display: flex; gap: 8px; padding: 1px 0; }
.perm-act-id { flex: none; min-width: 62px; color: var(--text3); font: 11px var(--mono, ui-monospace, monospace); }
.perm-actions .btn { margin-top: 4px; }
.perm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
.perm-search { flex: 1 1 260px; max-width: 420px; height: 32px; }
.perm-cross-only { display: inline-flex; align-items: center; gap: 6px; color: var(--text2); font-size: 12.5px; cursor: pointer; }
.perm-legend { color: var(--text3); font-size: 12px; }
.perm-grid-note { margin: 0; padding: 10px 14px; border-top: 1px solid var(--hairline); color: var(--text3); font-size: 12px; }
@media (max-width: 760px) {
  .perm-category-header { flex-wrap: wrap; row-gap: 2px; }
  .perm-cat-name { white-space: normal; flex: 1; min-width: 0; }
  .perm-cat-desc { order: 5; flex-basis: 100%; padding-left: 51px; white-space: normal; }
  .perm-cat-actions { padding-left: 14px; }
  .perm-subgroup-body { padding-left: 10px; }
  .perm-leaf { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .perm-leaf-desc { grid-column: 1 / -1; grid-row: 2; padding-left: 26px; white-space: normal; }
  .perm-detail { margin-left: 0; }
}

/* ── Code and logs ── */
.codebox { font-family: var(--mono); font-size: 12px; line-height: 1.55; padding: 10px 12px; border-radius: var(--r); background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text); white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 360px; }
.secret { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--input-bg); border: 1px solid var(--input-border); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.secret > span { flex: 1; min-width: 0; }

/* ── Drawer (side sheet): <div class="drawer" id="x"> + <div class="drawer-overlay" id="x-overlay"> (admin.js openDrawer/closeDrawer) ── */
.drawer-overlay { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); }
.drawer-overlay.is-open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(480px, 100vw); display: flex; flex-direction: column; background: var(--bg);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(102%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
.drawer.is-open { transform: none; visibility: visible; }
.drawer > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--rail); }
.drawer > header h2 { font-size: 16px; font-weight: 650; }
.drawer > header p { color: var(--text3); font-size: 12px; margin-top: 2px; }
/* The body and footer may sit inside a <form> that fills the drawer. */
.drawer > form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drawer > .body, .drawer > form > .body { flex: 1; overflow-y: auto; padding: 18px 20px; display: grid; gap: 14px; align-content: start; }
.drawer .body > * { min-width: 0; }
.drawer > footer, .drawer > form > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--rail); }

/* ── Collapsible header arrow (admin.js data-collapse) ── */
.collapse-arrow { display: inline-block; transition: transform .15s; color: var(--text3); }
.collapse-arrow.collapsed { transform: rotate(-90deg); }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ── Sign-in, account and setup pages: the Hub's split (DashCal-Hub/app/templates/login.html) ── */
.split { display: grid; grid-template-columns: 560px 1fr; min-height: 100vh; }
.split .left { background: var(--rail); border-right: 1px solid var(--line); padding: 34px 44px; display: flex; flex-direction: column; }
.split .org { display: flex; gap: 14px; align-items: center; }
.split .org b { display: block; font-size: 15px; font-weight: 650; }
.split .org div > span { font-size: 12px; color: var(--text3); }
.split .ctx { margin: auto 0; padding: 40px 0; display: grid; gap: 18px; }
.split .ctx h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.split .ctx h1 em { font-style: normal; color: var(--accent-text); }
.split .ctx p { color: var(--text2); font-size: 14px; max-width: 420px; }
.split .ctx .list { max-width: 440px; }
.split .ctx .list .row { gap: 12px; font-size: 13px; color: var(--text2); }
.split .ctx .list .row svg { width: 16px; height: 16px; color: var(--accent-text); }
.split .lfoot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--text3); }
.split .lfoot .links { display: flex; align-items: center; gap: 14px; }
.split .right { display: grid; place-items: center; padding: 40px; }
.split .form { width: min(380px, 100%); display: grid; gap: 16px; }
.split .form.wide { width: min(460px, 100%); }
.split .form h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.split .form .notice { margin: 0; }
.split .row2 { display: flex; justify-content: space-between; align-items: center; }
.split .note { font-size: 12px; color: var(--text3); line-height: 1.55; }
.split .alt { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text2); }
.split .result { display: grid; gap: 14px; justify-items: start; }
.split .result .badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.split .result .badge svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.split .result .badge.ok { background: var(--ok-soft); color: var(--ok); }
.split .result .badge.bad { background: var(--bad-soft); color: var(--bad); }
.split .result .badge.warn { background: var(--warn-soft); color: var(--warn); }
.split .result .badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.split .result p { color: var(--text2); line-height: 1.55; }
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .split .left { border-right: 0; border-bottom: 1px solid var(--line); padding: 24px; }
  .split .ctx { padding: 24px 0 8px; } .split .ctx p, .split .ctx .list { display: none; }
  .split .right { padding: 28px 24px; }
}
