/* ==========================================================================
   PHILEO INDOOR — Design System "URBAN SIGNAL"
   Tema escuro (azul/preto profundo), grafite nas linhas, laranja só como
   sinal/ação/seleção/destaque. Tipografia com hierarquia, muito respiro.
   ========================================================================== */

:root {
  /* superfícies */
  --bg:        #0D1117;
  --surface:   #161B22;
  --surface-2: #1C232D;
  --surface-3: #232B36;
  --line:      #2B3139;
  --line-soft: rgba(233,236,239,.07);

  /* texto */
  --ink:    #E9ECEF;
  --head:   #F5F7FA;
  --muted:  #8B95A3;
  --faint:  #5E6875;

  /* marca: laranja = ação / sinal / seleção / destaque (uso pontual) */
  --accent:      #FF6A00;
  --accent-ink:  #FF8534;
  --accent-soft: rgba(255,106,0,.12);
  --accent-line: rgba(255,106,0,.35);

  /* semânticas (separadas da marca) */
  --ok:     #34D399; --ok-soft:   rgba(52,211,153,.13);
  --warn:   #F5B142; --warn-soft: rgba(245,177,66,.13);
  --crit:   #F26D6D; --crit-soft: rgba(242,109,109,.13);
  --info:   #6BA5FF; --info-soft: rgba(107,165,255,.13);

  /* forma */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(0,0,0,.3);
  --sh-2: 0 4px 16px -6px rgba(0,0,0,.5);
  --sh-3: 0 20px 48px -18px rgba(0,0,0,.7);

  /* espaçamento (grid 4px) */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px; --s6:24px; --s8:32px; --s10:40px; --s12:48px;

  /* tipografia */
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --z-drawer: 80; --z-modal: 90; --z-toast: 100; --z-login: 120;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent-ink); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* tipografia — escala e hierarquia */
h1,h2,h3,h4 { margin: 0; color: var(--head); font-weight: 680; letter-spacing: -.01em; line-height: 1.2; text-wrap: balance; }
.t-display { font-size: clamp(28px, 4vw, 40px); font-weight: 740; letter-spacing: -.02em; }
.t-h1 { font-size: 24px; font-weight: 700; letter-spacing: -.015em; }
.t-h2 { font-size: 19px; font-weight: 680; }
.t-h3 { font-size: 15px; font-weight: 650; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

/* ============================ LAYOUT / SHELL ============================= */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 10px 24px; }
.brand-logo { display: block; width: 168px; height: auto; object-fit: contain; object-position: left center; }
.login-logo { display: block; width: min(210px, 80%); height: auto; margin: 0 auto 10px; object-fit: contain; }
.brand b { color: var(--head); font-weight: 760; letter-spacing: -.025em; font-size: 16px; line-height: 1.2; }
.brand b span { color: var(--accent); font-weight: 650; }
.brand small { color: var(--faint); font-size: 10px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  margin: 16px 12px 5px; color: var(--faint); font-family: var(--mono);
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.nav-section:first-child { margin-top: 0; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 550; font-size: 14.5px; cursor: pointer; position: relative;
  transition: background .12s, color .12s;
}
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a.active { background: var(--surface-2); color: var(--head); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a .count { margin-left: auto; background: var(--accent); color: #1a0f00; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: var(--r-pill); display: grid; place-items: center; padding: 0 5px; }

.sidebar .foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.sidebar .foot .who { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; padding: 0 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 30px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); z-index: 20; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink); background: var(--surface); cursor: pointer; padding: 9px; }
.menu-toggle .ico { width: 18px; height: 18px; }
.sidebar-scrim { display: none; position: fixed; inset: 0; border: 0; padding: 0; background: rgba(6,9,13,.7); z-index: 55; }
.view { padding: 28px 30px 60px; max-width: 1180px; width: 100%; }

/* ============================ BOTÕES ==================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; border-radius: var(--r-sm); padding: 9px 15px;
  border: 1px solid transparent; transition: background .12s, border-color .12s, transform .05s, opacity .12s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #1a0f00; }
.btn-primary:hover { background: #ff7d1f; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); background: var(--surface); }
.btn-subtle { background: var(--surface-2); color: var(--ink); }
.btn-subtle:hover { background: var(--surface-3); }
.btn-danger { background: transparent; border-color: var(--line); color: var(--crit); }
.btn-danger:hover { border-color: var(--crit); background: var(--crit-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-icon { padding: 8px; }

/* ============================ FORMULÁRIOS ============================== */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; font: inherit; font-size: 14px; transition: border-color .12s, background .12s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); background: var(--surface-2); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B95A3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ============================ CARDS =================================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; }
.card.pad-sm { padding: 16px 18px; }
.card.hover { transition: border-color .12s, background .12s; cursor: pointer; }
.card.hover:hover { border-color: var(--muted); background: var(--surface-2); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { flex: 1; }

/* grids utilitários */
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.gap-lg { gap: 24px; }

/* ============================ STAT / KPI ============================== */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 550; letter-spacing: .01em; }
.stat .v { font-size: 30px; font-weight: 720; color: var(--head); letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Visão geral: indicadores formam uma faixa operacional única, não quatro
   caixas concorrentes. Cards ficam reservados aos blocos de contexto. */
#dash-stats { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 0 !important;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
#dash-stats .stat { border: 0; border-right: 1px solid var(--line-soft); border-radius: 0; min-width: 0; }
#dash-stats .stat:last-child { border-right: 0; }
#monitor-stats { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
#monitor-stats .stat { border: 0; border-right: 1px solid var(--line-soft); border-radius: 0; min-width: 0; }
#monitor-stats .stat:last-child { border-right: 0; }

/* ============================ BADGES / STATUS ========================= */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 620; letter-spacing: .01em; border: 1px solid transparent; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-ok .dot { background: var(--ok); }
.badge-off { background: var(--crit-soft); color: var(--crit); } .badge-off .dot { background: var(--crit); }
.badge-warn { background: var(--warn-soft); color: var(--warn); } .badge-warn .dot { background: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); } .badge-info .dot { background: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--muted); } .badge-neutral .dot { background: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); } .badge-accent .dot { background: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 4px 10px; font-size: 13px; color: var(--ink); }

