/* MPR One Website AI — layout and components follow MPR One Office (sidebar, top bar, panels,
   buttons with Lucide icons); only the brand colours differ. */
:root {
  /* Brand colours sampled from branding/source (logo and icon). */
  --brand-primary: #8a0410;
  --brand-primary-dark: #6a030c;
  --brand-ink: #1b1d22;
  --primary: var(--brand-primary);
  --primary-dark: var(--brand-primary-dark);
  --primary-soft: color-mix(in srgb, var(--brand-primary) 8%, #ffffff);
  --ink: var(--brand-ink);
  --muted: #667085;
  --line: #e5e7eb;
  --surface: #ffffff;
  --panel: rgba(255, 255, 255, 0.94);
  --theme-bg-start: color-mix(in srgb, var(--brand-primary) 2%, #ffffff);
  --theme-bg-mid: color-mix(in srgb, var(--brand-primary) 5%, #f6f6f7);
  --theme-bg-end: color-mix(in srgb, var(--brand-primary) 1%, #ffffff);
  --shadow: 0 18px 50px rgba(24, 16, 18, 0.08);
  --shadow-soft: 0 10px 30px rgba(24, 16, 18, 0.06);
  --shadow-float: 0 28px 90px rgba(16, 12, 14, 0.22);
  --radius: 8px;
  --control-height: 40px;
  --sidebar-width: 280px;
  --ok: #206b30;
  --ok-bg: #edf8ef;
  --ok-border: #bde5c3;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --warn-border: #f3d9a4;
  --info: #1d4f7a;
  --info-bg: #eef5fb;
  --info-border: #cfe2f3;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --danger-border: #f1c0bb;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 110px; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: linear-gradient(135deg, var(--theme-bg-start) 0%, var(--theme-bg-mid) 48%, var(--theme-bg-end) 100%);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  overflow-x: hidden;
}

a { color: var(--primary); }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; font-weight: 850; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 850; }
h3 { font-size: 15px; font-weight: 800; margin: 18px 0 8px; }
p { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); font-weight: 600; }
.error-text { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip-link:focus { left: 8px; }

svg.lucide { width: 16px; height: 16px; flex: 0 0 auto; pointer-events: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 20px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.08);
  border-right: 1px solid rgba(229, 231, 235, 0.86);
  overflow-y: auto;
}
.sidebar-logo img { display: block; width: 220px; max-width: 100%; height: auto; filter: drop-shadow(0 12px 18px rgba(17, 20, 24, 0.08)); }
.environment-switch { display: grid; gap: 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.environment-switch select { font-size: 14px; font-weight: 800; text-transform: none; letter-spacing: 0; color: var(--ink); }
.side-nav { display: grid; gap: 4px; align-content: start; flex: 1; }
.nav-group-label { margin: 10px 0 2px 14px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group-label:first-child { margin-top: 0; }
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px 8px 16px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #354052;
  font: inherit;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.side-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link svg { width: 18px; height: 18px; opacity: 0.84; }
.side-link:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); color: var(--primary-dark); }
.side-link.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 13%, transparent), color-mix(in srgb, var(--primary-dark) 7%, transparent));
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.side-link.active::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 3px; border-radius: 999px; background: var(--primary); }
.sidebar-footer { display: grid; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Main and top bar ---------- */
main { min-width: 0; padding: 0 30px 48px; outline: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 0 -30px 24px;
  padding: 22px 30px 18px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.72);
  background: color-mix(in srgb, var(--primary) 3%, rgba(255, 255, 255, 0.9));
  backdrop-filter: blur(18px) saturate(1.08);
}
.topbar-titles { min-width: 0; }
.topbar-titles h1 { overflow-wrap: anywhere; }
#subtitle { color: var(--muted); margin-top: 2px; }
#subtitle:empty { display: none; }
.topbar-tools { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-environment, .language-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--primary-dark); }
.topbar-environment svg, .language-switch svg { width: 18px; height: 18px; }
.topbar-environment select { min-width: 220px; font-weight: 800; }
.language-switch select { width: auto; min-width: 70px; font-weight: 700; }
.view-host { max-width: 1200px; }
.view { display: grid; gap: 18px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.page-actions:empty { display: none; }
.loading { padding: 20px 0; }

/* ---------- Panels ---------- */
.panel, .card {
  background: var(--panel);
  border: 1px solid rgba(229, 231, 235, 0.86);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  backdrop-filter: blur(8px);
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
}
.panel-heading h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.panel-heading h2 svg { width: 18px; height: 18px; color: var(--primary); }
.panel-heading .muted { max-width: 760px; }
.panel-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.panel > h2 { margin-bottom: 12px; }
.panel-attention { border-color: var(--warn-border); background: color-mix(in srgb, var(--warn-bg) 70%, #ffffff); }
.error-card { border-color: var(--danger-border); }
.empty { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.empty svg { width: 26px; height: 26px; opacity: 0.6; }

/* ---------- Buttons (Office style) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid #d8dee5;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7f8f9);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(17, 20, 24, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}
.btn:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 7px 18px rgba(30, 16, 20, 0.1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: var(--primary); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 25%, transparent); }
.btn-primary:hover { border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); background: linear-gradient(180deg, #ffffff, #fff7f6); }
.btn-danger:hover { border-color: var(--danger); }
.btn-link { min-height: 30px; padding: 5px 9px; border-color: transparent; background: transparent; box-shadow: none; color: var(--primary); font-weight: 650; }
.btn-link:hover { background: var(--primary-soft); border-color: transparent; transform: none; box-shadow: none; }
.btn-icon { width: 38px; padding: 0; }
td .btn { min-height: 30px; padding: 5px 9px; font-size: 12px; }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 8px 10px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; min-height: 96px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, .side-link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
  border-color: var(--primary);
}
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.field { display: grid; gap: 5px; }
.field-label { font-weight: 700; font-size: 13px; }
.field-wide { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; align-items: start; }
.form-actions, .composer-actions, .action-bar, .dialog-actions, .choices { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.action-bar { margin-top: 0; }
.composer-actions { justify-content: space-between; }
.composer-actions:has(> :only-child) { justify-content: flex-end; }
.form-error { color: var(--danger); margin: 0; min-height: 1.2em; }
.check { display: flex; gap: 8px; align-items: center; min-height: var(--control-height); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.inline-form select { width: auto; flex: 1 1 200px; }
.code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
pre.code { background: #f6f7f9; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; }
.secret-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.secret-box code { background: #f6f7f9; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; word-break: break-all; }
.secrets { display: grid; gap: 8px; margin-bottom: 16px; }
.secret-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; flex-wrap: wrap; background: var(--surface); }
.secret-row .hint { margin: 2px 0 0; }
.links { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.qr { width: 220px; height: 220px; display: block; margin: 8px 0; }

/* ---------- Sign-in (Office style card) ---------- */
body.signed-out { display: block; background: linear-gradient(145deg, #f6f5f5 0%, #ebe7e8 58%, #f4f2f2 100%); }
body.signed-out .sidebar, body.signed-out .topbar, body.signed-out .mobile-appbar { display: none; }
body.signed-out main { padding: 24px; min-height: 100vh; display: grid; place-items: center; }
body.signed-out .view-host { width: 100%; max-width: 440px; }
.auth-card { display: grid; gap: 14px; padding: 28px; border: 1px solid rgba(229, 231, 235, 0.86); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-float); }
.product-logo { width: min(320px, 100%); height: auto; justify-self: center; padding: 10px 12px; border: 1px solid rgba(229, 231, 235, 0.86); border-radius: 6px; background: #fff; }
.auth-card h1 { font-size: 24px; }

/* ---------- Notices, toasts ---------- */
.notice { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.notice ul { margin: 6px 0; padding-left: 20px; flex-basis: 100%; }
.notice-warning { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.notice-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); margin: 12px 0 0; }
.notice-progress { align-items: center; background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 300; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-float); }
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .btn:hover { transform: none; } }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; border: 1px solid #dfe3e6; font-size: 12px; font-weight: 700; background: #f7f8f8; color: #475467; white-space: nowrap; }
.status-bezig, .status-wachtrij, .status-publiceren, .status-bezig_publiceren { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.status-verduidelijken, .status-wacht_op_klant, .status-wacht_op_keuze, .status-ter_controle, .status-wacht_op_budget, .status-klaargezet { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.status-live, .status-afgerond { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.status-mislukt, .status-afgewezen { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.badge-internal { background: #f1ecfb; border-color: #ddd0f5; color: #5b3aa0; }
.request-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 82%, transparent); border-radius: var(--radius); }
.panel .table-wrap { margin: 0; }
.panel .table-wrap + .table-wrap, .panel .table-wrap + ul { margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafafa; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: color-mix(in srgb, var(--primary) 3%, #ffffff); }
td select { min-width: 150px; }

/* ---------- Tiles, meter, site cards ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.tile { display: grid; gap: 2px; background: var(--panel); border: 1px solid rgba(229, 231, 235, 0.86); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 18px; text-decoration: none; color: inherit; transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease; }
a.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 24%, transparent); box-shadow: 0 16px 44px rgba(30, 16, 20, 0.1); }
.tile-value { font-size: 28px; font-weight: 850; color: var(--primary); }
.tile-label { color: var(--muted); font-weight: 600; }
.budget-line { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.meter { height: 10px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.meter span.high { background: #d99a00; }
.meter span.full { background: var(--danger); }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.site-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; transition: border-color 0.16s ease, box-shadow 0.16s ease; }
.site-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, transparent); box-shadow: var(--shadow-soft); }
.site-card-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.site-card-icon svg { width: 20px; height: 20px; }
.site-card-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.site-card-body strong { color: var(--primary-dark); }
.site-card > svg { color: var(--muted); }

/* ---------- Request thread ---------- */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.message { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; max-width: 88%; box-shadow: 0 2px 8px rgba(17, 20, 24, 0.03); }
.message-user, .message-admin { justify-self: end; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 16%, #ffffff); }
.message-agent { justify-self: start; }
.message-system { justify-self: stretch; max-width: none; background: #fafafa; font-size: 13px; }
.message-internal { border-style: dashed; border-color: #cbb8ef; background: #faf7ff; }
.message-meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.attachment { display: grid; gap: 4px; text-decoration: none; color: inherit; max-width: 220px; }
.attachment img { width: 200px; height: 150px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f2f3f5; }
.attachment video { width: 320px; max-width: 100%; border-radius: 6px; background: #000; }
.attachment-video { max-width: 340px; }
.attachment-file { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; background: var(--surface); }
.caption { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.file-icon { font-size: 1.4rem; }
.admin-panel { border-style: dashed; }
.plain { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; font-size: 13px; }

/* ---------- Composer, file picker ---------- */
.composer { display: grid; gap: 10px; }
.file-picker { display: grid; gap: 8px; justify-items: start; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; width: 100%; }
.file-list li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; background: var(--surface); }
.file-list img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.file-name { flex: 1; overflow-wrap: anywhere; }
.source-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.source-image { display: grid; gap: 4px; justify-items: center; cursor: pointer; }
.source-image img { width: 90px; height: 70px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
details > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 800; }
details > summary svg { color: var(--primary); }
details[open] > summary { margin-bottom: 10px; }

/* ---------- System checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.check-icon { font-weight: 800; width: 1.2em; }
.check-ok .check-icon { color: var(--ok); }
.check-fail .check-icon { color: var(--danger); }
.test-output { margin-top: 12px; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-float); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(17, 20, 24, 0.45); }
.dialog-form { padding: 22px; display: grid; gap: 12px; max-height: calc(100vh - 64px); overflow: auto; }
.dialog-actions { justify-content: flex-end; }

/* ---------- Mobile (same breakpoint and pattern as MPR One Office) ---------- */
.mobile-appbar, .mobile-nav-close, .mobile-nav-scrim { display: none; }

@media (max-width: 1100px) {
  :root { --mobile-appbar-height: 62px; }
  body { display: block; }
  .mobile-appbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: calc(var(--mobile-appbar-height) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }
  .mobile-nav-toggle { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; }
  .mobile-nav-toggle svg { width: 20px; height: 20px; }
  .mobile-appbar-context { display: grid; min-width: 0; gap: 1px; }
  .mobile-appbar-context strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-appbar-context small { overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(320px, 86vw);
    height: 100dvh;
    padding-top: calc(20px + env(safe-area-inset-top));
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-float);
  }
  body.mobile-nav-open .sidebar { transform: translateX(0); }
  .mobile-nav-close { display: grid; place-items: center; position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
  .mobile-nav-scrim { position: fixed; inset: 0; z-index: 50; border: 0; background: rgba(17, 20, 24, 0.4); }
  body.mobile-nav-open .mobile-nav-scrim { display: block; }
  .sidebar-logo img { width: 180px; }
  main { padding: 0 16px 40px; }
  .topbar { position: static; margin: 0 -16px 18px; padding: 16px; flex-wrap: wrap; background: transparent; backdrop-filter: none; }
  .topbar-titles h1 { font-size: 22px; }
  .topbar-environment { display: none !important; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar-titles { display: none; }
  .topbar { padding-bottom: 4px; border-bottom: 0; }
  .topbar-tools { margin-left: auto; }
  .panel, .card { padding: 16px; }
  .message { max-width: 100%; }
  .attachment img { width: 150px; height: 112px; }
  .page-actions { justify-content: flex-start; }
  /* Tables become stacked cards. */
  .table-wrap { border: 0; background: none; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 6px 0; }
  td { border: 0; padding: 4px 12px; display: flex; gap: 12px; justify-content: space-between; align-items: center; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex-shrink: 0; }
  td[data-label=""]::before { content: none; }
}
