/* dockie SPA - native CSS. Tokens and components are specified in docs/ui-style-guide.md;
   change that guide first when adding a pattern. No hard-coded colours outside :root. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --hover: #f1f5fa;
  --border: #dfe3e8;
  --text: #1f2933;
  --muted: #66707c;
  --link: #1f5fbf;
  --accent: #1e3f75;
  --accent-hover: #17335f;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --on-danger: #ffffff;
  --warn: #8a5300;
  --warn-bg: #fdf3e0;
  --ok: #1a7f4b;
  --ok-bg: #e6f4ec;
  --focus: #ffd54a;
  --m-get: #1f5fbf;
  --m-post: #1a7f4b;
  --m-put: #9a5b00;
  --m-patch: #7a4bb5;
  --m-delete: #b42318;
  /* The Jarvis orb uses the C4X website style (c4x-website-style): a dark glass sphere, three lights moving inside it, a teal / gold halo.
     These are the same in light and dark themes on purpose; only the pop-up panel follows Dockie's own tokens. */
  --jarvis-accent: #00a4bf;
  --jarvis-accent-dark: #00c0ce;
  --jarvis-gold: #e8b84b;
  --jarvis-sphere-1: #1c405c;
  --jarvis-sphere-2: #08141f;
  --jarvis-blob-1: #8fe3ff;
  --jarvis-blob-2: #ffb0e6;
  --jarvis-blob-3: #f3d17a;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-base: 13px;
  --fs-small: 12px;
  --fs-title: 20px;
  --fs-section: 15px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --radius: 4px;
  --topbar-h: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #16222e;
    --surface-alt: #1a2734;
    --hover: #1d2d3d;
    --border: #2a3a4a;
    --text: #e6eef6;
    --muted: #9db0c2;
    --link: #7fb2f0;
    --accent: #3b6bb5;
    --accent-hover: #4a7ac4;
    --danger: #ff8a80;
    --danger-bg: #3a1c1c;
    --on-danger: #2b0f0f;
    --warn: #f2c066;
    --warn-bg: #3a2c12;
    --ok: #7fd3a1;
    --ok-bg: #16301f;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: var(--fs-title); font-weight: 600; margin: 0; }
h2 { font-size: var(--fs-section); font-weight: 600; margin: var(--space-4) 0 var(--space-2); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: var(--fs-small); }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.6; cursor: default; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.loading { padding: var(--space-5); color: var(--muted); }

/* ---- Top bar and tabs ---- */
.topbar {
  background: var(--surface);
  color: var(--text);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; font-weight: 600; font-size: var(--fs-section); color: var(--accent); }
.topbar .spacer { flex: 1; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; color: var(--muted); border-radius: var(--radius); }
.bell:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.bell-count { position: absolute; top: 0; right: -2px; min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; font-weight: 600; }
.bell-count[hidden] { display: none; }
.topbar .user { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); }
.topbar nav { display: flex; }
.tabs { display: flex; align-items: stretch; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.tabs li { display: flex; }
.tabs a {
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  color: var(--text);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface-alt); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Layout ---- */
.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-3) var(--space-2);
  width: 220px;
  flex-shrink: 0;
}
.sidebar .client-name { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-3); font-weight: 600; }
.sidebar .back { display: block; padding: var(--space-1) var(--space-2) var(--space-3); font-size: var(--fs-small); }
.nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-list a { display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--text); }
.nav-list a:hover { background: var(--hover); text-decoration: none; }
.nav-list a[aria-current="page"] { background: var(--hover); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }

