/* ============================================================================
   SEHL Mail — Control Center · UI v0.2.0
   Identidad SEHL: "lujo contenido" — marfil cálido, oro sobrio, navy autoridad.
   Tokens según SEHL_BRAND_IDENTITY (capa identidad + capa semántica).
   ========================================================================== */

:root {
  /* Identidad · núcleo */
  --gold: #b0894f;
  --gold-deep: #97713a;
  --gold-soft: #f3ebdc;
  --gold-ondark: #d8b676;
  --navy: #1f2a3c;
  --navy-2: #18202e;          /* navy más profundo: cards sobre navy */
  --navy-soft: #e7ebf1;
  --ink: #1b1f2a;
  --ivory: #faf8f4;
  /* Neutros */
  --bg: #faf8f4;
  --bg-2: #f3efe8;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --line: #e8e3da;
  --line-soft: #f0ece4;
  --ink-soft: #555c6b;
  --ink-faint: #8a909c;
  /* Semántica */
  --ok: #2f8f5b;      --ok-soft: #e7f3ec;
  --warn: #c98a25;    --warn-soft: #faf0db;
  --danger: #c0492f;  --danger-soft: #f8e8e3;
  --info: #2f6f9f;    --info-soft: #e6eef5;
  /* Sombra / geometría */
  --sh-1: 0 1px 2px rgba(27,31,42,.05);
  --sh-2: 0 10px 30px rgba(27,31,42,.10);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 256px;
  /* Tipografía */
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { transition: .16s ease; }
.hidden { display: none !important; }
code { font-family: var(--mono); font-size: .86em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* Voz editorial: serif en titulares y marca */
.brand-lockup strong, .login-copy h1, .hero-panel h2, .hero-orbit b,
.topbar h1, .panel-heading h3, .secret-dialog h2 { font-family: var(--serif); }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-deep); margin: 0; }

/* ============================================================ LOGIN */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 32px; position: relative; overflow: hidden;
  background: var(--bg); }
.ambient { position: absolute; border-radius: 50%; opacity: .8; pointer-events: none; }
.ambient-a { width: 640px; height: 640px; background: radial-gradient(circle, rgba(176,137,79,.10), transparent 66%); top: -220px; right: -120px; }
.ambient-b { width: 520px; height: 520px; background: radial-gradient(circle, rgba(31,42,60,.06), transparent 66%); bottom: -200px; left: -140px; }
.login-card { position: relative; width: min(440px, 100%); padding: 40px 38px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--sh-2); }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-lockup strong { display: block; font-size: 19px; font-weight: 600; letter-spacing: .01em; }
.brand-lockup small { display: block; color: var(--ink-faint); margin-top: 1px; font-size: 12px; }
.brand-mark { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep)); box-shadow: 0 6px 18px rgba(151,113,58,.35); }
.brand-mark span { font-family: var(--serif); font-weight: 600; font-size: 21px; color: #fff; }
.login-copy { margin: 36px 0 26px; }
.login-copy h1 { font-size: clamp(26px, 4.5vw, 33px); font-weight: 500; line-height: 1.14; margin: 10px 0 12px; letter-spacing: -.01em; }
.login-copy p:last-child { color: var(--ink-soft); line-height: 1.6; margin: 0; }
.login-foot { display: flex; align-items: center; gap: 9px; color: var(--ink-faint); font-size: 12px; margin-top: 26px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }

/* ============================================================ FORMULARIOS */
.stack { display: grid; gap: 15px; }
label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,137,79,.16); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-label { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 500; font-size: 13px; }
.check-label input { width: 16px; height: 16px; accent-color: var(--gold); }
.form-error { min-height: 18px; color: var(--danger); font-size: 13px; margin: 0; }

/* ============================================================ BOTONES */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; }
.button img { width: 17px; height: 17px; }
.button.primary { background: linear-gradient(145deg, var(--gold), var(--gold-deep)); color: #fff;
  box-shadow: 0 6px 16px rgba(151,113,58,.28); }