/* ============================ TABELAS ================================= */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table.rows-hover tbody tr:hover { background: var(--surface-2); cursor: pointer; }

/* Lista operacional da Rede: uma superfície contínua, leitura horizontal e
   ação contextual. Evita transformar cada estabelecimento em um dashboard. */
.entity-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.entity-row { position: relative; display: grid; grid-template-columns: minmax(230px, 1.1fr) minmax(260px, .9fr) minmax(280px, 1.2fr);
  align-items: center; gap: 22px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  transition: background .12s; }
.entity-row:last-child { border-bottom: 0; }
.entity-row:hover { background: var(--surface-2); }
.content-client-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.content-client-group > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; cursor: pointer; }
.content-client-group > summary::-webkit-details-marker { display: none; }
.content-client-group > summary:hover { background: var(--surface-2); }
.content-client-group[open] > summary { border-bottom: 1px solid var(--line); }
.program-flow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.program-flow > span { color: var(--faint); }
.form-page-card { margin-top: 20px; width: 100%; max-width: 1080px; }
.form-page-card > div { max-width: none; }
.program-start { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.program-start .step { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.program-start .step b { display: block; color: var(--head); font-size: 14px; margin-bottom: 5px; }
.program-start .step p { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 0; }
.tv-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.target-locations { display: flex; flex-direction: column; gap: 14px; }
.location-target { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.location-target.selected { border-color: var(--accent-line); }
.location-target-head { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.location-symbol { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #0a0d11; color: var(--accent); font-size: 25px; font-weight: 400; }
.location-symbol img { display: block; width: 100%; height: 100%; padding: 5px; object-fit: contain; }
.location-building { position: relative; width: 21px; height: 23px; border: 2px solid var(--accent); border-radius: 2px 2px 1px 1px;
  background: repeating-linear-gradient(90deg, transparent 0 4px, var(--accent) 4px 6px, transparent 6px 10px),
              repeating-linear-gradient(0deg, transparent 0 5px, color-mix(in srgb, var(--accent) 65%, transparent) 5px 7px, transparent 7px 11px); }
.location-building::before { content: ""; position: absolute; left: -4px; right: -4px; top: -6px; height: 4px;
  border: 2px solid var(--accent); border-bottom: 0; border-radius: 3px 3px 0 0; }
.location-building::after { content: ""; position: absolute; left: 7px; bottom: -2px; width: 6px; height: 8px;
  border: 2px solid var(--accent); border-bottom: 0; background: #0a0d11; }
.location-title { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 2px; }
.location-title b { color: var(--head); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-title span { color: var(--muted); font-size: 12px; }
.location-target .tv-picker { padding: 12px; }
.tv-choice { position: relative; display: flex; align-items: center; gap: 13px; min-width: 0; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer;
  transition: border-color .14s, background .14s, transform .08s; }
.tv-choice:hover { border-color: var(--muted); background: var(--surface-3); }
.tv-choice:active { transform: translateY(1px); }
.tv-choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-line) inset; }
.tv-choice > input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.tv-device { flex: 0 0 72px; display: flex; flex-direction: column; align-items: center; }
.tv-screen { width: 72px; height: 43px; display: grid; place-items: center; padding: 8px; overflow: hidden;
  border: 3px solid #69717d; border-radius: 5px; background: #090c10; box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
.tv-screen img { display: block; width: 100%; height: auto; max-height: 20px; object-fit: contain; }
.tv-stand { width: 25px; height: 5px; margin-top: 3px; border-top: 3px solid #69717d; border-radius: 50%; }
.tv-choice-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tv-choice-copy b, .tv-choice-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-choice-copy b { color: var(--head); font-size: 13.5px; }
.tv-choice-copy span { color: var(--muted); font-size: 12px; }
.tv-choice-copy small { color: var(--faint); font-size: 11px; }
.tv-check { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: transparent; font-size: 12px; font-weight: 800; }
.tv-choice.selected .tv-check { border-color: var(--accent); background: var(--accent); color: #1a0f00; }
.entity-main, .entity-metrics, .entity-action { min-width: 0; }
.entity-action > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-row { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .12s; }
.screen-row:last-child { border-bottom: 0; }
.screen-row:hover { background: var(--surface-2); }

/* ============================ TABS =================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs button { background: none; border: none; color: var(--muted); font: inherit; font-size: 14.5px; font-weight: 560;
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--head); border-bottom-color: var(--accent); }

/* breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumbs .sep { color: var(--faint); }
.breadcrumbs a:hover { color: var(--ink); }

/* ============================ EMPTY / SKELETON ======================= */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .icon { font-size: 30px; opacity: .5; margin-bottom: 10px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

@keyframes shimmer { 100% { background-position: -200% 0; } }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-line { height: 12px; margin: 8px 0; } .sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; }
.sk-card { height: 96px; }

/* ============================ DRAWER ================================= */
.overlay { position: fixed; inset: 0; background: rgba(6,9,13,.55); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: var(--z-drawer); }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 94vw); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--sh-3); transform: translateX(100%); transition: transform .22s cubic-bezier(.2,.7,.2,1);
  z-index: var(--z-drawer); display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer .dh { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer .db { padding: 22px 24px; overflow-y: auto; flex: 1; }

/* ============================ MODAL ================================= */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: var(--z-modal); padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .16s; }
.modal.open { opacity: 1; pointer-events: auto; }
.modal .box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: min(520px, 100%); max-height: 88vh; overflow: auto; transform: translateY(6px); transition: transform .16s; }
.modal.open .box { transform: none; }

/* ============================ STEPPER (wizard) ====================== */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.stepper .st { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 13px; font-weight: 600; }
.stepper .st .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  border: 1.5px solid var(--line); background: var(--surface); }
.stepper .st.active { color: var(--head); } .stepper .st.active .n { border-color: var(--accent); color: var(--accent-ink); }
.stepper .st.done .n { background: var(--accent); border-color: var(--accent); color: #1a0f00; }
.stepper .bar { flex: 1; height: 1.5px; background: var(--line); }

/* ============================ TOAST ================================= */
#toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: var(--z-toast); }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-sm); padding: 12px 16px; box-shadow: var(--sh-2); max-width: 400px; font-size: 14px;
  animation: toastin .2s ease; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--crit); }
@keyframes toastin { from { opacity: 0; transform: translateX(12px); } }

/* ============================ LOGIN ================================= */
#login { position: fixed; inset: 0; background: var(--bg); display: none; place-items: center; z-index: var(--z-login); }
#login.show { display: grid; }
#login { padding: 16px; }
#login .box { width: min(360px, 100%); }

/* ============================ HELPERS =============================== */
.hidden { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.pill-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 3px; }
.pill-toggle button { background: none; border: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 14px; border-radius: var(--r-pill); cursor: pointer; }
.pill-toggle button.active { background: var(--accent); color: #1a0f00; }

@media (max-width: 1120px) and (min-width: 861px) {
  .entity-row { grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.35fr); }
  .entity-action { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; z-index: 60; width: min(288px, 86vw); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sh-3); }
  .sidebar.open { transform: none; }
  .sidebar-scrim.open { display: block; }
  .menu-toggle { display: grid; }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
  #dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #monitor-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #dash-stats .stat:nth-child(2) { border-right: 0; }
  #monitor-stats .stat:nth-child(2) { border-right: 0; }
  #dash-stats .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  #monitor-stats .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .entity-row { grid-template-columns: 1fr; gap: 12px; }
  .program-flow { align-items: stretch; flex-direction: column; }
  .program-flow > span { display: none; }
  .program-start { grid-template-columns: 1fr; }
  .entity-action { padding-top: 12px; border-top: 1px solid var(--line-soft); }
}
@media (max-width: 520px) {
  body { font-size: 14px; }
  .view { padding-top: 22px; }
  #dash-stats { grid-template-columns: 1fr !important; }
  #monitor-stats { grid-template-columns: 1fr !important; }
  #dash-stats .stat { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  #monitor-stats .stat { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  #dash-stats .stat:last-child { border-bottom: 0; }
  #monitor-stats .stat:last-child { border-bottom: 0; }
  .card { padding: 18px; }
  .t-h1 { font-size: 22px; }
  .screen-row { align-items: flex-start; flex-direction: column; }
  .screen-row .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
