/* ShippyVIC - interfaccia in stile Shopify admin */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Sora", var(--font);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --frame: #1a1a1a;
  --frame-text: #e3e3e3;
  --frame-muted: #b5b5b5;
  --frame-hover: #2a2a2a;
  --frame-active: #303030;

  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #f1f1f1;
  --surface-hover: #f7f7f7;
  --border: #e3e3e3;
  --border-strong: #cccccc;
  --text: #303030;
  --text-strong: #1a1a1a;
  --text-2: #616161;
  --text-3: #8a8a8a;
  --link: #005bd3;
  --focus: #005bd3;
  --brand: #0e8104;
  --brand-soft: #f2ffd4;

  --b-neutral-bg: rgba(0, 0, 0, 0.06);   --b-neutral-fg: #4a4a4a;
  --b-info-bg: #e0f0ff;                   --b-info-fg: #00527c;
  --b-violet-bg: #efe9fe;                 --b-violet-fg: #5c2bc2;
  --b-success-bg: #cdfee1;                --b-success-fg: #0c5132;
  --b-critical-bg: #fee9e8;               --b-critical-fg: #8e1f0b;
  --b-warning-bg: #fff1d6;                --b-warning-fg: #6b4400;

  --shadow-card: 0 1px 0 rgba(26, 26, 26, 0.07), 0 0 0 1px rgba(26, 26, 26, 0.07);
  --shadow-sheet: -24px 0 48px -12px rgba(0, 0, 0, 0.18), -1px 0 0 rgba(0, 0, 0, 0.06);
  --scrim: rgba(0, 0, 0, 0.18);

  --r-sm: 8px;
  --r-md: 12px;
  --r-pill: 999px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: light;
}


* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 13px/1.45 var(--font);
  color: var(--text);
  background: var(--frame);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* ---------- Struttura ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 12px 12px 14px;
  color: var(--frame-text);
}
.brand { display: flex; align-items: center; padding: 12px 8px 20px; border-radius: var(--r-sm); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; height: 21px; width: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; color: var(--frame-muted); padding: 16px 8px 6px; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r-sm);
  color: var(--frame-text); font-weight: 500; text-decoration: none;
  transition: background-color 120ms ease;
}
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--frame-muted); }
@media (hover: hover) and (pointer: fine) { .nav a:hover { background: var(--frame-hover); } }
.nav a[aria-current="page"] { background: var(--frame-active); color: #fff; }
.nav-install {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-top: 10px; padding: 6px 8px; border: 0; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(14, 129, 4, 0.22); color: #c9f2c2; font-weight: 550; text-align: left;
  transition: background-color 120ms ease, transform 140ms var(--ease-out);
}
.nav-install svg { width: 18px; height: 18px; flex: none; }
.nav-install:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .nav-install:hover { background: rgba(14, 129, 4, 0.34); color: #fff; } }
/* installata come app: niente margine esterno attorno al pannello sui telefoni */
@media (display-mode: standalone) and (max-width: 900px) { .sidebar { padding-top: max(8px, env(safe-area-inset-top)); } }
.nav a[aria-current="page"] svg { color: #fff; }
.nav .count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  padding: 0 7px; line-height: 20px; border-radius: var(--r-pill);
  background: #3a3a3a; color: #e3e3e3;
}
.nav .count.alert { background: #e51c00; color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.sidebar-foot .who { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--frame-muted); cursor: pointer;
  transition: background-color 120ms ease, transform 120ms var(--ease-out);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--frame-hover); color: #fff; } }

.main {
  background: var(--panel);
  margin: 8px 8px 8px 0;
  border-radius: var(--r-md);
  min-width: 0;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 16px);
}

/* Barra superiore con i numeri chiave, come la home di Shopify */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 14px 20px 12px;
}
.topbar .period { color: var(--text-2); }
.kpis { display: flex; gap: 28px; }
.kpi { text-align: center; }
.kpi-label { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.kpi-value { font-weight: 600; color: var(--text-strong); font-size: 13px; font-variant-numeric: tabular-nums; }
.kpi-value.alert { color: #c70a24; }
.live { justify-self: end; display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); white-space: nowrap; }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.live-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--brand); opacity: 0;
  animation: ping 2.4s var(--ease-out) infinite;
}
.live-dot.stale { background: var(--text-3); }
.live-dot.stale::after { display: none; }
.live-dot.error { background: #e51c00; }
.live-dot.error::after { border-color: #e51c00; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 70%, 100% { transform: scale(1.4); opacity: 0; } }

.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px 24px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-title { font: 650 22px/1.2 var(--font-display); letter-spacing: -0.02em; color: var(--text-strong); margin: 0; }
.page-sub { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 14px; border-radius: var(--r-pill);
  border: 0; cursor: pointer; font-weight: 550; white-space: nowrap;
  background: var(--surface-3); color: var(--text-strong);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08);
  transition: background-color 140ms ease, transform 140ms var(--ease-out), opacity 140ms ease;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: #e3e3e3; text-decoration: none; } }
.btn.primary { background: #303030; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 1px 0 rgba(0,0,0,0.3); }
@media (hover: hover) and (pointer: fine) { .btn.primary:hover { background: #1a1a1a; } }
.btn.ghost { background: transparent; box-shadow: none; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: var(--surface-3); color: var(--text-strong); } }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn.loading svg { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chip di attenzione ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* Saluto in apertura, come la home di Shopify */
.hello { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 22px 0 22px; }
.hello-title {
  margin: 0 0 18px; font: 600 28px/1.25 var(--font); letter-spacing: -0.025em; color: var(--text-strong);
  text-wrap: balance;
  animation: hello-in 520ms var(--ease-out) both;
}
.hello .chips { justify-content: center; margin: 0; animation: hello-in 520ms 60ms var(--ease-out) both; }
@keyframes hello-in { from { opacity: 0; transform: translateY(6px); } }

/* Scrivi al cliente */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.seg-btn {
  height: 28px; padding: 0 12px; border-radius: var(--r-pill); border: 0; cursor: pointer;
  background: var(--surface-3); color: var(--text-2); font-weight: 550;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms var(--ease-out);
}
.seg-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .seg-btn:hover { color: var(--text-strong); } }
.seg-btn[aria-checked="true"] { background: var(--text-strong); color: #fff; }
textarea.msg { min-height: 132px; max-height: 340px; field-sizing: content; font-size: 13px; }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.contact-hint { font-size: 12px; }
.btn.go { background: var(--brand); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 1px 0 rgba(0,0,0,0.2); }
@media (hover: hover) and (pointer: fine) { .btn.go:hover { background: #0b6e03; } }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 6px 0 12px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-card);
  border: 0; cursor: pointer; font-weight: 500; color: var(--text-strong);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .chip:hover { background: var(--surface-hover); } }
.chip .n {
  min-width: 22px; padding: 0 7px; line-height: 20px; border-radius: var(--r-pill);
  background: var(--surface-3); font-size: 12px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
}
.chip.critical .n { background: var(--b-critical-bg); color: var(--b-critical-fg); }
.chip.warning .n { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.chip[aria-pressed="true"] { box-shadow: 0 0 0 1.5px var(--text-strong); }
.chips-ok {
  display: inline-flex; align-items: center; gap: 8px; color: var(--b-success-fg);
  background: var(--b-success-bg); padding: 6px 12px; border-radius: var(--r-pill); font-weight: 500;
}
.chips-ok svg { width: 16px; height: 16px; }

/* ---------- Card e tabella ---------- */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); overflow: clip; }
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px; }
.card-title { font-weight: 650; color: var(--text-strong); font-size: 14px; margin: 0 0 4px; }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 8px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 28px; padding: 0 10px; border-radius: var(--r-sm);
  border: 0; background: transparent; cursor: pointer; color: var(--text-2); font-weight: 550;
}
@media (hover: hover) and (pointer: fine) { .tab:hover { background: var(--surface-3); color: var(--text-strong); } }
.tab[aria-selected="true"] { background: var(--surface-3); color: var(--text-strong); }
.tab .tc { font-size: 12px; color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tc { color: var(--text-2); }
.tab .tc.alert { color: #c70a24; font-weight: 600; }

.search {
  position: relative; flex: 0 1 280px; min-width: 160px;
}
.search svg { position: absolute; left: 9px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 30px; padding: 0 30px 0 32px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.search kbd {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font: 500 11px/18px var(--font); color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.grid-head, .row {
  display: grid;
  grid-template-columns: 82px 92px minmax(140px, 1.2fr) minmax(120px, 1fr) 168px minmax(180px, 1.6fr) 52px;
  align-items: center; gap: 12px; padding: 0 16px;
}
.grid-head {
  height: 34px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 550; color: var(--text-2);
}
.grid-head .r, .row .r { text-align: right; }
.row {
  min-height: 46px; padding-top: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); cursor: pointer; outline: none;
  transition: background-color 80ms ease;
}
.row:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { .row:hover { background: var(--surface-hover); } }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }
.row.selected { background: var(--surface-3); }
.cell { min-width: 0; }
.cell-order { font-weight: 650; color: var(--text-strong); display: flex; align-items: center; gap: 6px; }
.cell-order .note-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--link); flex: none; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-last .t { color: var(--text); }
.cell-last .m { color: var(--text-3); font-size: 12px; }
.cell-status { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.prob { font-size: 12px; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }
.prob svg { width: 14px; height: 14px; flex: none; }
.prob.critical { color: #b51c06; }
.prob.warning { color: #8a5a00; }
.prob.acked { color: var(--text-3); font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px 0 7px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--b-neutral-bg); color: var(--b-neutral-fg);
}
.badge .pi { width: 10px; height: 10px; flex: none; }
.badge.info { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge.violet { background: var(--b-violet-bg); color: var(--b-violet-fg); }
.badge.success { background: var(--b-success-bg); color: var(--b-success-fg); }
.badge.critical { background: var(--b-critical-bg); color: var(--b-critical-fg); }
.badge.warning { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.badge.plain { background: var(--surface-3); color: var(--text-2); }

.list-foot { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--border); }
.empty { padding: 56px 24px; text-align: center; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 8px; }
.empty h3 { margin: 0 0 4px; font-size: 14px; color: var(--text-strong); }

/* scheletro di caricamento */
.skel { height: 46px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 16px; }
.skel i { display: block; height: 10px; border-radius: 6px; background: var(--surface-3); }

/* ---------- Pannello di dettaglio ---------- */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity 240ms ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 8px; right: 8px; bottom: 8px; z-index: 50;
  width: min(540px, calc(100vw - 16px));
  background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column;
  transform: translateX(calc(100% + 16px));
  transition: transform 200ms var(--ease-out);
  visibility: hidden;
}
.sheet.open { transform: translateX(0); transition: transform 340ms var(--ease-drawer); visibility: visible; }
.sheet.closing { visibility: visible; }
.sheet-head { padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.sheet-top { display: flex; align-items: center; gap: 10px; }
.sheet-title { font: 650 20px/1.2 var(--font-display); letter-spacing: -0.02em; color: var(--text-strong); margin: 0; }
.sheet-top .badge { margin-top: 2px; }
.sheet-top .spacer { flex: 1; }
.sheet-close { color: var(--text-2); }
@media (hover: hover) and (pointer: fine) { .sheet-close:hover { background: var(--surface-3); color: var(--text-strong); } }
.sheet-meta { color: var(--text-2); margin-top: 4px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 20px 28px; overscroll-behavior: contain; }
.sheet-body > section + section { margin-top: 22px; }
.sec-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }

.callout {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--b-critical-bg); color: var(--b-critical-fg);
}
.callout.warning { background: var(--b-warning-bg); color: var(--b-warning-fg); }
.callout.done { background: var(--surface-3); color: var(--text-2); }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout b { display: block; font-weight: 650; }
.callout .act { margin-top: 10px; display: flex; gap: 8px; }
.callout .btn { height: 28px; background: rgba(255,255,255,0.7); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: var(--r-md); overflow: hidden; box-shadow: 0 0 0 1px var(--border); }
.fact { background: var(--surface); padding: 10px 12px; min-width: 0; }
.fact .k { font-size: 12px; color: var(--text-2); }
.fact .v { color: var(--text-strong); font-weight: 550; margin-top: 2px; overflow-wrap: anywhere; }
.fact .v a { font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl { position: relative; padding: 0 0 16px 24px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--border); border-radius: 2px; }
.tl:last-child { padding-bottom: 0; }
.tl:last-child::before { display: none; }
.tl .dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--border-strong); }
.tl.first .dot { box-shadow: inset 0 0 0 4px var(--text-strong); }
.tl.first.success .dot { box-shadow: inset 0 0 0 4px #29845a; }
.tl.first.critical .dot { box-shadow: inset 0 0 0 4px #e51c00; }
.tl .t { font-weight: 550; color: var(--text-strong); }
.tl:not(.first) .t { font-weight: 500; color: var(--text); }
.tl .m { color: var(--text-3); font-size: 12px; margin-top: 1px; }

textarea.note {
  width: 100%; min-height: 84px; resize: vertical; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); outline: none; line-height: 1.5;
}
textarea.note:focus { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.note-state { font-size: 12px; color: var(--text-3); margin-top: 6px; height: 16px; }

/* ---------- Notifiche e diagnostica ---------- */
.log-row { display: grid; grid-template-columns: 120px 72px 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.log-row:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { .log-row:hover { background: var(--surface-hover); } }
.log-row .when { color: var(--text-2); font-variant-numeric: tabular-nums; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.check svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.check.ok svg { color: #29845a; }
.check.ko svg { color: #e51c00; }
.check .d { color: var(--text-2); font-size: 12px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input {
  height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; min-width: 0;
}
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.steps { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; line-height: 1.6; }
.run-row { display: grid; grid-template-columns: 130px 80px 1fr 1fr 1fr; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.run-row:last-child { border-bottom: 0; }
.run-log { grid-column: 1 / -1; color: var(--text-2); font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  background: #1a1a1a; color: #fff; padding: 10px 16px; border-radius: var(--r-pill); font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: opacity 260ms ease, transform 260ms var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(12px); } }
.toast.out { opacity: 0; transform: translateY(12px); transition-duration: 180ms; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: 0 24px 64px rgba(0,0,0,0.35); }
.login-card .brand { padding: 0 0 20px; }
.login-logo { display: block; height: 34px; width: auto; margin-bottom: 24px; }
.login-card h1 { font: 650 20px/1.25 var(--font-display); letter-spacing: -0.02em; margin: 0 0 4px; color: var(--text-strong); }
.login-card p { color: var(--text-2); margin: 0 0 18px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-weight: 550; margin-bottom: 6px; color: var(--text-strong); }
.field .input { width: 100%; height: 36px; }
.login-card .btn { width: 100%; height: 36px; margin-top: 6px; }
.login-err { background: var(--b-critical-bg); color: var(--b-critical-fg); padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpis { gap: 18px; }
  .grid-head, .row { grid-template-columns: 76px 86px minmax(120px, 1fr) minmax(100px, 1fr) 160px minmax(150px, 1.4fr); }
  .col-days { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center;
    padding: 8px 12px; gap: 8px; background: var(--frame); min-width: 0;
  }
  .brand { padding: 0; }
  .brand-logo { height: 17px; }
  .nav { min-width: 0; }
  .live { min-width: 0; overflow: hidden; }
  .live span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpis { scrollbar-width: none; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: none; }
  .brand { padding: 0; }
  .nav-label, .sidebar-foot .who, .sidebar-foot .avatar { display: none; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; flex: 1; }
  .nav a { white-space: nowrap; }
  .nav a span.lbl, .nav-install span.lbl { display: none; }
  .nav-install { width: auto; margin: 0; flex: none; }
  .nav a[aria-current="page"] span.lbl { display: inline; }
  .sidebar-foot { margin: 0; padding: 0; }
  .main { margin: 0; border-radius: 0; min-height: calc(100vh - 48px); }
  .topbar { grid-template-columns: 1fr auto; padding: 12px 16px 4px; }
  .topbar .period { display: none; }
  .kpis { order: 3; grid-column: 1 / -1; justify-content: space-between; gap: 8px; overflow-x: auto; }
  .content { padding: 14px 16px 64px; }
}
@media (max-width: 760px) {
  .hello { padding: 14px 0 16px; }
  .hello-title { font-size: 22px; }
  .grid-head { display: none; }
  .row {
    grid-template-columns: 1fr auto; grid-template-areas: "order status" "cust cust" "last last";
    gap: 2px 12px; padding: 12px 16px;
  }
  .row .c-order { grid-area: order; }
  .row .c-status { grid-area: status; align-items: flex-end; }
  .row .c-date, .row .col-days, .row .c-dest { display: none; }
  .row .c-cust { grid-area: cust; }
  .row .c-cust::after { content: attr(data-dest); color: var(--text-3); margin-left: 6px; }
  .row .c-last { grid-area: last; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .toolbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: -1; }
  .facts { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 1fr auto; }
  .log-row .when { grid-column: 1 / -1; }
  .run-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .hello-title, .hello .chips { animation: none; }
  .sheet, .sheet.open { transition: opacity 160ms ease; transform: none; opacity: 0; }
  .sheet.open { opacity: 1; }
  .live-dot::after { animation: none; }
  .btn:active, .chip:active, .icon-btn:active { transform: none; }
  .toast { transition: opacity 160ms ease; }
}
