/* MunimG staff console — charcoal frame, saffron accent, warm neutral canvas.
   Tokens mirror the approved Windows companion (munimg_desktop_theme.dart). */
:root {
  color-scheme: light;
  --frame: #202226;
  --frame-2: #2b2d31;
  --frame-line: rgba(255, 255, 255, .09);
  --frame-text: #f4f1ea;
  --frame-muted: #b8b3ab;
  --brand: #c2410c;
  --brand-strong: #a3360a;
  --brand-soft: #ffeadb;
  --brand-glow: #f8b28d;
  --gold: #d6b477;
  --canvas: #f7f4ef;
  --surface: #ffffff;
  --surface-muted: #f3efe9;
  --row-alt: #fbf9f6;
  --row-hover: #fff5ec;
  --ink: #202226;
  --ink-2: #3d3a35;
  --muted: #68655f;
  --line: #e8e2d9;
  --line-strong: #d9d1c5;
  --success: #067647;
  --success-bg: #e8f5ee;
  --warning: #b54708;
  --warning-bg: #fff3e3;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info: #1f5f99;
  --info-bg: #eaf2fa;
  --focus: #f59e0b;
  --radius-panel: 18px;
  --radius-control: 10px;
  --shadow: 0 1px 2px rgba(42, 33, 24, .05), 0 8px 24px rgba(42, 33, 24, .06);
  --shadow-lift: 0 2px 4px rgba(42, 33, 24, .06), 0 14px 32px rgba(42, 33, 24, .10);
  --topbar: 3.5rem;
  --sidebar: 15rem;
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--ink); letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
code { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: .85em; }
.sr-only {
  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: absolute; left: .75rem; top: -3rem; z-index: 50; padding: .5rem .8rem;
  background: var(--surface); border-radius: var(--radius-control); box-shadow: var(--shadow);
}
.skip-link:focus { top: .6rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon { flex: none; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  min-height: var(--topbar); padding: .5rem 1.25rem; background: var(--frame); color: var(--frame-text);
  border-bottom: 1px solid var(--frame-line);
}
.brand { display: flex; align-items: center; gap: .65rem; min-width: calc(var(--sidebar) - 1.25rem); }
.brand-mark {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem;
  background: linear-gradient(145deg, #d9531a, var(--brand)); color: #fff; font-weight: 800;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1rem; letter-spacing: .01em; }
.brand-text span { font-size: .72rem; color: var(--frame-muted); text-transform: uppercase; letter-spacing: .12em; }
.global-search { flex: 1; max-width: 34rem; }
.global-search input {
  width: 100%; height: 2.25rem; padding: 0 .9rem 0 2.2rem; border-radius: 999px;
  border: 1px solid #434447; background: var(--frame-2) no-repeat .8rem 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16' fill='none' stroke='%23b8b3ab' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4'/%3E%3C/svg%3E");
  color: var(--frame-text); font: inherit; font-size: .9rem;
}
.global-search input::placeholder { color: var(--frame-muted); }
.global-search input:focus { border-color: var(--brand-glow); outline: none; box-shadow: 0 0 0 3px rgba(248, 178, 141, .25); }
.session-actions { display: flex; align-items: center; gap: .6rem; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.session-status {
  font-size: .75rem; padding: .2rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .08);
  color: var(--frame-muted); white-space: nowrap;
}
.operator-context { font-size: .85rem; color: var(--frame-text); overflow-wrap: anywhere; }
.operator-context:empty { display: none; }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.25rem; padding: .4rem .9rem; border-radius: var(--radius-control);
  border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: #bfb5a6; background: var(--row-alt); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #efc2bc; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #8f1b12; }
.btn-ghost-light { background: transparent; color: var(--frame-text); border-color: #4a4b4f; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .08); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-muted); }
.btn-icon {
  min-height: 2rem; width: 2rem; padding: 0; background: var(--surface); color: var(--ink-2);
  border-color: var(--line); border-radius: .6rem;
}
.btn-icon:hover { border-color: var(--line-strong); background: var(--row-alt); }
.btn-small { min-height: 1.6rem; width: 1.6rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.copied { color: var(--success); border-color: #a9dcc3; }
.input {
  width: 100%; min-width: 0; min-height: 2.35rem; padding: .45rem .7rem; border-radius: var(--radius-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: .92rem;
}
.input:hover { border-color: #bfb5a6; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(194, 65, 12, .15); }
select.input { padding-right: 2rem; }
textarea.input { min-height: 4.6rem; resize: vertical; line-height: 1.4; }
.input-code { letter-spacing: .4em; font-size: 1.2rem; text-align: center; }
.field { display: grid; gap: .35rem; min-width: 0; align-content: start; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: .8rem; color: var(--muted); }
.field-error { font-size: .8rem; color: var(--danger); }
.field-inline { display: block; }
.check {
  display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border-radius: var(--radius-control);
  background: var(--row-alt); border: 1px solid var(--line); font-size: .88rem; color: var(--ink-2);
}
.check input { width: 1.05rem; height: 1.05rem; margin: .15rem 0 0; accent-color: var(--brand); flex: none; }

/* Sign-in */
.auth-panel { display: grid; place-items: start center; padding: clamp(1.5rem, 6vh, 4.5rem) 1rem 5rem; }
.auth-card {
  width: min(28rem, 100%); padding: 2rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lift); display: grid; gap: 1rem;
}
.auth-card h1 { font-size: 1.45rem; }
.auth-eyebrow {
  justify-self: start; font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft); padding: .25rem .6rem; border-radius: 999px;
}
.auth-lead, .auth-foot { color: var(--muted); font-size: .9rem; margin-top: .4rem; }
.auth-message { color: var(--ink-2); font-size: .9rem; }
.auth-message:empty { display: none; }
.auth-form { display: grid; gap: .9rem; margin-top: 1.2rem; }
.password-help { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.password-help summary { cursor: pointer; font-weight: 600; color: var(--brand); font-size: .9rem; }
.password-help > p { color: var(--muted); font-size: .85rem; margin-top: .6rem; }
#mfa-qr { display: block; max-width: 100%; height: auto; margin: .8rem 0; border: 1px solid var(--line); border-radius: 12px; }
#mfa-secret { display: block; overflow-wrap: anywhere; padding: .8rem; background: var(--surface-muted); border-radius: 8px; margin-top: .5rem; }

/* App shell */
.shell {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar));
  background: linear-gradient(90deg, var(--frame) 0 var(--sidebar), var(--canvas) var(--sidebar));
}
.sidebar {
  position: sticky; top: var(--topbar); align-self: start; height: calc(100vh - var(--topbar));
  overflow-y: auto; background: var(--frame); color: var(--frame-text); padding: 1rem .75rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.nav-group { display: grid; gap: .15rem; }
.nav-heading {
  font-size: .68rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--frame-muted); padding: 0 .75rem .35rem;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .7rem;
  color: #e7e2d9; text-decoration: none; font-size: .9rem; font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link[aria-current="page"] { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(194, 65, 12, .35); }
.nav-link [data-icon] { display: inline-flex; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: .75rem; border-top: 1px solid var(--frame-line); }
.session-strength { font-size: .78rem; color: var(--frame-muted); }
.view { padding: 1.5rem clamp(1rem, 2.4vw, 2rem) 5rem; min-width: 0; outline: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-content: start; }
.view > *, .grid > *, .tab-panel > * { min-width: 0; }

/* Page header */
.page-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .8rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumb-sep { color: var(--line-strong); }
.page-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-title-main { display: flex; align-items: center; gap: 1rem; min-width: 0; flex: 1 1 18rem; }
.page-title-block { display: grid; gap: .3rem; min-width: 0; }
.page-subtitle .chips { display: inline-flex; gap: .35rem; flex-wrap: wrap; vertical-align: middle; margin-left: .5rem; }
.page-title-block h1 { font-size: 1.55rem; font-weight: 700; overflow-wrap: anywhere; outline: none; }
.page-subtitle { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.page-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.refresh-meta { display: flex; align-items: center; gap: .5rem; }
.refreshed-at { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* Identity header for detail pages */
.identity { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.avatar {
  display: grid; place-items: center; flex: none; width: 3.1rem; height: 3.1rem; border-radius: 1rem;
  background: linear-gradient(145deg, #2e3035, var(--frame)); color: var(--gold); font-weight: 700; font-size: 1.05rem;
  box-shadow: inset 0 0 0 1px rgba(214, 180, 119, .35);
}
.avatar-company { border-radius: .8rem; background: linear-gradient(145deg, #fff1e6, var(--brand-soft)); color: var(--brand); box-shadow: inset 0 0 0 1px #f5cfb6; }
.identity-lines { display: grid; gap: .35rem; min-width: 0; }
.identity-lines .chips { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Cards and stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1rem 1.2rem .2rem; flex-wrap: wrap; }
.card-title { font-size: 1rem; font-weight: 650; }
.card-subtitle { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card-body { padding: .9rem 1.2rem 1.1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: .9rem; min-width: 0; }
.card-flush .card-body { padding: .5rem 0 .2rem; }
.card-danger { border-color: #f2cbc6; }
.card-danger .card-title { color: var(--danger); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat {
  display: grid; gap: .45rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-panel); box-shadow: var(--shadow); text-decoration: none; color: inherit; min-width: 0;
}
.stat-link { transition: transform .15s, box-shadow .15s, border-color .15s; }
.stat-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); border-color: #f0c7ad; }
.stat-top { display: flex; align-items: center; gap: .55rem; }
.stat-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; }
.tone-neutral { background: var(--surface-muted); color: var(--ink-2); }
.tone-brand { background: var(--brand-soft); color: var(--brand); }
.tone-success { background: var(--success-bg); color: var(--success); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.tone-info { background: var(--info-bg); color: var(--info); }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-detail { font-size: .82rem; color: var(--muted); }
.quick-search { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.quick-search .search-box { max-width: none; }
.picker-results { display: grid; gap: .25rem; }
.picker-option {
  display: flex; gap: .4rem; align-items: baseline; text-align: left; padding: .5rem .7rem; border-radius: var(--radius-control);
  border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: .88rem; cursor: pointer;
}
.picker-option:hover { border-color: var(--brand); background: var(--row-hover); }
.validity { border: 0; padding: 0; margin: 0; display: grid; gap: .4rem; }
.date-input { width: 10.5rem; }
.attention-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.attention-row {
  display: flex; align-items: center; gap: .8rem; padding: .7rem 1.2rem; text-decoration: none; color: inherit;
  border-top: 1px solid var(--line);
}
.attention-row:first-child { border-top: 0; }
a.attention-row:hover { background: var(--row-hover); }
.attention-text { flex: 1; min-width: 0; display: grid; }
.attention-text strong { font-size: .9rem; font-weight: 600; }
.attention-text span { font-size: .8rem; color: var(--muted); }
.attention-count { font-weight: 700; font-size: 1.05rem; min-width: 2ch; text-align: right; }
.attention-count.zero { color: var(--muted); font-weight: 500; font-size: .85rem; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; line-height: 1.5; border: 1px solid transparent;
}
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-warning { background: var(--warning-bg); color: var(--warning); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-neutral { background: var(--surface-muted); color: var(--ink-2); }
.chip-muted { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.chip-brand { background: var(--brand-soft); color: var(--brand-strong); }

/* Toolbars and filters */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; flex: 1 1 16rem; max-width: 26rem; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: .7rem; color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 2.1rem; }
.segmented { display: inline-flex; flex-wrap: wrap; padding: .2rem; gap: .15rem; background: var(--surface-muted); border-radius: .75rem; }
.segment {
  border: 0; background: transparent; padding: .38rem .75rem; border-radius: .6rem; font: inherit; font-size: .84rem;
  font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.segment:hover { color: var(--ink); }
.segment[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(42, 33, 24, .14); }
.toolbar select.input { width: auto; min-width: 9rem; }

/* Tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.data-table th {
  text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: .65rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface);
  white-space: nowrap; position: sticky; top: 0;
}
.data-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; min-width: 0; }
.data-table tbody tr:nth-child(even) td { background: var(--row-alt); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tr.row-link { cursor: pointer; }
.data-table tr.row-link:hover td { background: var(--row-hover); }
.align-right { text-align: right; }
.cell-main { display: grid; gap: .1rem; min-width: 0; }
.cell-main strong, .cell-main a { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.cell-main a:hover { color: var(--brand); text-decoration: underline; }
.cell-sub { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.cell-main > .chip, .kv dd > .chip, .identity-lines .chip { justify-self: start; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.link { color: var(--brand); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1.2rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager-status, .pager-page { font-size: .82rem; color: var(--muted); }
.pager-buttons { display: flex; align-items: center; gap: .5rem; }

/* States */
.state { display: grid; justify-items: center; gap: .5rem; padding: 2.6rem 1.5rem; text-align: center; color: var(--muted); }
.state-icon { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 50%; background: var(--surface-muted); color: var(--muted); }
.state-error .state-icon { background: var(--danger-bg); color: var(--danger); }
.state-title { font-weight: 650; color: var(--ink); }
.state-text { font-size: .88rem; max-width: 32rem; }
.state-loading { grid-auto-flow: column; justify-content: center; align-items: center; }
.spinner {
  width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .stat-link:hover { transform: none; } }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab {
  border: 0; background: transparent; font: inherit; font-size: .9rem; font-weight: 600; color: var(--muted);
  padding: .7rem .95rem; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
  display: inline-flex; gap: .4rem; align-items: center; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { font-size: .72rem; background: var(--surface-muted); color: var(--ink-2); border-radius: 999px; padding: .02rem .45rem; }
.tab-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; min-width: 0; }

/* Key-value lists */
.kv { display: grid; margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr); gap: 1rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.kv-row:first-child { border-top: 0; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.id-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .8rem; }
.id-label { color: var(--muted); min-width: 7rem; }
.id-value { color: var(--ink-2); overflow-wrap: anywhere; }
details.tech { border-top: 1px solid var(--line); padding-top: .6rem; }
details.tech summary { cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 600; }
details.tech[open] summary { margin-bottom: .6rem; }

/* Notices */
.notice { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem .9rem; border-radius: var(--radius-control); font-size: .86rem; }
.notice .icon { margin-top: .1rem; }
.notice-info { background: var(--info-bg); color: #184a78; }
.notice-warning { background: var(--warning-bg); color: #7a3306; }
.notice-danger { background: var(--danger-bg); color: #7a1a12; }
.notice-success { background: var(--success-bg); color: #05573a; }
.notice-neutral { background: var(--surface-muted); color: var(--ink-2); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline-item { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); gap: .8rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.timeline-item:first-child { border-top: 0; }
.timeline-dot { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .7rem; }
.timeline-main { display: grid; gap: .3rem; min-width: 0; }
.timeline-title { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-weight: 600; }
.timeline-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.timeline-reason { font-size: .86rem; color: var(--ink-2); overflow-wrap: anywhere; }

/* Device cards */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }
.device-card { border: 1px solid var(--line); border-radius: 14px; padding: 1rem; display: grid; gap: .7rem; background: var(--surface); min-width: 0; }
.device-card.included { border-color: #f0c7ad; background: linear-gradient(180deg, #fffaf6, var(--surface)); }
.device-head { display: flex; gap: .7rem; align-items: flex-start; }
.device-icon { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: .7rem; background: var(--surface-muted); color: var(--ink-2); flex: none; }
.device-title { display: grid; gap: .15rem; min-width: 0; }
.device-title strong { overflow-wrap: anywhere; }
.device-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .8rem; font-size: .8rem; }
.device-facts span { color: var(--muted); display: block; }
.device-companies { display: flex; flex-wrap: wrap; gap: .35rem; }
.mini-list { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }

/* Capacity meter */
.meter { display: grid; gap: .35rem; }
.meter-track { height: .5rem; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: var(--brand); }
.meter-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

/* Review dialog */
.dialog {
  width: min(46rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0;
  border-radius: 20px; box-shadow: 0 24px 64px rgba(20, 16, 12, .32); color: var(--ink); background: var(--surface);
}
.dialog::backdrop { background: rgba(32, 34, 38, .5); backdrop-filter: blur(2px); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.2rem 1.4rem .8rem; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.2rem; }
.dialog-subtitle { color: var(--muted); font-size: .86rem; margin-top: .3rem; }
.dialog-subtitle:empty { display: none; }
.dialog-body { padding: 1.1rem 1.4rem; overflow-y: auto; display: grid; gap: 1rem; }
.dialog-error { margin: 0 1.4rem; padding: .7rem .9rem; border-radius: var(--radius-control); background: var(--danger-bg); color: #7a1a12; font-size: .86rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.4rem 1.2rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
.review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.review-col { border: 1px solid var(--line); border-radius: 14px; padding: .85rem 1rem; display: grid; gap: .45rem; align-content: start; background: var(--row-alt); }
.review-col.after { background: #fffaf5; border-color: #f0c7ad; }
.review-col h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.review-line { display: flex; justify-content: space-between; gap: .8rem; font-size: .86rem; }
.review-line span:first-child { color: var(--muted); }
.review-line span:last-child { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.affected { display: grid; gap: .4rem; font-size: .86rem; }
.affected ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .2rem; }
.success-panel { display: grid; justify-items: start; gap: .6rem; }
.success-mark { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--success-bg); color: var(--success); }

/* Permission matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .yes { color: var(--success); font-weight: 700; }
.matrix .no { color: var(--line-strong); }

/* Busy + toast */
.busy {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 40; display: flex; gap: .55rem; align-items: center;
  background: var(--frame); color: var(--frame-text); padding: .6rem .9rem; border-radius: 12px; box-shadow: var(--shadow-lift); font-size: .88rem;
}
.busy .spinner { border-color: #55565a; border-top-color: var(--brand-glow); }
.result {
  display: block; position: fixed; left: 50%; bottom: 1.2rem; z-index: 45; transform: translateX(-50%);
  width: min(40rem, calc(100% - 2rem)); max-height: 40vh; overflow: auto; background: var(--frame); color: #fff;
  padding: .8rem 1.1rem; border-radius: 14px; box-shadow: var(--shadow-lift); white-space: pre-wrap; font-size: .9rem;
  border-left: 4px solid var(--success);
}
.result:empty { display: none; }
.result.error { background: #7a1a12; border-left-color: #f9b4ab; }

/* Responsive: tablet */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

/* Responsive: narrow windows — navigation becomes a scrollable strip. */
@media (max-width: 900px) {
  :root { --topbar: auto; }
  .topbar { flex-wrap: wrap; position: static; }
  .brand { min-width: 0; }
  .global-search { order: 3; flex-basis: 100%; max-width: none; }
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--canvas); }
  .sidebar {
    position: sticky; top: 0; z-index: 15; height: auto; flex-direction: row; gap: .25rem; padding: .5rem .6rem;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  }
  .nav-group { display: flex; gap: .25rem; }
  .nav-heading, .sidebar-foot { display: none; }
  .nav-link { white-space: nowrap; padding: .45rem .7rem; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .review, .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Responsive: phone width — tables become labelled cards. */
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 1rem .75rem 5rem; }
  .auth-card { padding: 1.4rem; }
  .kv-row { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .data-table td { border: 0; padding: .3rem 1rem; display: grid; grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr); gap: .6rem; }
  .data-table td::before { content: attr(data-label); font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
  .data-table tbody tr:nth-child(even) td { background: transparent; }
  .align-right { text-align: left; }
  .device-facts { grid-template-columns: minmax(0, 1fr); }
  .session-actions { width: 100%; justify-content: flex-start; }
  .btn { white-space: normal; text-align: center; }
  .page-title-row { flex-direction: column; align-items: stretch; }
  .page-title-main { flex-direction: column; align-items: flex-start; flex-basis: auto; }
  .page-title-block, .page-title-block h1 { max-width: 100%; }
  .toolbar select.input, .date-input { min-width: 0; width: 100%; }
  .toolbar .field-inline { flex: 1 1 100%; }
  .search-box { flex-basis: 100%; max-width: none; }
}