.content { flex: 1; padding: var(--space-4); max-width: 1100px; width: 100%; margin: 0 auto; min-width: 0; }
.content.wide { max-width: none; margin: 0; }
.content.narrow { max-width: 420px; }
.stack { margin-top: var(--space-3); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.pre { font-size: var(--fs-small); white-space: pre-wrap; }
.card > h2:first-child { margin-top: 0; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-actions { display: flex; gap: var(--space-2); align-items: center; }

/* ---- Cards, lists, notices ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
}
.cluster { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.list { display: flex; flex-direction: column; gap: var(--space-1); padding: 0; margin: 0; list-style: none; }
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
}
.list-item:hover { background: var(--hover); }
.meta { font-size: var(--fs-small); color: var(--muted); }
.notice { color: var(--muted); font-size: var(--fs-small); }
.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}
.badge { display: inline-block; padding: 1px var(--space-2); border: 1px solid var(--border); border-radius: 999px; font-size: var(--fs-small); background: var(--surface-alt); }
.badge-muted { color: var(--muted); }

/* ---- Buttons ---- */
button, .btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-3);
  min-height: 28px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button:hover:not(:disabled), .btn:hover { background: var(--hover); text-decoration: none; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary, .btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
button.danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.topbar button { min-height: 28px; }

/* ---- Forms ---- */
.form-row { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.form-row label { font-weight: 600; }
.form-row input, .form-row textarea, .form-row select, .search input, .editor-title, .pager select {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.form-row textarea { min-height: 140px; resize: vertical; }
.input-group { display: flex; gap: var(--space-2); align-items: center; }
.input-group input { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---- Clients list / data tables ---- */
.subtabs { display: flex; gap: var(--space-4); border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); }
.subtabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: var(--space-2) var(--space-1); min-height: 0; }
.subtabs button[aria-selected="true"] { border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: var(--space-3); align-items: center; margin-bottom: var(--space-2); }
.toolbar input { min-height: 28px; padding: var(--space-1) var(--space-3); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.toolbar input[type="text"], .toolbar input:not([type]) { flex: 0 1 20rem; min-width: 0; }
.search { flex: 1; }
.search input { width: 100%; }
.az-bar { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: var(--space-2); }
.az-bar button { background: none; border: none; padding: 0 var(--space-1); min-height: 22px; min-width: 18px; justify-content: center; color: var(--link); font-size: var(--fs-small); }
.az-bar button[aria-pressed="true"] { font-weight: 700; color: var(--text); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.data-table th, .data-table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: var(--surface-alt); font-weight: 600; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table button.sort { background: none; border: none; padding: 0; min-height: 0; font-weight: 600; }
.data-table .name-cell { display: flex; align-items: center; gap: var(--space-2); }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; font-size: var(--fs-small); color: var(--muted); }
.pager button { min-width: 26px; justify-content: center; }
.pager button[aria-current="page"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.avatar.has-logo { background: var(--surface) !important; border: 1px solid var(--border); }
.avatar-lg { width: 56px; height: 56px; border-radius: var(--radius); font-size: 20px; }
.recents { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-4); }
.recents-section summary { font-size: var(--fs-section); font-weight: 600; cursor: pointer; margin-bottom: var(--space-3); }
.recent-tile { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); width: 84px; color: var(--text); font-size: var(--fs-small); }
.recent-tile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Admin hub and sidebar ---- */
.nav-group { margin-bottom: var(--space-2); }
.nav-group summary { cursor: pointer; padding: var(--space-1) var(--space-2); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.nav-list .icon { margin-right: var(--space-2); vertical-align: -3px; color: var(--muted); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.tile { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.tile:hover { background: var(--hover); text-decoration: none; }
.tile .meta { display: block; }
.tile-icon { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; }

.section { max-width: 640px; margin-bottom: var(--space-5); }
.section > h2:first-child { margin-top: 0; }

/* ---- Tables in admin pages ---- */
.nowrap { white-space: nowrap; }
.row-actions { width: 1%; text-align: center; }
.icon-btn { background: none; border: none; color: var(--danger); padding: var(--space-1); min-height: 0; border-radius: var(--radius); }
.icon-btn:hover:not(:disabled) { background: var(--danger-bg); }
fieldset.form-row { border: none; padding: 0; margin: 0 0 var(--space-3); }
fieldset.form-row legend { font-weight: 600; padding: 0; margin-bottom: var(--space-1); }
.code-block { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); overflow-x: auto; margin: var(--space-2) 0; }

/* ---- API documentation ---- */
.section.wide { max-width: 900px; }
.api-tag { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-2); }
.api-tag > summary { cursor: pointer; padding: var(--space-3) var(--space-4); font-size: var(--fs-section); font-weight: 600; text-transform: capitalize; }
.api-tag > summary .meta { font-weight: 400; margin-left: var(--space-2); text-transform: none; }
.api-op { border-top: 1px solid var(--border); }
.api-op > summary { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); cursor: pointer; }
.api-op > summary:hover { background: var(--hover); }
.api-path { font-weight: 600; }
.api-summary { color: var(--muted); flex: 1; min-width: 0; }
.api-body { padding: var(--space-2) var(--space-4) var(--space-4); background: var(--surface-alt); border-top: 1px solid var(--border); }
.api-body h3 { font-size: var(--fs-base); margin: var(--space-4) 0 var(--space-2); }
.api-response { margin-bottom: var(--space-2); }
.method { display: inline-block; min-width: 64px; text-align: center; padding: 2px var(--space-2); border-radius: var(--radius); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; }
.m-get { background: var(--m-get); } .m-post { background: var(--m-post); } .m-put { background: var(--m-put); }
.m-patch { background: var(--m-patch); } .m-delete { background: var(--m-delete); }
.status { display: inline-block; min-width: 36px; text-align: center; font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.s-2 { color: var(--m-post); } .s-3 { color: var(--m-get); } .s-4 { color: var(--m-put); } .s-5 { color: var(--m-delete); }
.schema-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); background: var(--surface); margin: var(--space-2) 0; }
.schema-table th, .schema-table td { text-align: left; padding: var(--space-1) var(--space-2); border: 1px solid var(--border); vertical-align: top; }
.schema-table th { background: var(--surface-alt); }
.schema-table .schema-table { margin: var(--space-1) 0 0; }
.req { color: var(--danger); font-weight: 700; }
fieldset.authorize { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); }
fieldset.authorize legend { font-weight: 600; padding: 0 var(--space-1); }
.try-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.try-form .form-row label { font-weight: 400; }
.try-form textarea, .try-form input { width: 100%; }
.try-result { margin-top: var(--space-3); }

/* ---- Asset layouts ---- */
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
/* ---- Roles and groups ---- */
.role-cell { display: inline-block; margin: 0 var(--space-3) var(--space-1) 0; white-space: nowrap; }
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); }
.pick-list label[hidden] { display: none; }
/* ---- Reports ---- */
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.narrow-input { width: 90px; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
/* ---- Notifications and branding ---- */
.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.note { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.note.unread { border-left: 3px solid var(--accent); background: var(--surface-alt); }
.note-body { display: flex; flex-direction: column; gap: var(--space-1); width: 100%; text-align: left; background: none; border: none; padding: var(--space-3); white-space: pre-line; }
.note-title { font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.note .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.color-pair { display: flex; gap: var(--space-2); align-items: center; }
.color-pair input[type="color"] { width: 44px; height: 34px; padding: 2px; }
/* ---- Procedures ---- */
button.linklike { background: none; border: none; padding: 0; min-height: 0; color: var(--link); text-decoration: underline; }
.run-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.run-steps .card h2 { margin-top: 0; }
.step-row { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); }
.step-row legend { font-weight: 600; padding: 0 var(--space-1); }
/* ---- Global map ---- */
.map-all { height: 460px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-3); }
@media (max-width: 820px) { .map-all { height: 320px; } }
/* ---- Expirations ---- */
.stat-row { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-2) 0 var(--space-3); }
.stat { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat strong { font-size: var(--fs-title); margin-right: var(--space-1); }
.stat-danger { border-color: var(--danger); background: var(--danger-bg); }
.stat-warn { border-color: var(--warn); background: var(--warn-bg); }
td.row-actions { white-space: nowrap; width: auto; text-align: right; }
td.row-actions button + button { margin-left: var(--space-1); }
.meta.block { display: block; }
.pad { padding: var(--space-2) var(--space-4); }
.error-text { color: var(--danger); }
button.danger-text { color: var(--danger); }
.layout-groups { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.layout-folder { border-bottom: 1px solid var(--border); }
.layout-folder:last-child { border-bottom: none; }
.layout-folder > summary { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); cursor: pointer; font-weight: 600; }
.folder-name { display: inline-flex; align-items: center; gap: var(--space-2); }
.folder-actions { display: inline-flex; gap: var(--space-1); }
.icon-btn.plain { color: var(--muted); }
.icon-btn.plain:hover:not(:disabled) { background: var(--hover); }
.layout-list { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-3) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.layout-item { display: flex; align-items: center; gap: var(--space-3); color: var(--text); }
.layout-name { color: var(--link); }
.layout-icon { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); max-width: 960px; }
.template-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.template-card[hidden] { display: none; }
.template-card h3 { margin: 0; font-size: var(--fs-section); }
.template-card .page-actions { margin-top: auto; padding-top: var(--space-2); }

