:root {
  --sand-50: #ece6f4;
  --sand-100: #ddd4ea;
  --sand-200: #cbc0df;
  --sand-300: #b0a3cc;
  --navy-700: #4a3a72;
  --navy-800: #352a58;
  --navy-900: #241c3f;
  --text-dark: #1c1528;
  --panel-bg: #f3eef9;
  --panel-border: #c9bddc;
  --input-bg: #fdfcfe;
  --input-border: #b8a8ce;
  --table-row-bg: #f0eaf8;
  --table-row-border: #d8cee8;
  --ok: #2a8a62;
  --err: #b54848;
  --theme-hover: rgba(238, 225, 255, 0.28);
  --accent-1: #5a3da0;
  --accent-2: #7a54c4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--text-dark);
  /* Sfondo “scudo”: viola più profondo, meno saturo in centro */
  background:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(62, 44, 102, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 100% 0%, rgba(48, 34, 78, 0.28) 0%, transparent 50%),
    linear-gradient(180deg, #e4dcf2 0%, #dcd2ec 42%, #d4c9e4 100%);
}

body.theme-scuro {
  --text-dark: #e8e2f4;
  --panel-bg: #161022;
  --panel-border: #3d3258;
  --input-bg: #100d1a;
  --input-border: #4a3d6a;
  --table-row-bg: #14101f;
  --table-row-border: #322a48;
  --ok: #59c79a;
  --err: #e37474;
  --theme-hover: rgba(140, 111, 212, 0.34);
  background:
    radial-gradient(ellipse 100% 70% at 0% 0%, rgba(72, 52, 118, 0.45) 0%, transparent 52%),
    radial-gradient(ellipse 80% 60% at 100% 10%, rgba(40, 28, 68, 0.5) 0%, transparent 48%),
    linear-gradient(180deg, #08060e 0%, #0c0a14 45%, #100e18 100%);
}

.layout { min-height: 100vh; }
.mobile-menu-btn,
.mobile-sidebar-backdrop { display: none; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 250px;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, #1a0f2e 0%, #251542 38%, #2d1a4e 100%);
  color: #eef3f8;
  overflow-y: auto;
  box-shadow: 10px 0 36px rgba(6, 4, 14, 0.55);
}
.sidebar-admin {
  background: linear-gradient(180deg, #240f32, #1a0b24 55%, #14081c);
}
.sidebar-main { min-height: 0; }
.sidebar-footer { margin-top: auto; padding-top: 14px; }
.brand { margin: 0 0 18px; font-size: 22px; font-weight: 700; }
.subtitle { margin: 0 0 22px; font-size: 13px; color: #b9a8d4; }

.menu { display: flex; flex-direction: column; gap: 10px; }
.menu a {
  text-decoration: none;
  color: #eef3f8;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  display: block;
}
.menu a:hover { background: rgba(255, 255, 255, 0.1); }
.menu a.active {
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.12));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4), 0 4px 12px rgba(0,0,0,.18);
}
.sidebar-return-link,
.sidebar-logout-link {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 10px;
  width: 100%;
}
.sidebar-footer .btn {
  width: 100%;
  justify-content: center;
}
.sidebar-admin .menu a.active {
  background: linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,.12));
}
.sidebar-admin .sidebar-return-link {
  background: linear-gradient(180deg, #4a2a66, #2f1a44);
  border-color: #6b4a8b;
  color: #f4ecff;
}
.sidebar-user-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #d8e1ec;
  line-height: 1.35;
  opacity: 1;
  word-break: break-word;
}
.sidebar-version-label {
  margin-top: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #d8e1ec;
  line-height: 1.35;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 8px;
}
.theme-switcher label,
.sidebar-user-label,
.sidebar-version-label {
  font-size: 12px;
  font-weight: 600;
  color: #d8e1ec;
}