.button.primary img { filter: brightness(0) invert(1); }
.button.primary:hover { filter: brightness(1.05); }
.button.secondary { background: var(--navy); color: #f4f1ec; border-color: var(--navy); }
.button.secondary img { filter: brightness(0) invert(1); }
.button.secondary:hover { background: #2a3850; border-color: #2a3850; }
.button.ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.button.ghost:hover { color: var(--ink); border-color: var(--ink-faint); }
.button.danger { color: var(--danger); border-color: rgba(192,73,47,.32); background: var(--danger-soft); }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button.full { width: 100%; }
.button.small { min-height: 32px; padding: 5px 11px; font-size: 12px; }

/* ============================================================ SHELL */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }

/* --- Sidebar: navy de autoridad --- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column;
  padding: 22px 16px; background: var(--navy); z-index: 10; }
.sidebar img { filter: brightness(0) invert(1); opacity: .62; }
.brand-lockup.compact { padding: 0 6px 20px; }
.brand-lockup.compact .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.brand-lockup.compact strong { color: #f4f1ec; font-size: 16px; }
.brand-lockup.compact small { color: #8d97a8; font-size: 11px; }
.navigation { display: grid; gap: 3px; margin-top: 6px; }
.nav-item, .launch-link { width: 100%; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 9px;
  padding: 9px 12px; background: transparent; color: #c3c9d4; cursor: pointer; text-decoration: none; text-align: start;
  font-size: 13.5px; font-weight: 500; }
.nav-item img, .launch-link img { width: 18px; height: 18px; }
.nav-item:hover, .launch-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item:hover img, .launch-link:hover img { opacity: .92; }
.nav-item.active { background: rgba(216,182,118,.13); color: #fff; box-shadow: inset 3px 0 var(--gold-ondark); }
.nav-item.active img { opacity: 1; }
.sidebar-links { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.09); }
.operator-card { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 9px; margin-top: 14px;
  padding: 10px 9px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(0,0,0,.18); }
.operator-card strong, .operator-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-card strong { font-size: 12px; color: #f4f1ec; }
.operator-card small { font-size: 10px; color: #8d97a8; margin-top: 2px; }
.avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep)); color: #fff; font-weight: 600; font-family: var(--serif); }
.sidebar .icon-button { border-color: rgba(255,255,255,.14); background: transparent; }
.sidebar .icon-button:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.26); }

.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--surface); cursor: pointer; }
.icon-button img { width: 17px; height: 17px; }
.icon-button:hover { border-color: var(--ink-faint); }

/* --- Workspace --- */
.workspace { grid-column: 2; padding: 0 32px 48px; min-width: 0; }
.workspace img { filter: brightness(0) opacity(.7); }
.topbar { height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  background: rgba(250,248,244,.92); backdrop-filter: blur(14px); }
.topbar h1 { font-size: 23px; font-weight: 600; margin: 3px 0 0; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: end; gap: 10px; }
.compact-select { min-width: 150px; }
.compact-select span { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); }
.compact-select select { padding: 7px 10px; min-height: 34px; background: var(--surface); }
.view { display: none; padding-top: 26px; }
.view.active { display: block; }

/* ============================================================ DASHBOARD */
/* Hero sobre navy: bloque de identidad "ondark" */
.hero-panel { min-height: 240px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(210px, .6fr);
  align-items: center; gap: 30px; padding: 40px 44px; border-radius: 20px; overflow: hidden; position: relative;
  background: linear-gradient(130deg, var(--navy) 0%, var(--navy-2) 100%); color: #f4f1ec; box-shadow: var(--sh-2); }
.hero-panel:before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 86% 18%, rgba(216,182,118,.15), transparent 38%); }
.hero-panel .eyebrow { color: var(--gold-ondark); position: relative; }
.hero-panel h2 { font-size: clamp(27px, 3.6vw, 40px); font-weight: 500; line-height: 1.1; letter-spacing: -.015em;
  margin: 12px 0 14px; max-width: 720px; position: relative; }
.hero-panel p:last-child { max-width: 680px; line-height: 1.65; color: #c3c9d4; margin: 0; position: relative; }
.hero-orbit { width: 190px; height: 190px; position: relative; display: grid; place-items: center; margin: auto;
  border: 1px solid rgba(216,182,118,.32); border-radius: 50%; box-shadow: inset 0 0 46px rgba(216,182,118,.08); }
.hero-orbit:before, .hero-orbit:after { content: ""; position: absolute; border: 1px solid rgba(216,182,118,.2);
  border-radius: 50%; inset: 22px; transform: rotate(60deg); }
.hero-orbit:after { inset: 43px; border-color: rgba(216,182,118,.34); transform: rotate(-30deg); }
.hero-orbit span { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-ondark);
  box-shadow: 0 0 14px var(--gold-ondark); }