/* ---- Builder (full screen) ---- */
.builder { display: flex; flex-direction: column; min-height: 100vh; }
.builder-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--surface); border-bottom: 1px solid var(--border); }
.builder-top .menu { justify-self: end; }
.builder-title { display: flex; align-items: center; gap: var(--space-2); justify-self: center; }
.title-input { font-size: var(--fs-title); font-weight: 600; border: 1px solid transparent; background: transparent; border-radius: var(--radius); padding: 2px var(--space-2); min-width: 14ch; text-align: center; color: var(--text); }
.title-input:hover, .title-input:focus { border-color: var(--border); background: var(--surface); }
.builder-tabs { display: flex; justify-content: center; gap: var(--space-5); background: var(--surface); border-bottom: 1px solid var(--border); }
.builder-tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: var(--space-2) var(--space-3); min-height: 0; }
.builder-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); font-weight: 600; }
.builder-body { flex: 1; min-height: 0; }
.builder-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--surface); border-top: 1px solid var(--border); }
.builder-build { display: grid; grid-template-columns: 200px 1fr; min-height: 60vh; }
.palette { background: var(--surface); border-right: 1px solid var(--border); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.palette-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: var(--space-3) 0 var(--space-1); }
.palette-title:first-child { margin-top: 0; }
.palette-item { justify-content: flex-start; gap: var(--space-2); width: 100%; }
.builder-tabs .icon { vertical-align: -3px; }
.canvas { padding: var(--space-4); }
.canvas-empty { display: flex; align-items: center; justify-content: center; min-height: 50vh; text-align: center; }
.form-preview { max-width: 520px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); min-height: 70vh; }
.field-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: start; border: 1px solid transparent; border-radius: var(--radius); padding: var(--space-1) var(--space-2); }
.field-row:hover { border-color: var(--border); }
.field-row.selected { border-color: var(--accent); background: var(--surface-alt); }
.field-row.drop-target, [data-line].drop-target { box-shadow: 0 -3px 0 var(--accent); }
.fp-main { cursor: pointer; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; border-radius: var(--radius); }
.fp-label { font-size: var(--fs-small); }
.fp-control { width: 100%; pointer-events: none; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); color: var(--muted); }
.fp-check { display: flex; align-items: center; gap: var(--space-2); pointer-events: none; }
.fp-add { align-self: flex-start; background: none; border: none; color: var(--muted); padding: 0; min-height: 0; }
.fp-heading { margin: var(--space-2) 0 0; font-size: var(--fs-section); }
.fp-divider { border: none; border-top: 1px solid var(--border); width: 100%; margin: var(--space-2) 0; }
.fp-hint { font-size: var(--fs-small); color: var(--muted); }
.fp-side { display: flex; align-items: center; gap: var(--space-1); padding-top: var(--space-1); }
.drag-handle { cursor: grab; color: var(--muted); display: inline-flex; align-items: center; padding: var(--space-1); border-radius: var(--radius); }
.drag-handle:active { cursor: grabbing; }
.fp-editor { grid-column: 1 / -1; margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.builder-settings { max-width: 560px; margin: 0 auto; padding: var(--space-4); }
.builder-settings h2 { margin-top: var(--space-5); }
.icon-preview { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
.icon-group h3 { font-size: var(--fs-small); color: var(--muted); margin: var(--space-3) 0 var(--space-1); }
.icon-grid { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.icon-choice { width: 32px; height: 32px; padding: 0; justify-content: center; }
.icon-choice[aria-pressed="true"] { background: var(--hover); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.builder-qr { display: grid; grid-template-columns: minmax(180px, 240px) minmax(280px, 420px); gap: var(--space-5); justify-content: center; padding: var(--space-4); }
.qr-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); display: flex; flex-direction: column; align-items: center; text-align: center; font-size: var(--fs-small); width: 100%; max-height: 520px; overflow: hidden; }
.qr-code { width: 78%; color: #000; }
.qr-code svg { display: block; width: 100%; height: auto; }
.qr-title { margin-top: var(--space-2); }
.qr-card hr { width: 80%; border: none; border-top: 1px solid var(--border); margin: var(--space-2) 0; }
.qr-line-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.qr-line-list li { display: flex; align-items: center; gap: var(--space-2); }
.qr-line-list select { flex: 1; padding: var(--space-2) var(--space-3); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--space-1) var(--space-2); }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 60; min-width: 190px; list-style: none; margin: 0; padding: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.menu-list button { width: 100%; justify-content: flex-start; gap: var(--space-2); border: none; background: none; }
.menu-list button:hover { background: var(--hover); }
.menu-list hr { border: none; border-top: 1px solid var(--border); margin: var(--space-1) 0; }
.share-page { max-width: 820px; }
.share-content { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: var(--fs-base); margin: var(--space-3) 0 0; }

.overview-card { padding: 0; overflow: hidden; }
.banner { height: 120px; background: var(--surface-alt); border-bottom: 1px solid var(--border); }
.banner-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.info-strip { display: flex; flex-wrap: wrap; gap: var(--space-3) 0; padding: var(--space-3) var(--space-4); font-size: var(--fs-small); }
.info-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-right: var(--space-4); margin-right: var(--space-4); border-right: 1px solid var(--border); }
.info-cell:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.info-cell .icon, .inline-link .icon { width: 12px; height: 12px; vertical-align: -1px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--space-3); }
.dash-panel { display: flex; flex-direction: column; height: 300px; min-height: 0; }   /* every card the same size; long lists scroll inside */
.dash-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-color: var(--border) transparent; }
.dash-more { margin: var(--space-2) 0 0; text-align: right; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-4); text-align: center; }
.dash-stats strong { display: block; font-size: var(--fs-title); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.topbar a.brand { text-decoration: none; }
.overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.panel { min-height: 220px; }
.panel h2 { margin: 0 0 var(--space-3); font-size: var(--fs-section); }
.visit-list, .feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.visit-item { display: flex; align-items: center; gap: var(--space-2); color: var(--text); }
.visit-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feed-item { display: flex; gap: var(--space-2); align-items: flex-start; }
.feed-title { color: var(--link); }
a.icon-btn { display: inline-flex; align-items: center; padding: var(--space-1) var(--space-2); border-radius: var(--radius); text-decoration: none; }
a.icon-btn:hover { background: var(--hover); }
.map-card .map-img { display: block; width: 100%; max-width: 640px; aspect-ratio: 2 / 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-alt); }
.map-card .meta { margin: var(--space-2) 0; }