.theme-switcher { border-top: 1px solid rgba(255,255,255,.15); padding-top: 14px; }
.theme-switcher label { font-size: 12px; font-weight: 600; color: #d8e1ec; }
.theme-dropdown { position: relative; margin-top: 6px; }
.theme-trigger {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(235, 222, 255, .14);
  color: #eef3f8;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.theme-trigger:hover { background: var(--theme-hover); }
.theme-menu {
  position: absolute;
  left: 0; right: 0; bottom: calc(100% + 8px);
  background: #2a1e47;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 12px;
  padding: 6px;
  z-index: 20;
}
.theme-option {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #eef3f8;
  text-align: left;
  padding: 9px 10px;
  font-weight: 600;
  cursor: pointer;
}
.theme-option:hover { background: var(--theme-hover); }

.content { margin-left: 250px; min-height: 100vh; padding: 14px 24px 30px 24px; }
.panel {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-bg) 90%, #ffffff 10%), var(--panel-bg));
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 14px 12px 14px;
  margin-bottom: 12px;
  box-shadow:
    0 10px 22px rgba(39, 23, 68, 0.14),
    0 1px 0 rgba(255,255,255,.5) inset;
  max-width: calc(100vw - 300px);
  margin-left: auto;
  margin-right: auto;
}
h2 { margin-top: 0; margin-bottom: 10px; color: var(--navy-800); font-size: 28px; font-weight: 700; letter-spacing: .15px; }
.small-text { font-size: 12px; color: #5a4d6e; }
.content > .panel:nth-of-type(odd) {
  background:
    linear-gradient(180deg, #f0e9f8, #e8e0f2);
}
.content > .panel:nth-of-type(even) {
  background:
    linear-gradient(180deg, #ebe4f4, #e3dbea);
}

form { margin-top: 12px; }
label { display: block; margin-top: 8px; font-weight: 700; color: var(--navy-800); }
.required-star {
  color: #d93a3a;
  margin-left: 3px;
  font-weight: 800;
}
input, textarea, select {
  width: 100%;
  border-radius: 9px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  padding: 8px 10px;
  margin-top: 5px;
  color: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(74, 58, 114, 0.2);
}

.btn {
  border: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, #7451ba, #4e3584 66%, #3b2967);
  color: #f7f1ff;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 32, 52, 0.26);
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-secondary {
  background: linear-gradient(180deg, #efe7ff, #ddcff8);
  color: #2a2044;
  border: 1px solid #b7a2df;
}
.btn-danger {
  background: linear-gradient(180deg, #d85f5f, #b54848);
  border: 1px solid #a64242;
  color: #fff;
}
.btn.hidden { display: none !important; }

.notice-ok, .notice-err { border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 10px; }
.notice-ok { color: var(--ok); background: #e7f5ee; border: 1px solid #b9e4cd; }
.notice-err { color: var(--err); background: #fdeeee; border: 1px solid #f2c2c2; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.table-scroll { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--panel-border); border-radius: 10px; overflow: hidden; }
th, td { padding: 7px 8px; border-top: 1px solid var(--table-row-border); vertical-align: top; }
th { background: linear-gradient(180deg, #4f367f, #3d2a66); color: #f4efff; border-top: 0; text-align: left; white-space: nowrap; }
td { background: var(--table-row-bg); }
tr:first-child th:first-child { border-top-left-radius: 10px; }
tr:first-child th:last-child { border-top-right-radius: 10px; }
tr:hover td { background: color-mix(in srgb, var(--table-row-bg) 92%, #cfe0ff 8%); }

.accounts-table { table-layout: auto; min-width: 1500px; }
.accounts-table .col-id { width: 52px; }
.accounts-table .col-enabled { width: 132px; }
.accounts-table .col-actions { width: 168px; min-width: 168px; }
.accounts-table th:last-child,
.accounts-table td:last-child { text-align: center; }

.view-only-value { display: inline-block; color: inherit; font-weight: 400; font-family: inherit; }
.editable-field:disabled { opacity: .92; cursor: not-allowed; }

.actions-cell {
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.actions-cell form { display: inline-flex; vertical-align: middle; margin: 0; }
.actions-cell > * { margin: 0; }

.icon-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid #aeb9cb;
  background: linear-gradient(180deg, #e4e8ef, #cfd6e2);
  color: #141922;
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.icon-btn-delete { border-color: #a64242; background: linear-gradient(180deg, #d85f5f, #b54848); color: #fff; }
.icon-btn-save { border-color: #2f7d5f; background: linear-gradient(180deg, #3da376, #2a8a62); color: #fff; }
.icon-btn-cancel { border-color: #7d8797; }
.icon-btn-restart { color: #2f5f9d; }

.status-badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-ok, .status-active, .status-online, .status-dispatched, .status-new { background: #e6f5ec; color: #1f6b45; }
.status-error, .status-rejected { background: #fdeeee; color: #9c2f2f; }
.status-queued { background: #f0f4fb; color: #3e5477; }
.status-processed { background: #e8eef9; color: #2d4b7a; }
.status-inactive, .status-offline, .status-pending, .status-unknown { background: #f0f2f4; color: #4f5a66; }

.secret-field { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.secret-masked { min-width: 0; letter-spacing: .5px; }
.secret-revealed { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.secret-toggle-btn {
  border: 1px solid #aeb9cb; border-radius: 7px;
  background: linear-gradient(180deg, #e4e8ef, #cfd6e2);
  color: #141922; width: 28px; height: 24px; padding: 0; cursor: pointer;
}
.eye-icon { display: inline-flex; width: 14px; height: 14px; }
.eye-icon svg { width: 100%; height: 100%; }
.secret-toggle-btn .eye-closed { display: inline-flex; }
.secret-toggle-btn .eye-open { display: none; }
.secret-toggle-btn.is-open .eye-open { display: inline-flex; }
.secret-toggle-btn.is-open .eye-closed { display: none; }

.field-help { display: inline-flex; align-items: center; margin-left: 6px; position: relative; }
.help-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid #c6cedb; background: #e8edf5; color: #49566f;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; cursor: pointer;
}
.help-card {
  position: absolute; z-index: 40; left: 0; top: 24px;
  width: min(520px, 80vw);
  background: #f8fbff; border: 1px solid #cfd8e7; border-radius: 12px;
  box-shadow: 0 8px 18px rgba(15,32,52,.2);
  padding: 12px; line-height: 1.45; color: #313844;
}
.help-card p { margin: 0; font-size: 13px; }
.field-hint {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: #667691;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.inline-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.metrics { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; }
.metrics-6 { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.metric { background: linear-gradient(180deg, #f2ecfa, #e8e0f2); border: 1px solid #c4b4d8; border-radius: 12px; padding: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,.55); }
.metric-title { font-size: 12px; color: #4a3d66; font-weight: 700; }
.metric-mini-panel {
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid #c8b8dc;
  background: linear-gradient(180deg, #ffffff, #f2ebfb);
  padding: 8px 10px;
  min-height: 56px;
  display: flex;
  align-items: center;
}
.metric-value { font-size: 30px; font-weight: 800; color: #2a1f42; letter-spacing: .15px; line-height: 1; }
.metric-health {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}
.metric-health .alert-chip {
  font-size: 11px;
  padding: 3px 9px;
}
.state-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.memory-help {
  margin-top: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--panel-bg) 85%, #edf3ff 15%);
}
.memory-help h3 { margin: 0 0 6px; font-size: 14px; }
.memory-help p { margin: 0; font-size: 13px; color: #44516a; }
.log-area {
  max-height: 60vh;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #0f1724;
  color: #c9d6ea;
  padding: 10px;
}
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.alert-list { margin: 8px 0 0; padding-left: 18px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-actions .btn { text-align: center; text-decoration: none; }
.alert-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(16, 28, 42, 0.12);
}
.alert-ok {
  background: linear-gradient(180deg, #eafaf0, #d2f0df);
  color: #1e6b46;
  border-color: #97d5b3;
}
.alert-warn {
  background: linear-gradient(180deg, #fff7e1, #ffecbe);
  color: #805100;
  border-color: #eecb7a;
}
.alert-crit {
  background: linear-gradient(180deg, #feebef, #fad6de);
  color: #962948;
  border-color: #e59ab0;
}

.multi-select { position: relative; }
.multi-select-trigger {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: inherit;
  padding: 10px 12px;
  margin-top: 6px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.multi-select-trigger:hover {
  border-color: var(--navy-700);
}
.multi-select-trigger:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(29, 54, 87, 0.12);
}
.multi-select-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px;
  box-shadow: 0 8px 18px rgba(15,32,52,.18); padding: 8px;
}
.multi-select-option { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; }
.multi-select-option:hover { background: var(--sand-50); }
.multi-select-option input[type="checkbox"] { width: auto; margin: 0; }

/* Dark mode: pannelli coerenti, KPI = riquadro quasi nero + cifre chiarissime */
body.theme-scuro h2 { color: #f2ecff; }
body.theme-scuro label { color: #d4c8ec; }
body.theme-scuro .small-text { color: #a898c4; }
body.theme-scuro .content > .panel:nth-of-type(odd),
body.theme-scuro .content > .panel:nth-of-type(even) {
  background: linear-gradient(180deg, #181222, #14101c);
  border-color: var(--panel-border);
}
body.theme-scuro .panel {
  background: linear-gradient(180deg, #181222, #14101c);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(120, 96, 168, 0.12);
}
body.theme-scuro th {
  background: linear-gradient(180deg, #2a2240, #1e1830);
  color: #f4efff;
}
body.theme-scuro td { color: #e4dcf4; }
body.theme-scuro tr:hover td {
  background: color-mix(in srgb, var(--table-row-bg) 88%, #5c4a82 12%);
}
body.theme-scuro .metric-title { color: #b8a8d4; }
body.theme-scuro .metric {
  background: linear-gradient(180deg, #1c1628, #15101f);
  border-color: #3d3358;
  box-shadow: inset 0 1px 0 rgba(100, 80, 140, 0.15);
}
body.theme-scuro .metric-mini-panel {
  border: 1px solid #0a0810;
  background: linear-gradient(180deg, #121018, #0c0a12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
body.theme-scuro .metric-value {
  color: #faf8ff;
  text-shadow: none;
}
body.theme-scuro .status-pill.on {
  background: rgba(89, 199, 154, 0.18);
  color: #8eedc4;
}
body.theme-scuro .status-pill.off {
  background: rgba(140, 130, 170, 0.2);
  color: #c4b8de;
}
body.theme-scuro .help-dot {
  border-color: #314760;
  background: #182536;
  color: #9eb2cf;
}
body.theme-scuro .help-card {
  background: #161222;
  border-color: #40355c;
  color: #e8dff8;
}
body.theme-scuro .field-hint { color: #a898c4; }
body.theme-scuro .theme-switcher { border-top-color: #2a3b52; }
body.theme-scuro .theme-switcher label { color: #90a4c2; }
body.theme-scuro .theme-switcher label,
body.theme-scuro .sidebar-user-label,
body.theme-scuro .sidebar-version-label {
  color: #90a4c2;
}
body.theme-scuro .sidebar-version-label {
  border-top-color: rgba(200, 180, 234, 0.22);
}
body.theme-scuro .theme-trigger {
  background: rgba(174, 147, 236, 0.12);
  border-color: #5b4b8f;
  color: #e5d9ff;
}
body.theme-scuro .theme-menu {
  background: #1c1531;
  border-color: #544488;
}
body.theme-scuro .btn-secondary {
  background: linear-gradient(180deg, #2f244f, #251c41);
  border-color: #554787;
  color: #f2eaff;
}
body.theme-scuro .memory-help {
  background: #14101f;
  border-color: #3d3358;
}
body.theme-scuro .memory-help p { color: #c4b8de; }
body.theme-scuro .multi-select-trigger {
  border-color: #4f3f80;
  background: #1b1430;
  color: #e9ddff;
}
body.theme-scuro .multi-select-trigger:hover {
  border-color: #6f5bab;
}
body.theme-scuro .notice-ok {
  background: rgba(71, 185, 135, 0.16);
  border-color: rgba(71, 185, 135, 0.36);
  color: #6ce0aa;
}
body.theme-scuro .notice-err {
  background: rgba(227, 116, 116, 0.16);
  border-color: rgba(227, 116, 116, 0.36);
  color: #f39c9c;
}
body.theme-scuro .alert-chip {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
body.theme-scuro .alert-ok {
  background: linear-gradient(180deg, rgba(71, 185, 135, 0.22), rgba(71, 185, 135, 0.14));
  color: #82e3b5;
  border-color: rgba(71, 185, 135, 0.45);
}
body.theme-scuro .alert-warn {
  background: linear-gradient(180deg, rgba(236, 182, 74, 0.22), rgba(236, 182, 74, 0.13));
  color: #ffd07b;
  border-color: rgba(236, 182, 74, 0.42);
}
body.theme-scuro .alert-crit {
  background: linear-gradient(180deg, rgba(227, 116, 116, 0.22), rgba(227, 116, 116, 0.13));
  color: #ffabab;
  border-color: rgba(227, 116, 116, 0.44);
}

.form-submit-spaced {
  margin-top: 10px;
}

.hidden { display: none !important; }

.mini-action-btn {
  border: 1px solid #aeb9cb;
  background: linear-gradient(180deg, #edf1f7, #d7deea);
  color: #152235;
  min-width: 25px;
  height: 24px;
  border-radius: 7px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mini-action-btn svg {
  width: 12px;
  height: 12px;
}

.mini-action-btn.delete {
  background: linear-gradient(180deg, #d85f5f, #b54848);
  border-color: #a64242;
  color: #fff;
}

.mini-action-btn.save {
  background: linear-gradient(180deg, #3da376, #2a8a62);
  border-color: #2f7d5f;
  color: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.status-pill.on { background: #e6f5ec; color: #1f6b45; }
.status-pill.off { background: #f0f2f4; color: #4f5a66; }

.masked-secret {
  color: #8d97a8;
  letter-spacing: .3px;
}

.path-cell {
  max-width: 220px;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #5e6d83 50%), linear-gradient(135deg, #5e6d83 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 10px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

body.theme-scuro select {
  background-image: linear-gradient(45deg, transparent 50%, #9fb0c8 50%), linear-gradient(135deg, #9fb0c8 50%, transparent 50%);
}

@media (max-width: 1024px) {
  .metrics { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
  .metrics-6 { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-flex;
    position: fixed;
    top: 10px;
    left: 10px;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    border: 1px solid #6b4fa9;
    background: linear-gradient(180deg, #7451ba, #4e3584 66%, #3b2967);
    box-shadow: 0 6px 18px rgba(18, 10, 33, 0.35);
    z-index: 120;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
  }
  .mobile-menu-btn span {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 999px;
    background: #f7f1ff;
  }
  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12, 8, 22, 0.48);
    border: 0;
    z-index: 105;
  }
  body.mobile-nav-open { overflow: hidden; }
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    width: min(82vw, 290px);
    z-index: 110;
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  .content {
    margin-left: 0;
    padding: 62px 12px 18px 12px;
  }
  .panel {
    max-width: 100%;
    padding: 12px;
    border-radius: 10px;
  }
  .sidebar-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  h2 {
    font-size: 22px;
    line-height: 1.2;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  input, textarea, select {
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 8px; }
  .metrics-6 { grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 8px; }
  .metric { padding: 10px; }
  .metric-value { font-size: 24px; }
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .quick-actions { grid-template-columns: 1fr; }
  .panel .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel table tbody {
    display: table;
    width: max-content;
    min-width: 100%;
  }
  .panel table tr {
    white-space: nowrap;
  }
  .panel table td pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 220px;
  }
  th, td {
    padding: 6px 7px;
    font-size: 13px;
  }
}