.hero-orbit span:nth-child(1) { top: 16px; }
.hero-orbit span:nth-child(2) { bottom: 34px; right: 20px; }
.hero-orbit span:nth-child(3) { left: 14px; bottom: 66px; }
.hero-orbit b { font-family: var(--serif); font-weight: 600; font-size: 25px; letter-spacing: .14em; color: #f4f1ec; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.metric-card { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-1); }
.metric-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--gold-soft); }
.metric-icon img { width: 20px; height: 20px; }
.metric-card span { display: block; color: var(--ink-faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.metric-card strong { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 25px; font-weight: 600; margin-top: 3px; }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--sh-1); padding: 22px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-heading h3 { margin: 5px 0 0; font-size: 17px; font-weight: 600; }

.status-list { display: grid; gap: 9px; }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-soft); }
.status-row div { display: flex; align-items: center; gap: 10px; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.status-row.ok .status-indicator { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.status-row.bad .status-indicator { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.status-row small { color: var(--ink-faint); }
.status-row.ok small { color: var(--ok); font-weight: 600; }
.status-row.bad small { color: var(--danger); font-weight: 600; }

.activation-list { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; counter-reset: activation; }
.activation-list li { display: grid; grid-template-columns: 27px 1fr; align-items: center; gap: 11px; color: var(--ink-soft); }
.activation-list li:before { counter-increment: activation; content: counter(activation); width: 25px; height: 25px;
  border-radius: 8px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-deep);
  font-family: var(--mono); font-size: 11px; font-weight: 600; }

/* ============================================================ SECCIONES CRUD */
.section-grid { display: grid; gap: 16px; }
.form-table-grid { grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); }
.form-panel { align-self: start; position: sticky; top: 112px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 620px; background: var(--surface); }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-faint); font-size: 10.5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .08em; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td small { display: block; color: var(--ink-faint); margin-top: 3px; font-size: 12px; }
td code { color: var(--gold-deep); background: var(--line-soft); padding: 1px 6px; border-radius: 6px; font-size: 11.5px; }

.status-pill, .badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-family: var(--mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface-2); }
.status-pill.active { color: var(--ok); background: var(--ok-soft); border-color: rgba(47,143,91,.28); }
.status-pill.pending, .status-pill.provisioning { color: var(--warn); background: var(--warn-soft); border-color: rgba(201,138,37,.3); }
.status-pill.failed { color: var(--danger); background: var(--danger-soft); border-color: rgba(192,73,47,.3); }
.status-pill.suspended { color: var(--info); background: var(--info-soft); border-color: rgba(47,111,159,.3); }
.status-pill.archived { color: var(--ink-faint); background: var(--bg-2); border-color: var(--line); }
.badge.native { color: var(--gold-deep); background: var(--gold-soft); border-color: rgba(151,113,58,.3); }

.row-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.row-action { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 5px 9px;
  color: var(--ink-soft); cursor: pointer; font-size: 11.5px; font-weight: 600; }
.row-action:hover { color: var(--ink); border-color: var(--ink-faint); background: var(--surface-2); }

.tenant-required { display: none; padding: 16px 20px; margin-bottom: 16px; border: 1px dashed rgba(201,138,37,.45);
  border-radius: var(--radius-sm); color: #8a5f14; background: var(--warn-soft); font-weight: 500; }
.tenant-required.visible { display: block; }
.tenant-required.visible + .tenant-content { display: none; }
.empty-row td { text-align: center; color: var(--ink-faint); padding: 38px; }

/* ============================================================ SEMÁNTICA */
.semantic-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 16px; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.semantic-results { display: grid; gap: 10px; margin-top: 16px; }
.semantic-result { padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.semantic-result header { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.semantic-result h4 { margin: 0; font-size: 14px; font-weight: 600; }
.semantic-result p { color: var(--ink-soft); line-height: 1.55; margin: 9px 0 0; font-size: 13px; }
.semantic-score { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--gold-deep); font-size: 12px; font-weight: 600; }
.empty-state { min-height: 210px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--ink-faint); }
.empty-state img { width: 42px; height: 42px; opacity: .35; margin-bottom: 12px; }

/* ============================================================ ANALÍTICA */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.bar-col .bar { width: 100%; min-height: 3px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); opacity: .85; transition: .2s; }
.bar-col:hover .bar { opacity: 1; }
.bar-col span { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); }
.hbar-list { display: grid; gap: 13px; }
.hbar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.hbar-head strong { font-size: 13px; }
.hbar-head small { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; }
.hbar-track { height: 9px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--gold-deep)); }
.hbar-fill.hot { background: linear-gradient(90deg, var(--warn), var(--danger)); }