/* ---- Client pages ---- */
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-small); margin-bottom: var(--space-3); color: var(--muted); }
.breadcrumb [aria-current="page"] { color: var(--text); }
.form-page { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
.form-row .inline { font-weight: 400; display: flex; gap: var(--space-2); align-items: center; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* ---- Dialog ---- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: var(--space-4); width: min(420px, 92vw); }
.dialog h2 { margin-top: 0; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }

/* ---- Editor ---- */
.editor-title { width: 100%; font-size: var(--fs-section); font-weight: 600; padding: var(--space-2) var(--space-3); }
.editor-area { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-base); }
.editor-status { font-size: var(--fs-small); color: var(--muted); margin-top: var(--space-1); }
.presence { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0 var(--space-3); }
.presence .pill { background: var(--hover); color: var(--text); border-radius: 999px; padding: 2px var(--space-2); font-size: var(--fs-small); font-weight: 600; }

canvas { display: block; margin: var(--space-2) 0; border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%; height: auto; }

/* ---- Accessibility ---- */
.table-wrap, .tabs, .sidebar, .rte-toolbar { position: relative; }   /* so absolutely positioned .visually-hidden labels inside are clipped with their scroller */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -200px; left: 0;
  background: var(--accent); color: var(--on-accent); padding: var(--space-2) var(--space-3);
  z-index: 200; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }

@media (max-width: 820px) {
  .overview-grid { grid-template-columns: 1fr; }
  .builder-build, .builder-qr { grid-template-columns: 1fr; }
  .builder-top { grid-template-columns: 1fr auto; }
  .builder-title { grid-column: 1 / -1; order: 3; }
  .form-grid { grid-template-columns: 1fr; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .nav-list { flex-direction: row; }
  .nav-list a { white-space: nowrap; }
  .sidebar .nav-group .nav-list { flex-direction: column; }   /* the admin menu is long: stack it instead of one wide row */
  .sidebar .nav-group .nav-list a { white-space: normal; }
  .content { padding: var(--space-3); }
  .topbar .user span { display: none; }
  .topbar .bell { order: 2; }

  /* Phone top bar: brand and Log out on one row, the tabs scroll sideways on their own full-width row, search below. */
  .topbar { height: auto; flex-wrap: wrap; align-items: center; padding: var(--space-2) var(--space-3) 0; gap: var(--space-3); position: static; }
  .topbar .brand { order: 1; min-height: 40px; }
  .topbar .spacer { display: none; }
  .topbar .user { order: 3; }
  .topbar nav { order: 4; flex: 1 0 100%; min-width: 0; margin: 0 calc(var(--space-3) * -1); border-top: 1px solid var(--border); }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 0 var(--space-4); min-height: 44px; }
  /* The client menu becomes one row you can swipe, instead of a tall block above every page. */
  .sidebar[aria-label="Client"] { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-3); white-space: nowrap; }
  .sidebar[aria-label="Client"] > * { flex-shrink: 0; }
  .sidebar[aria-label="Client"] .nav-heading { display: none; }
  .sidebar[aria-label="Client"] .back, .sidebar[aria-label="Client"] .client-name { padding: 0; }
  .sidebar[aria-label="Client"] .hide-empty { padding: 0; }

  /* Touch: 16px text in fields (iOS zooms the page otherwise) and finger-sized targets. */
  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 40px; }
  .icon-btn { min-width: 40px; min-height: 40px; justify-content: center; }
  .az-bar button { min-width: 32px; min-height: 36px; }
  .page-header { gap: var(--space-2); }
  .page-actions { flex-wrap: wrap; }
  .pager { flex-wrap: wrap; justify-content: flex-start; }
}

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

