/* PSAI · Lopettia operator console. Visual system ported from Servitium
   (static/styles.css) so the two products feel like one family. No theming. */
:root {
  --gold:  #FCE28A;
  --peach: #F7B285;
  --coral: #F38281;
  --teal:  #0D9488;
  --mint:  #5EEAD4;
  --navy:  #0B1120;
  --navy-card: #182440;
  --cream: #FAF6F1;
  --line:  rgba(11, 17, 32, .12);
  --muted: rgba(11, 17, 32, .6);
  --ok:    #2f9461;
  --warn:  #c97a00;
  --bad:   #c0392b;
  --crit:  #8e1a13;
  --shadow: 0 8px 24px rgba(11, 17, 32, .08);
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--cream); color: var(--navy); min-height: 100vh; }

button {
  cursor: pointer; font: inherit; color: inherit; background: white;
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem 1rem;
  transition: transform .08s, box-shadow .08s, background .1s;
}
button:hover:not(:disabled) { box-shadow: var(--shadow); transform: translateY(-1px); }
button.primary { background: linear-gradient(135deg, var(--gold), var(--peach)); border-color: transparent; font-weight: 600; }
button.danger { border-color: var(--coral); color: var(--coral); }
button.tertiary { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.sm { padding: .35rem .7rem; font-size: .85rem; }

input, select, textarea { font: inherit; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: white; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--peach); outline-offset: -1px; }
textarea { resize: vertical; min-height: 80px; }
label { display: block; margin: .8rem 0 .25rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
a { color: var(--coral); text-decoration: none; }

/* ── Login ── */
.login { display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-height: 100vh; padding: 6vh 2rem 2rem;
  background: radial-gradient(circle at 20% 0%, rgba(252,226,138,.6), transparent 40%),
              radial-gradient(circle at 80% 100%, rgba(243,130,129,.35), transparent 50%), var(--cream); }
.brand { text-align: center; margin-bottom: 1.25rem; }
/* Canonical Lopettia logomark (sunburst + L) — single source of truth, served
   from brand/logo-sol.svg. Every .sun on any page renders the real mark. */
.brand .sun { width: 76px; height: 76px; margin: 0 auto .75rem;
  background: url('../brand/logo-sol.svg') center/contain no-repeat;
  filter: drop-shadow(0 3px 16px rgba(243,130,129,.35)); }
.brand.small { display: flex; align-items: center; gap: .55rem; margin: 0; }
.brand.small .sun { width: 30px; height: 30px; margin: 0; filter: none; }
.brand.small span { font-weight: 700; flex: 1; font-family: "Quicksand", "Inter", system-ui, sans-serif; letter-spacing: .01em; }
.brand.small small { display: block; font-size: .6rem; letter-spacing: .12em; opacity: .6; font-weight: 600; }
.brand h1 { font-size: 1.7rem; margin: .25rem 0; font-weight: 700; font-family: "Quicksand", "Inter", system-ui, sans-serif; letter-spacing: .01em; }
.brand .tagline { color: var(--muted); margin: 0; }
#login-form { background: white; padding: 2rem; width: 100%; max-width: 380px; border-radius: var(--radius); box-shadow: var(--shadow); }
#login-form button { width: 100%; margin-top: 1rem; padding: .8rem; }
#login-form .hint { margin-top: .8rem; font-size: .8rem; color: var(--muted); }

/* ── App shell ── */
/* Fixed to the viewport height (dvh handles iOS Safari's dynamic toolbar) so the
   sidebar and the content each own their scroll — the left menu never scrolls
   away with the right-hand content. */
.app { display: grid; grid-template-columns: 244px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { background: var(--navy); color: var(--cream); padding: 1rem; display: flex; flex-direction: column; transition: transform .2s ease; min-height: 0; overflow-y: auto; }
.sidebar .brand.small { color: var(--cream); padding: .5rem; }
.sidebar nav { margin-top: 1rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; overflow-y: auto; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .45; padding: .85rem .75rem .35rem; font-weight: 700; }
.sidebar .nav-link { padding: .55rem .75rem; color: var(--cream); text-decoration: none; border-radius: 8px; font-size: .95rem; opacity: .8; cursor: pointer; }
.sidebar .nav-link:hover { opacity: 1; background: rgba(255,255,255,.06); }
.sidebar .nav-link.active { opacity: 1; background: linear-gradient(135deg, rgba(252,226,138,.25), rgba(243,130,129,.15)); font-weight: 600; }
.user-card { border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; font-size: .85rem; }
.user-card .who { opacity: .8; word-break: break-word; }
.user-card button { width: 100%; background: transparent; color: var(--cream); border-color: rgba(255,255,255,.2); }
.lang-toggle { display: flex; gap: .4rem; justify-content: center; font-size: .78rem; }
.lang-toggle a { color: rgba(250,246,241,.55); font-weight: 600; }
.lang-toggle a.active { color: var(--gold); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { background: white; padding: 1rem 2rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 1.25rem; flex: 1; }
.topbar .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.hamburger, .hamburger-close { display: none; background: transparent; border: 1px solid transparent; padding: .25rem .5rem; font-size: 1.2rem; }
.hamburger-close { color: var(--cream); }
.content { padding: 2rem; flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.loading { color: var(--muted); }
.crumb { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
.crumb a { cursor: pointer; border-bottom: 1px dashed var(--line); }

/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.kpi { background: white; padding: 1rem 1.25rem; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); border-left: 4px solid var(--peach); }
.kpi.ok { border-left-color: var(--ok); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); }
.kpi.gold { border-left-color: var(--gold); }
.kpi .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 1.8rem; font-weight: 700; margin: .25rem 0; }

/* ── Toolbar + tables ── */
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; }
.table-wrap { background: white; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { background: var(--cream); font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(252,226,138,.1); }

/* ── Badges ── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--cream); color: var(--muted); white-space: nowrap; }
.badge.l1 { background: #e0f2fe; color: #075985; }
.badge.l2 { background: rgba(247,178,133,.25); color: #8a4900; }
.badge.l3 { background: rgba(192,57,43,.15); color: var(--bad); }
.badge.p-urgent, .badge.p-high { background: rgba(243,130,129,.2); color: var(--bad); }
.badge.p-medium { background: rgba(252,226,138,.4); color: #6e5400; }
.badge.p-low { background: rgba(47,148,97,.1); color: var(--ok); }
.badge.new, .badge.triaged, .badge.assigned { background: #e9e7f5; color: #4a3f8a; }
.badge.in_progress, .badge.awaiting_customer, .badge.reopened { background: rgba(247,178,133,.25); color: #8a4900; }
.badge.escalated { background: rgba(192,57,43,.15); color: var(--bad); }
.badge.resolved, .badge.closed, .badge.active, .badge.published { background: rgba(47,148,97,.15); color: var(--ok); }
.badge.expiring { background: rgba(252,226,138,.4); color: #6e5400; }
.badge.expired { background: rgba(192,57,43,.15); color: var(--bad); }
.badge.ch-vapi { background: rgba(243,130,129,.18); color: var(--coral); }
.badge.ch-web { background: var(--cream); color: var(--muted); }
.badge.ch-whatsapp { background: rgba(47,148,97,.15); color: var(--ok); }
.badge.ch-email, .badge.ch-sms { background: #e0f2fe; color: #075985; }
.badge.ch-voice { background: rgba(13,148,136,.15); color: var(--teal); }
.badge.sla-ok { background: rgba(47,148,97,.15); color: var(--ok); }
.badge.sla-soon { background: rgba(201,122,0,.15); color: var(--warn); }
.badge.sla-overdue { background: rgba(192,57,43,.2); color: var(--bad); font-weight: 700; }

/* ── Cards / detail ── */
.empty { background: white; border-radius: var(--radius); border: 1px dashed var(--line); padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.detail-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
.card { background: white; padding: 1.25rem 1.5rem; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card + .card { margin-top: 1rem; }
.detail-grid { display: grid; grid-template-columns: minmax(84px, 130px) 1fr; column-gap: .5rem; row-gap: .5rem; align-items: baseline; }
.detail-grid dt { color: var(--muted); font-size: .85rem; }
.detail-grid dd { margin: 0; font-size: .95rem; word-break: break-word; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.rowflex { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.rowflex > * { flex: 1; min-width: 140px; }

.msg-thread { display: flex; flex-direction: column; gap: .75rem; }
.msg { background: var(--cream); border-radius: 10px; padding: .75rem 1rem; font-size: .92rem; }
.msg.internal { background: rgba(252,226,138,.25); border-left: 3px solid var(--peach); }
.msg .meta { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.timeline { border-left: 2px solid var(--line); padding-left: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.timeline .ev { font-size: .85rem; }
.timeline .ev .at { color: var(--muted); font-size: .75rem; }

.chain-status { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 600; background: rgba(47,148,97,.15); color: var(--ok); margin-bottom: 1rem; }
.chain-status.broken { background: rgba(192,57,43,.15); color: var(--bad); }
.chain-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
code.hash, code.id { font-family: ui-monospace, Menlo, monospace; font-size: .75rem; color: var(--muted); }
.score-bar { height: 8px; background: var(--cream); border-radius: 999px; overflow: hidden; margin-top: .4rem; }
.score-bar > div { height: 100%; background: linear-gradient(90deg, var(--coral), var(--peach), var(--gold), var(--ok)); }

/* ── Modal ── */
dialog { border: none; border-radius: var(--radius); padding: 1.5rem 2rem; max-width: 640px; width: 92%; box-shadow: 0 25px 60px rgba(11,17,32,.35); }
dialog::backdrop { background: rgba(11,17,32,.55); }
dialog h3 { margin-top: 0; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Toast ── */
#toast-host { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; }
.toast { background: var(--navy); color: var(--cream); padding: .85rem 1.2rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; max-width: 380px; cursor: pointer; animation: slidein .2s ease; }
.toast.error { background: var(--bad); }
.toast.success { background: linear-gradient(135deg, var(--gold), var(--peach)); color: var(--navy); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Command palette ── */
#palette { padding: 0; max-width: 600px; }
#palette-input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 1rem 1.25rem; font-size: 1.05rem; }
#palette-input:focus { outline: none; }
#palette-results { max-height: 60vh; overflow: auto; padding: .5rem 0; }
.palette-row { padding: .65rem 1.25rem; cursor: pointer; display: flex; align-items: center; gap: .75rem; font-size: .95rem; }
.palette-row:hover, .palette-row.focused { background: rgba(252,226,138,.25); }
.palette-row .tag { font-size: .7rem; color: var(--muted); text-transform: uppercase; min-width: 84px; }

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; width: 280px; z-index: 100; transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .hamburger, .hamburger-close { display: inline-flex; align-items: center; }
  .content, .topbar { padding: 1rem; }
  .detail-cols, .form-row { grid-template-columns: 1fr; }
  /* Narrow screens: let the toolbar wrap so action buttons (e.g. 🎤 Voz) never
     get pushed off-screen instead of dropping to a second row. */
  .topbar { flex-wrap: wrap; row-gap: .5rem; }
  .topbar h2 { min-width: 0; font-size: 1.1rem; }
  .topbar .actions { width: 100%; }
}
@media (max-width: 520px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }

/* Live tickets list · new-row flash + "live" indicator */
@keyframes rowNewFlash { 0% { background: rgba(47,148,97,.30); } 100% { background: transparent; } }
tr.row-new > td { animation: rowNewFlash 2.6s ease-out; }
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.live-dot { font-size: .72rem; font-weight: 600; color: var(--ok); letter-spacing: .02em; margin-left: .6rem; vertical-align: middle; animation: livePulse 2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { tr.row-new > td, .live-dot { animation: none; } }

/* Structured ticket descriptions (voice intake) keep their line breaks */
.msg.body { white-space: pre-wrap; }

/* Standard list search box (all list screens) */
.toolbar .search { min-width: 260px; flex: 0 1 340px; }

/* Report bars + big numbers */
.bar { background: rgba(11,17,32,.08); border-radius: 6px; height: 10px; overflow: hidden; margin: .4rem 0; }
.bar-fill { height: 100%; background: var(--teal, #0D9488); border-radius: 6px; }
.bar-fill.ok { background: var(--ok); } .bar-fill.warn { background: var(--gold); } .bar-fill.bad { background: var(--coral); }
.big { font-size: 1.9rem; font-weight: 700; margin: .2rem 0; }
.text-bad { color: var(--coral); }

/* Board-ready print (Reportes → Imprimir/PDF) */
@media print {
  .sidebar, .topbar .actions, .hamburger, button, #palette { display: none !important; }
  .app, .content { display: block !important; margin: 0 !important; padding: 0 !important; }
  .topbar { border: none; }
  .card, .table-wrap { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }
}

/* Clickable dashboard KPI tiles */
.kpi-link { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.kpi-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--coral); }
.kpi-link:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .kpi-link { transition: none; } .kpi-link:hover { transform: none; } }

/* Setup Wizard hierarchy chain */
.wizard-chain{display:flex;align-items:stretch;gap:.5rem;flex-wrap:wrap}
.wizard-chain .wz{flex:1 1 120px;background:var(--panel-2,rgba(255,255,255,.03));border:1px solid var(--line);border-radius:10px;padding:.6rem .7rem;display:flex;flex-direction:column;gap:.15rem}
.wizard-chain .wz-k{font-weight:800;font-size:.95rem}
.wizard-chain .wz small{color:var(--muted,#94a3b8);font-size:.72rem;text-transform:uppercase;letter-spacing:.05em}
.wizard-chain .wz-arrow{display:flex;align-items:center;color:var(--muted,#94a3b8);font-weight:700}
@media(max-width:720px){.wizard-chain .wz-arrow{display:none}}

/* Required-field marker */
.req{color:var(--coral,#F38281);font-weight:800;margin-left:.15rem}

/* Trend sparkline */
.spark{margin:.2rem 0 .8rem}
.spark svg{display:block;background:var(--panel-2,rgba(255,255,255,.02));border-radius:8px}
.spark-legend{margin-top:.35rem;font-size:.8rem;color:var(--muted,#94a3b8)}
.spark-legend .k{font-size:.9rem}

/* Tickets summary tiles */
.tk-summary{margin-bottom:.9rem;display:flex;flex-direction:column;gap:.6rem}
.tk-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(96px,1fr));gap:.5rem}
.tk-tile{background:var(--panel-2,rgba(255,255,255,.03));border:1px solid var(--line);border-radius:10px;padding:.55rem .6rem;cursor:pointer;transition:border-color .12s,background .12s}
.tk-tile:hover{border-color:var(--coral,#F38281)}
.tk-tile.active{border-color:var(--coral,#F38281);background:rgba(243,130,129,.12)}
.tk-tile .v{font-size:1.35rem;font-weight:800;line-height:1;font-variant-numeric:tabular-nums}
.tk-tile .l{font-size:.72rem;color:var(--muted,#94a3b8);text-transform:uppercase;letter-spacing:.04em;margin-top:.25rem}
.tk-tile.bad .v{color:#F38281}
.tk-tile.warn .v{color:#F7B285}
.tk-top{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.tk-top-h{font-size:.72rem;color:var(--muted,#94a3b8);text-transform:uppercase;letter-spacing:.04em;margin-right:.2rem}
.tk-ent{display:inline-flex;align-items:center;gap:.4rem;background:var(--panel-2,rgba(255,255,255,.03));border:1px solid var(--line);border-radius:999px;padding:.28rem .6rem;cursor:pointer;font-size:.82rem;color:inherit}
.tk-ent:hover{border-color:var(--coral,#F38281)}
.tk-ent strong{font-variant-numeric:tabular-nums}

/* ── <dialog> polyfill styling (applies ONLY when native <dialog> is absent, i.e.
   html.no-dialog is set by dialog-polyfill.js on iOS < 15.4 / old browsers). Native
   browsers are untouched — they keep their built-in centering + ::backdrop. ── */
.no-dialog dialog { display: none; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%); max-height: 85vh; overflow: auto; margin: 0; z-index: 999; }
.no-dialog dialog[open] { display: block; }
.dialog-poly-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(11, 17, 32, .55); z-index: 998; }
/* Safety net for any engine that lacks the UA default: never show a closed dialog inline. */
dialog:not([open]) { display: none; }

/* Flexbox-gap fallback for very old Safari (< 14.1 / iOS < 14.5): approximate the
   gap with margins so controls don't collide when flex `gap` is unsupported. */
@supports not (gap: 1px) {
  .rowflex > *, .toolbar > *, .modal-actions > * { margin: .25rem; }
  .lang-toggle a { margin: 0 .2rem; }
}

/* ════════════════════════════════════════════════════════════════════════
   Command Center (cockpit) · self-contained dark NOC panel on the light
   console. Redefines --muted/--ink locally so the shared SVG chart helpers
   render correctly against the dark ground.
   ════════════════════════════════════════════════════════════════════════ */
.cc {
  --ink: #eaf1ff; --muted: rgba(159,176,217,.75);
  color: #eaf1ff; border-radius: 16px; padding: 20px;
  background:
    radial-gradient(1100px 420px at 15% -10%, rgba(13,148,136,.20), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(243,130,129,.13), transparent 55%),
    linear-gradient(160deg, #0b1120 0%, #0e1730 55%, #0a0f1e 100%);
  border: 1px solid rgba(120,145,200,.18);
  box-shadow: 0 24px 60px rgba(3,7,18,.5), inset 0 1px 0 rgba(255,255,255,.04);
  font-variant-numeric: tabular-nums;
}
.cc-load { padding: 60px; text-align: center; color: rgba(159,176,217,.75); letter-spacing: .04em; }

.cc-topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid rgba(120,145,200,.15); }
.cc-title { font-size: 1.35rem; font-weight: 800; letter-spacing: .18em; color: #eaf1ff;
  font-family: "Quicksand","Inter",system-ui,sans-serif; }
.cc-sub { color: rgba(159,176,217,.8); font-size: .82rem; margin-top: 2px; letter-spacing: .02em; }
.cc-clock { text-align: right; }
.cc-clock-t { font-size: 1.55rem; font-weight: 800; color: #5EEAD4; letter-spacing: .08em;
  text-shadow: 0 0 18px rgba(94,234,212,.35); font-variant-numeric: tabular-nums; }
.cc-clock-l { font-size: .62rem; text-transform: uppercase; letter-spacing: .18em; color: rgba(159,176,217,.6); }

/* Tactical alert row */
.cc-tactical { display: grid; grid-template-columns: 1.35fr 2fr; gap: 14px; margin-bottom: 16px; }
.cc-crit { position: relative; border-radius: 13px; padding: 16px 18px; overflow: hidden;
  background: linear-gradient(135deg, rgba(255,60,60,.16), rgba(255,60,60,.04));
  border: 1px solid rgba(255,93,93,.45); }
.cc-crit::before { content: ""; position: absolute; inset: 0; border-radius: 13px;
  box-shadow: 0 0 0 0 rgba(255,93,93,.5); animation: ccPulse 2.4s infinite; pointer-events: none; }
.cc-crit-ok { background: linear-gradient(135deg, rgba(61,220,132,.14), rgba(61,220,132,.03)); border-color: rgba(61,220,132,.4); }
.cc-crit-ok::before { animation: none; }
@keyframes ccPulse { 0% { box-shadow: 0 0 0 0 rgba(255,93,93,.45); } 70% { box-shadow: 0 0 0 14px rgba(255,93,93,0); } 100% { box-shadow: 0 0 0 0 rgba(255,93,93,0); } }
@media (prefers-reduced-motion: reduce) { .cc-crit::before { animation: none; } }
.cc-crit-tag { font-size: .7rem; font-weight: 800; letter-spacing: .16em; color: #ff9a9a; }
.cc-crit-ok .cc-crit-tag { color: #7ef0ae; }
.cc-crit-code { margin: 8px 0 6px; font-weight: 700; font-size: .95rem; }
.cc-crit-title { color: rgba(234,241,255,.9); font-size: .9rem; line-height: 1.35; }
.cc-chip { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: .68rem; font-weight: 700;
  background: rgba(120,145,200,.18); border: 1px solid rgba(120,145,200,.3); letter-spacing: .04em; vertical-align: middle; }
.cc-chip-urgent { background: rgba(255,93,93,.22); border-color: rgba(255,93,93,.5); color: #ffbcbc; }
.cc-chip-high { background: rgba(247,178,59,.2); border-color: rgba(247,178,59,.5); color: #ffd98a; }

.cc-tac-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.cc-big { border-radius: 13px; padding: 14px 12px; text-align: center;
  background: rgba(16,25,48,.7); border: 1px solid rgba(120,145,200,.16); }
.cc-big-n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cc-big-l { font-size: .62rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(159,176,217,.7); margin-top: 4px; }

/* Pillar columns */
.cc-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.cc-pillar { cursor: pointer; border-radius: 14px; padding: 15px 16px;
  background: linear-gradient(160deg, rgba(20,31,58,.9), rgba(12,19,38,.9));
  border: 1px solid rgba(120,145,200,.18); border-top: 3px solid var(--sc);
  transition: transform .12s, box-shadow .12s; }
.cc-pillar:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(3,7,18,.55); }
.cc-p-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cc-p-id { display: flex; align-items: center; gap: 11px; }
.cc-p-ic { font-size: 1.4rem; color: var(--sc); filter: drop-shadow(0 0 8px var(--sc)); }
.cc-p-key { font-size: 1.15rem; font-weight: 800; letter-spacing: .06em; }
.cc-p-tag { font-size: .68rem; color: rgba(159,176,217,.7); letter-spacing: .02em; }
.cc-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.cc-p-sla { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.cc-p-kv { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.cc-p-kv > div { display: flex; flex-direction: column; }
.cc-p-kv b { font-size: 1.05rem; font-weight: 800; line-height: 1; }
.cc-p-kv span { font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(159,176,217,.65); }
.cc-p-pr { margin-bottom: 10px; }
.cc-pr-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.cc-pr-row > span { width: 52px; font-size: .68rem; color: rgba(159,176,217,.8); text-align: right; }
.cc-pr-row > i { height: 8px; border-radius: 5px; min-width: 4px; }
.cc-pr-row > b { width: 26px; font-size: .78rem; text-align: right; }
.cc-p-foot { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid rgba(120,145,200,.14); }
.cc-spark { flex: 1; min-width: 0; }
.cc-fc { text-align: right; min-width: 78px; }
.cc-fc-n { font-size: 1.4rem; font-weight: 800; color: #FCE28A; line-height: 1; }
.cc-fc-l { font-size: .56rem; text-transform: uppercase; letter-spacing: .09em; color: rgba(159,176,217,.65); }
.cc-fc-m { font-size: .74rem; font-weight: 700; margin-top: 2px; }

/* Lower: AI intel + transversal */
.cc-lower { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.cc-intel, .cc-xv { border-radius: 14px; padding: 15px 16px;
  background: linear-gradient(160deg, rgba(18,28,54,.9), rgba(11,17,32,.9)); border: 1px solid rgba(120,145,200,.18); }
.cc-panel-h { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: .95rem;
  margin-bottom: 12px; letter-spacing: .02em; }
.cc-ai-badge { font-size: .62rem; font-weight: 800; letter-spacing: .1em; padding: 2px 9px; border-radius: 6px;
  background: linear-gradient(135deg, #0D9488, #5EEAD4); color: #06121a; }
.cc-ins { display: flex; gap: 11px; align-items: flex-start; padding: 10px 12px; margin: 8px 0; border-radius: 10px;
  background: rgba(12,19,38,.6); border: 1px solid rgba(120,145,200,.12); border-left: 3px solid var(--ic);
  font-size: .86rem; line-height: 1.4; color: rgba(234,241,255,.92); }
.cc-ins-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ic); margin-top: 6px; flex: none;
  box-shadow: 0 0 8px var(--ic); }
.cc-intel-foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid rgba(120,145,200,.14); }
.cc-intel-foot > div { display: flex; flex-direction: column; gap: 3px; }
.cc-intel-foot span { font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(159,176,217,.65); }
.cc-intel-foot b { font-size: 1.25rem; font-weight: 800; }
.cc-xv-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; cursor: pointer;
  border-bottom: 1px solid rgba(120,145,200,.1); font-size: .82rem; }
.cc-xv-row:hover { background: rgba(120,145,200,.06); }
.cc-xv-ic { color: rgba(159,176,217,.85); }
.cc-xv-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-xv-sla { font-weight: 800; color: #eaf1ff; }
.cc-xv-open { font-size: .72rem; color: rgba(159,176,217,.7); width: 76px; text-align: right; }
.cc-xv-fc { font-size: .74rem; color: #FCE28A; width: 42px; text-align: right; font-weight: 700; }
.cc-xv-note { margin-top: 12px; font-size: .74rem; line-height: 1.45; color: rgba(159,176,217,.7); font-style: italic; }

@media (max-width: 900px) {
  .cc-tactical, .cc-pillars, .cc-lower { grid-template-columns: 1fr; }
  .cc-tac-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Executive impact band (cockpit) — crisis exposure */
.cc-impact { border-radius:14px; padding:16px 18px; margin-bottom:16px;
  background:linear-gradient(160deg, rgba(255,93,93,.12), rgba(252,226,138,.06));
  border:1px solid rgba(255,138,93,.32); }
.cc-imp-sub { margin-left:auto; font-size:.72rem; color:rgba(159,176,217,.8); letter-spacing:.04em; font-weight:600; }
.cc-panel-h { display:flex; align-items:center; }
.cc-imp-bigs { display:grid; grid-template-columns:repeat(5,1fr); gap:12px; margin:6px 0 12px; }
.cc-imp-big { text-align:center; padding:10px 8px; border-radius:11px;
  background:rgba(12,19,38,.55); border:1px solid rgba(120,145,200,.16); }
.cc-imp-n { font-size:1.7rem; font-weight:800; line-height:1.05; font-variant-numeric:tabular-nums; }
.cc-imp-l { font-size:.62rem; text-transform:uppercase; letter-spacing:.08em; color:rgba(159,176,217,.75); margin-top:5px; }
.cc-imp-bd { display:flex; flex-direction:column; gap:2px; margin-bottom:8px; }
.cc-imp-row { display:flex; align-items:center; gap:10px; font-size:.82rem; padding:4px 0; }
.cc-imp-row > span { color:rgba(234,241,255,.9); min-width:210px; }
.cc-imp-row > i { flex:1; height:1px; background:rgba(120,145,200,.18); }
.cc-imp-row > b { font-weight:800; width:34px; text-align:right; }
.cc-imp-row > u { text-decoration:none; color:#ff8a5d; font-weight:700; width:64px; text-align:right; font-size:.8rem; }
.cc-imp-note { font-size:.76rem; line-height:1.45; color:rgba(159,176,217,.72); font-style:italic; }
.if-row { margin-bottom:.6rem; }
.if-row label { display:block; margin-bottom:.2rem; font-size:.85rem; color:var(--muted); font-weight:600; }
@media (max-width:900px){ .cc-imp-bigs { grid-template-columns:repeat(2,1fr); } .cc-imp-row > span { min-width:130px; } }

/* ── Phone viewer (iOS / Android) · ≤600px ─────────────────────────────── */
@media (max-width: 600px) {
  html, body { font-size: 15px; }
  .content { padding: .75rem !important; }
  /* Command center fits the phone: tighter padding, stacked header. */
  .cc { padding: 13px 11px; border-radius: 12px; }
  .cc-topbar { flex-direction: column; align-items: flex-start; gap: 4px; }
  .cc-clock { text-align: left; }
  .cc-title { font-size: 1.05rem; letter-spacing: .1em; }
  .cc-sub { font-size: .72rem; }
  .cc-clock-t { font-size: 1.3rem; }
  .cc-tactical, .cc-lower, .cc-pillars { gap: 10px; }
  .cc-tac-grid { gap: 8px; }
  .cc-big { padding: 10px 8px; }
  .cc-big-n { font-size: 1.35rem; }
  .cc-crit { padding: 13px 14px; }
  /* Impact panel */
  .cc-imp-bigs { gap: 8px; }
  .cc-imp-big { padding: 8px 6px; }
  .cc-imp-n { font-size: 1.3rem; }
  .cc-imp-row { font-size: .78rem; gap: 8px; }
  .cc-imp-row > span { min-width: 0; flex: 1; }
  .cc-imp-row > i { display: none; }
  .cc-imp-row > u { width: 54px; }
  /* Pillars */
  .cc-p-key { font-size: 1.05rem; }
  .cc-p-kv b { font-size: .95rem; }
  .cc-panel-h { flex-wrap: wrap; row-gap: 4px; }
  .cc-ins { font-size: .82rem; }
  /* KPI tiles two-up, integrations cards single column */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: .5rem; }
  .kpi .value { font-size: 1.5rem; }
  /* Setup form: full-width controls, buttons wrap */
  .if-row input, .if-row select { width: 100%; }
  /* Tables never break the layout — scroll inside their own box. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  /* Modals fill the small screen */
  dialog, .modal { max-width: 96vw; }
}
@media (max-width: 380px) {
  .cc-imp-bigs { grid-template-columns: 1fr 1fr; }
  .cc-tac-grid { grid-template-columns: 1fr 1fr; }
}