/* ============================================================ FILTROS / TAGS */
.heading-tools { display: flex; align-items: center; gap: 8px; }
.table-filter { width: 170px; min-height: 34px; padding: 6px 11px; font-size: 12.5px; }
.tag-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--navy-soft);
  color: var(--navy); font-size: 10px; font-weight: 600; margin-top: 3px; }

/* ============================================================ ENTREGA / CUARENTENA */
.delivery-grid { grid-template-columns: 1.15fr .85fr; }
#view-delivery table, #view-quarantine table { min-width: 680px; }
#view-delivery td:nth-child(2), #view-quarantine td:nth-child(2) { white-space: nowrap; }
@media (max-width: 1100px) { .delivery-grid { grid-template-columns: 1fr; } }

/* ============================================================ SISTEMA */
.code-panel { min-height: 330px; max-height: 540px; overflow: auto; margin: 0; padding: 16px;
  border-radius: var(--radius-sm); background: var(--navy-2); border: 1px solid var(--navy);
  color: #cdd6e4; font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; }

/* ============================================================ TOASTS / DIALOG */
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: grid; gap: 10px; width: min(380px, calc(100vw - 44px)); }
.toast { padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); border-inline-start: 3px solid var(--ink-faint);
  background: var(--surface); box-shadow: var(--sh-2); animation: toast-in .18s ease; }
.toast.success { border-inline-start-color: var(--ok); }
.toast.error { border-inline-start-color: var(--danger); }
.toast strong { display: block; font-size: 13px; }
.toast p { margin: 4px 0 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.45; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.secret-dialog { width: min(500px, calc(100vw - 36px)); border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-2); padding: 0; }
.secret-dialog::backdrop { background: rgba(27,31,42,.5); backdrop-filter: blur(5px); }
.secret-dialog form { padding: 30px; text-align: center; }
.dialog-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin: auto; background: var(--gold-soft); }
.dialog-icon img { width: 25px; height: 25px; filter: brightness(0) opacity(.7); }
.secret-dialog h2 { margin: 18px 0 8px; font-weight: 600; }
.secret-dialog p { color: var(--ink-soft); line-height: 1.55; }
.secret-value { display: grid; grid-template-columns: 1fr 38px; gap: 9px; align-items: center; text-align: start;
  margin: 20px 0; padding: 10px 10px 10px 14px; border-radius: var(--radius-sm); background: var(--navy-2); }
.secret-value code { overflow-wrap: anywhere; color: var(--gold-ondark); font-size: 13px; }
.secret-value .icon-button { background: transparent; border-color: rgba(255,255,255,.16); }
.secret-value .icon-button img { filter: brightness(0) invert(1); opacity: .8; }

.edit-dialog { width: min(480px, calc(100vw - 36px)); border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-2); padding: 0; }
.edit-dialog::backdrop { background: rgba(27,31,42,.5); backdrop-filter: blur(5px); }
.edit-dialog form { padding: 26px 28px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1100px) {
  :root { --sidebar: 216px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-panel { grid-template-columns: 1fr; }
  .hero-orbit { display: none; }
  .semantic-layout, .two-column { grid-template-columns: 1fr; }
  .form-table-grid { grid-template-columns: 310px minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 10px 12px; flex-direction: row; align-items: center; }
  .sidebar .brand-lockup, .sidebar-links, .operator-card { display: none; }
  .navigation { display: flex; overflow: auto; margin: 0; width: 100%; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 -2px var(--gold-ondark); }
  .workspace { padding: 0 16px 35px; }
  .topbar { height: auto; min-height: 84px; position: static; align-items: flex-start; padding: 16px 0; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .compact-select { min-width: 122px; }
  .form-table-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .hero-panel { padding: 28px; }
  .hero-panel h2 { font-size: 29px; }
}
@media (max-width: 560px) {
  .login-view { padding: 14px; }
  .login-card { padding: 26px 22px; }
  .topbar { display: block; }
  .topbar-actions { justify-content: flex-start; margin-top: 12px; }
  .metric-grid { grid-template-columns: 1fr; }
  .split, .search-form { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .hero-panel { min-height: 0; }
  .navigation span { display: none; }
  .nav-item { padding: 10px; }
  .workspace { padding-inline: 11px; }
}

/* ============================================================ RTL */
[dir="rtl"] .sidebar { inset: 0 0 0 auto; }
[dir="rtl"] .workspace { grid-column: 1; }
[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 var(--gold-ondark); }
[dir="rtl"] .toast-region { right: auto; left: 22px; }