/* ---- Knowledge base (style guide 3h) ---- */
.kb-tree { margin-bottom: var(--space-3); }
.kb-node { background: var(--surface); border: 1px solid var(--border); margin-bottom: 1px; }
.kb-node > summary, .kb-leaf { display: flex; align-items: center; padding: var(--space-2) var(--space-3); cursor: pointer; }
.kb-folder { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); }
.kb-children { padding-left: var(--space-4); }
.center { text-align: center; }

/* ---- Article page (style guide 3i) ---- */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
.article-body { padding: var(--space-4); min-height: 240px; }
.side-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-section { border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: none; }
.panel-section > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); font-weight: 600; cursor: pointer; }
.panel-body { padding: 0 var(--space-3) var(--space-3); font-size: var(--fs-small); }
.link-btn { background: none; border: none; color: var(--link); padding: 0; min-height: 0; cursor: pointer; font: inherit; }
.plain-list, .comments, .photo-grid { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) 0; }
.comment { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.comment p { margin: var(--space-1) 0 0; white-space: pre-wrap; }
.dropzone { display: block; border: 1px dashed var(--border); border-radius: var(--radius); padding: var(--space-3); text-align: center; color: var(--muted); cursor: pointer; margin-bottom: var(--space-2); }
.dropzone:focus-within { outline: 3px solid var(--focus); }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.photo-grid li { position: relative; }
.photo-grid img { width: 100%; height: 90px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.photo-grid .icon-btn { position: absolute; top: var(--space-1); right: var(--space-1); background: var(--surface); }

@media (max-width: 1000px) { .article-layout { grid-template-columns: 1fr; } }

/* ---- Search all (style guide 3j) ---- */
.search-results { list-style: none; margin: 0; padding: 0; }
.search-hit { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.search-title { font-size: var(--fs-section); font-weight: 600; }
.search-snippet { margin: var(--space-1) 0 0; color: var(--text); }

.notes img, .rte-surface img { max-width: 100%; height: auto; border-radius: var(--radius); }
.kb-drop-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--hover); }
.kb-drop-root { padding: var(--space-2) var(--space-3); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-size: var(--fs-small); margin-bottom: var(--space-2); }

/* ---- Bulk actions ---- */
.bulk-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--hover); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-2); font-size: var(--fs-small); }
.rte-field-surface { min-height: 90px; }
.label { display: block; font-weight: 600; margin-bottom: var(--space-1); }

/* ---- Rich-text editor (style guide 3i) ---- */
.article-main { min-width: 0; }
.lock-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); font-size: var(--fs-small); }
.lock-state { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: 600; }
.lock-state.editing { color: var(--accent); }
.lock-bar .editor-title { flex: 1; min-width: 160px; max-width: 420px; }
.lock-bar .presence { margin: 0; }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-2); position: sticky; top: var(--topbar-h); z-index: 5; }
.rte-btn { min-width: 28px; padding: 2px var(--space-2); }
.rte-bold { font-weight: 600; } .rte-italic { font-style: italic; } .rte-underline { text-decoration: underline; } .rte-strike { text-decoration: line-through; }
.rte-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--space-1); }
.rte-surface { outline: none; min-height: 160px; cursor: text; }
.rte-surface:focus-within { box-shadow: 0 0 0 2px var(--focus); }
.rte-surface p, .rte-surface h1, .rte-surface h2, .rte-surface h3, .rte-surface h4, .rte-surface ul, .rte-surface ol, .rte-surface pre, .rte-surface blockquote, .rte-surface table { margin: 0 0 var(--space-2); }
.rte-surface hr { cursor: default; }
.rte-host { position: relative; }
.rte-cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.rte-sel { position: absolute; background: var(--caret, var(--accent)); opacity: 0.22; pointer-events: none; border-radius: 2px; }
.rte-caret { position: absolute; width: 0; border-left: 2px solid var(--caret, var(--accent)); }
.rte-caret span { position: absolute; bottom: 100%; left: -2px; white-space: nowrap; font-size: var(--fs-small); line-height: 1.3; color: var(--on-accent); background: var(--caret, var(--accent)); padding: 0 var(--space-1); border-radius: 3px 3px 3px 0; }
.notes table, .rte-surface table { border-collapse: collapse; width: 100%; }
.notes th, .notes td, .rte-surface th, .rte-surface td { border: 1px solid var(--border); padding: var(--space-1) var(--space-2); min-width: 40px; }
.notes pre, .rte-surface pre { background: var(--surface-alt); border: 1px solid var(--border); padding: var(--space-2); overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.notes blockquote, .rte-surface blockquote { margin: var(--space-2) 0; padding-left: var(--space-3); border-left: 3px solid var(--border); color: var(--muted); }
.notes hr, .rte-surface hr { border: none; border-top: 1px solid var(--border); margin: var(--space-3) 0; }
.notes h1, .rte-surface h1 { font-size: var(--fs-title); } .notes h2, .rte-surface h2 { font-size: var(--fs-section); } .notes h4, .rte-surface h4 { font-size: var(--fs-base); }
.subtabs.small { margin-bottom: var(--space-2); gap: var(--space-3); }
.subtabs.small button[aria-pressed="true"] { border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Client workspace (style guide 3f, 3g) ---- */
.subtabs a { color: var(--text); border-bottom: 2px solid transparent; padding: var(--space-2) var(--space-1); display: inline-block; text-decoration: none; }
.subtabs a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.flag-chip { display: inline-block; padding: 1px var(--space-2); border-radius: 999px; font-size: var(--fs-small); color: var(--on-accent); margin-right: var(--space-1); }
.flag-row { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.nav-list .count { margin-left: auto; color: var(--muted); font-size: var(--fs-small); }
.nav-list a:has(.count) { display: flex; align-items: center; gap: var(--space-2); }
.sidebar .hide-empty { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); font-size: var(--fs-small); color: var(--muted); }
.sidebar .nav-heading { padding: var(--space-3) var(--space-3) var(--space-1); font-size: var(--fs-small); font-weight: 600; color: var(--muted); }
.banner.map-live { height: 280px; }
.map-live .map-canvas { width: 100%; height: 100%; }
.notes { white-space: normal; font-size: var(--fs-base); }
.notes h3 { font-size: var(--fs-base); margin: var(--space-2) 0 var(--space-1); }
.notes ul { margin: var(--space-1) 0; padding-left: var(--space-4); }
.notes p { margin: 0 0 var(--space-2); }
.notes-edit textarea { width: 100%; min-height: 160px; font-family: var(--font); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.panel-head h2 { margin: 0; }
.field-block { margin-bottom: var(--space-3); }
.field-block h3 { margin: var(--space-4) 0 var(--space-1); font-size: var(--fs-section); }
.check-list { display: grid; gap: var(--space-2); margin: var(--space-2) 0; }
.check-list label { display: flex; align-items: center; gap: var(--space-2); }
.color-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); vertical-align: -2px; margin-right: var(--space-1); }
.qr-detail { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.qr-detail svg { width: 160px; height: 160px; }
.link-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

@media (max-width: 820px) { .link-pair { grid-template-columns: 1fr; } }

/* Phone overrides for components defined above this point (kept here so they win over the base rules). */
@media (max-width: 820px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  td.row-actions { white-space: normal; }
  .rte-toolbar { top: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rte-toolbar > * { flex-shrink: 0; }
  .lock-bar .editor-title { flex: 1 1 100%; max-width: none; min-width: 0; }
  .page-header .name-cell { flex-wrap: nowrap; }
}

@media print {
  .topbar, .sidebar, .bulk-bar, .subtabs, .side-panel, .lock-bar button, .rte-toolbar, .page-actions, .skip-link, .toolbar, .pager, button, .menu { display: none !important; }
  .layout { display: block; }
  .content, .content.wide { max-width: none; padding: 0; }
  .card, .panel { border: 1px solid var(--border); break-inside: avoid; }
  body { background: none; color: inherit; }
}

/* Roles: radios with what each is for, and the what-can-each-role-do table (style guide 3k) */
.role-choices { border: 0; padding: 0; margin: var(--space-3) 0; }
.role-choices legend { font-weight: 600; margin-bottom: var(--space-2); }
.role-choice { align-items: flex-start; }
.role-choice .meta { display: block; }
.role-matrix th, .role-matrix td { text-align: center; }
.role-matrix th[scope="row"] { text-align: left; }
.role-matrix .is-selected { background: var(--hover); font-weight: 600; }
.role-matrix .yes { color: var(--ok); }
.role-matrix .no { color: var(--danger); }
.table-wrap + .table-wrap { margin-top: var(--space-4); }   /* two tables in one section (the role list and the role matrix) */

/* Settings forms: help under a field, a row of status badges, space before the buttons (style guide 5) */
.form-help { color: var(--muted); font-size: var(--fs-small); line-height: 1.5; margin-top: var(--space-1); }
.status-line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-3) 0 var(--space-2); }
.form-actions { margin-top: var(--space-4); }
.section > form { margin-top: var(--space-4); }
/* Every settings form: help text under a field reads as help, loose checkboxes and radios line up, buttons sit clear of the last field */
.form-row > .notice { line-height: 1.5; margin: var(--space-1) 0 0; }
form > label.inline, fieldset > label.inline { display: flex; gap: var(--space-2); align-items: center; font-weight: 400; margin: 0 0 var(--space-2); }
form > .page-actions { margin-top: var(--space-4); }
form > [role="status"] { margin-top: var(--space-2); }

/* Network: nested networks, utilisation, the address map and the rack drawing (style guide 3n) */
.data-table td.depth-1 { padding-left: calc(var(--space-3) + var(--space-4)); }
.data-table td.depth-2 { padding-left: calc(var(--space-3) + 2 * var(--space-4)); }
.data-table td.depth-3 { padding-left: calc(var(--space-3) + 3 * var(--space-4)); }
meter { width: 96px; height: 10px; vertical-align: middle; }
.ip-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); font-size: var(--fs-small); color: var(--muted); }
.ip-legend i { display: inline-block; width: 12px; height: 12px; vertical-align: middle; }
.ip-grid { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 2px; max-width: 640px; }
.ip-cell { display: flex; align-items: center; justify-content: center; min-height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 2px; background: var(--surface); color: var(--muted); font-size: 10px; }
button.ip-cell { cursor: pointer; }
.ip-cell.is-assigned { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ip-cell.is-reserved { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.ip-cell.is-gateway { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.ip-cell.is-dhcp { background: var(--hover); color: var(--muted); }
.rack-wrap { margin: var(--space-3) 0; overflow-x: auto; }
.rack-svg { display: block; max-width: 100%; height: auto; font-family: var(--font); font-size: 12px; }
.rk-slot { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.rk-slot.is-clickable { cursor: copy; }
.rk-slot.is-clickable:hover { fill: var(--hover); }
.rk-num { fill: var(--muted); font-size: 10px; }
.rk-item { cursor: pointer; }
.rk-item rect { fill: var(--surface-alt); stroke: var(--text); stroke-width: 1; }
.rk-item text { fill: var(--text); pointer-events: none; }
.rk-item.rk-asset rect { fill: var(--accent); stroke: var(--accent-hover); }
.rk-item.rk-asset text { fill: var(--on-accent); }
.rk-item.rk-patch_panel rect { fill: var(--ok-bg); stroke: var(--ok); }
.rk-item.rk-pdu rect { fill: var(--warn-bg); stroke: var(--warn); }
.rk-item.rk-shelf rect, .rk-item.rk-cable_management rect { fill: var(--hover); }
.rk-item.is-both rect { stroke-width: 2; }
.rk-item.is-proposed rect { stroke-dasharray: 5 3; opacity: 0.75; }
.rk-item:focus { outline: none; }
.rk-item:focus rect { stroke: var(--focus); stroke-width: 3; }

/* An action with its explanation on one row (HaloPSA deletion options, style guide 3o) */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.setting-row > button { flex: 0 0 11rem; justify-content: center; white-space: nowrap; }   /* one width for every action, so none wraps or sits wider than the rest */
.setting-row .notice { margin: var(--space-1) 0 0; }
.subtabs button .count { margin-left: var(--space-1); color: var(--muted); }

/* ---- Jarvis (docs/ui-style-guide.md 3q) ---- */
#jarvis-root { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 60; font-family: var(--font); }
#jarvis-orb { width: 56px; height: 56px; border: none; cursor: pointer; background: none; position: relative; padding: 0; }
#jarvis-orb:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 50%; }
/* Halo sits OUTSIDE the sphere (inset: -9px, unclipped) so it can extend past the edge. */
.jarvis-halo { position: absolute; inset: -9px; border-radius: 50%;
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--jarvis-accent) 60%, transparent), color-mix(in srgb, var(--jarvis-gold) 55%, transparent), rgba(255,255,255,0.4), color-mix(in srgb, var(--jarvis-accent-dark) 55%, transparent), color-mix(in srgb, var(--jarvis-accent) 60%, transparent));
  filter: blur(8px); opacity: 0.85; animation: jarvis-halo-spin 9s linear infinite; }
/* Core clips its own blobs so the moving light stays inside the circle. */
.jarvis-core { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 32% 28%, var(--jarvis-sphere-1) 0%, var(--jarvis-sphere-2) 72%); box-shadow: inset 0 0 12px rgba(0,0,0,0.65), 0 6px 20px rgba(0,0,0,0.45); }
/* Three blobs, each a different duration and path so the motion does not visibly loop; screen blending brightens overlaps like light. */
.jarvis-blob { position: absolute; width: 60%; height: 60%; border-radius: 50%; filter: blur(5px); mix-blend-mode: screen; }
.jarvis-blob-1 { background: radial-gradient(circle, var(--jarvis-blob-1) 0%, transparent 70%); animation: jarvis-blob-1 6.4s ease-in-out infinite; }
.jarvis-blob-2 { background: radial-gradient(circle, var(--jarvis-blob-2) 0%, transparent 70%); animation: jarvis-blob-2 5.1s ease-in-out infinite; }
.jarvis-blob-3 { background: radial-gradient(circle, var(--jarvis-blob-3) 0%, transparent 70%); animation: jarvis-blob-3 7.7s ease-in-out infinite; }
#jarvis-orb.jarvis-thinking .jarvis-halo { animation-duration: 2.2s; }
#jarvis-orb.jarvis-thinking .jarvis-blob-1 { animation-duration: 2.6s; }
#jarvis-orb.jarvis-thinking .jarvis-blob-2 { animation-duration: 2.1s; }
#jarvis-orb.jarvis-thinking .jarvis-blob-3 { animation-duration: 3s; }
@keyframes jarvis-halo-spin { to { transform: rotate(360deg); } }
@keyframes jarvis-blob-1 { 0% { top: 2%; left: 12%; } 28% { top: 38%; left: 46%; } 52% { top: 8%; left: 58%; } 79% { top: 34%; left: 6%; } 100% { top: 2%; left: 12%; } }
@keyframes jarvis-blob-2 { 0% { top: 46%; left: 4%; } 26% { top: 12%; left: 38%; } 61% { top: 50%; left: 50%; } 86% { top: 28%; left: 18%; } 100% { top: 46%; left: 4%; } }
@keyframes jarvis-blob-3 { 0% { top: 18%; left: 40%; } 37% { top: 52%; left: 14%; } 66% { top: 14%; left: 8%; } 91% { top: 40%; left: 44%; } 100% { top: 18%; left: 40%; } }
@media (prefers-reduced-motion: reduce) { .jarvis-halo, .jarvis-blob { animation: none; } }
#jarvis-panel { position: absolute; bottom: 72px; right: 0; width: 380px; max-width: calc(100vw - 24px); height: 520px; max-height: calc(100vh - 140px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.28); display: none; flex-direction: column; overflow: hidden; }
#jarvis-panel.jarvis-open { display: flex; }
#jarvis-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.jarvis-title { font-size: var(--fs-section); font-weight: 700; }
.jarvis-sub { font-size: var(--fs-small); color: var(--muted); }
.jarvis-header-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.jarvis-link { background: none; border: 0; color: var(--link); font-size: var(--fs-small); cursor: pointer; padding: var(--space-1); min-height: 32px; }
.jarvis-link:hover { text-decoration: underline; }
#jarvis-messages { flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); background: var(--bg); }
.jarvis-msg { font-size: var(--fs-base); line-height: 1.5; max-width: 88%; padding: var(--space-2) var(--space-3); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.jarvis-msg-user { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.jarvis-msg-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.jarvis-msg-user a { color: inherit; }
.jarvis-draft { align-self: flex-start; max-width: 88%; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: var(--space-2) var(--space-3); }
.jarvis-draft p { margin: var(--space-1) 0; overflow-wrap: anywhere; }
.jarvis-draft-note { color: var(--muted); font-size: var(--fs-small); }
.jarvis-draft-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.jarvis-msg-pending { align-self: flex-start; color: var(--muted); font-size: var(--fs-small); font-style: italic; }
#jarvis-empty { color: var(--muted); font-size: var(--fs-small); padding: var(--space-2) 2px; }
#jarvis-input-row { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--border); background: var(--surface); }
#jarvis-input { flex: 1; resize: none; height: 40px; padding: var(--space-2) var(--space-3); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
#jarvis-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
#jarvis-input-row button { min-height: 40px; min-width: 44px; }
#jarvis-mic-btn.jarvis-recording { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
#jarvis-unreachable-banner { display: none; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--danger-bg); color: var(--danger); font-size: var(--fs-small); border-top: 1px solid var(--border); }
#jarvis-unreachable-banner.jarvis-visible { display: flex; }
@media (max-width: 480px) { #jarvis-root { right: var(--space-3); bottom: var(--space-3); } #jarvis-panel { width: calc(100vw - 24px); right: -4px; height: calc(100vh - 120px); } }

/* ---- Customer groups (docs/ui-style-guide.md 3r) ---- */
#groupPanels { display: contents; }   /* the group panels are cells of the overview grid */
.check-inline { display: inline-flex; align-items: center; gap: var(--space-2); }
.check-inline[hidden] { display: none; }

/* ---- Search all modal (docs/ui-style-guide.md 3j) ---- */
button.bell { background: none; border: 0; cursor: pointer; font: inherit; }
.dialog.search-dialog { width: min(640px, calc(100vw - 24px)); padding: 0; margin: 12vh auto 0; overflow: hidden; }
.sm-box { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.sm-icon { color: var(--muted); display: inline-flex; }
.sm-input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; min-height: 36px; padding: 0; }
.sm-input:focus { outline: none; }
.sm-box:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.sm-close { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--fs-small); padding: 2px var(--space-2); cursor: pointer; }
.sm-list { list-style: none; margin: 0; padding: var(--space-1); max-height: 55vh; overflow-y: auto; }
.sm-item a { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.sm-item[aria-selected="true"] a { background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
.sm-text { min-width: 0; overflow-wrap: anywhere; }
.sm-note { padding: var(--space-4); color: var(--muted); font-size: var(--fs-small); }
.sm-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-alt); color: var(--muted); font-size: var(--fs-small); }
.sm-foot kbd { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 var(--space-1); font: inherit; }
@media (max-width: 600px) { .dialog.search-dialog { margin-top: 4vh; } .sm-foot span { display: none; } }

/* ---- Network diagram (docs/ui-style-guide.md 3s) ---- */
.dg-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--space-3); }
.dg-wrap svg { display: block; max-width: none; }
.dg-edge { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.dg-edge.dg-hand, .dg-edge.dg-away, .dg-edge.dg-guess { stroke-dasharray: 6 4; }
.dg-edge.dg-away { opacity: 0.55; }
.dg-label { font-size: 11px; fill: var(--muted); stroke: var(--surface); stroke-width: 3px; paint-order: stroke; }
.dg-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.4; }
.dg-node { color: var(--text); cursor: pointer; }
.dg-node:hover .dg-box, .dg-node:focus .dg-box { stroke: var(--accent); stroke-width: 2.2; }
.dg-node:focus { outline: none; }
.dg-name { font-size: 13px; font-weight: 600; fill: var(--text); }
.dg-kind { font-size: 11px; fill: var(--muted); }
.dg-root .dg-box { fill: var(--accent); stroke: var(--accent); }
.dg-root { color: var(--on-accent); }
.dg-root .dg-name, .dg-root .dg-kind { fill: var(--on-accent); }
.dg-outside { opacity: 0.6; }
.dg-outside .dg-box { stroke-dasharray: 5 3; }
.dg-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; color: var(--muted); font-size: var(--fs-small); margin: var(--space-3) 0; }
.dg-legend svg { vertical-align: middle; }
.dg-legend line { stroke: var(--muted); stroke-width: 1.6; }
.dg-attention { margin: var(--space-3) 0; }
.dg-attention li { margin-bottom: var(--space-1); }

.dg-ghost { cursor: pointer; color: var(--muted); }
.dg-ghost .dg-box { fill: var(--surface-alt); stroke: var(--muted); stroke-dasharray: 5 3; }
.dg-ghost:hover .dg-box, .dg-ghost:focus .dg-box { stroke: var(--accent); stroke-width: 2.2; }
.dg-ghost:focus { outline: none; }
.dg-ghost .dg-kind { font-style: italic; }
.dg-hidden summary { cursor: pointer; color: var(--muted); }
.dg-hidden li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; }
.dg-evidence { margin: var(--space-2) 0 var(--space-3) var(--space-4); padding: 0; }

/* ---- MAC vendors set-up steps (docs/ui-style-guide.md 3t) ---- */
.steps { list-style: none; margin: var(--space-4) 0; padding: 0; }
.steps > li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.steps > li:last-child { border-bottom: 0; }
.steps h2 { margin: 0 0 var(--space-2); font-size: var(--fs-section); }
.step-num { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-alt); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.steps meter { width: 100%; max-width: 420px; }
