/* ═══════════════════════════════════════════════════════════
   Helios Command Center  ·  app.css v3.0
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:       #07111d;
  --surface:  #0e1d35;
  --surface2: #132240;
  --border:   #1e3055;
  --accent:   #5b8def;
  --accent2:  #7aa4f7;
  --text:     #e4ecfa;
  --muted:    #8aa3c4;
  --success:  #34d399;
  --warn:     #fbbf24;
  --danger:   #f87171;
  --radius:   10px;
  --sidebar-w: 220px;
  --topbar-h:  52px;
  --font: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }
.hl-muted  { color: var(--muted); }
.hl-mono   { font-family: "SF Mono","Fira Code",monospace; font-size: 12px; }
.hl-hint   { font-size: 11px; color: var(--muted); }
.hl-key    { font-family: monospace; font-size: 12px; word-break: break-all; color: var(--accent2); }
.hl-empty  { text-align: center; padding: 40px; color: var(--muted); }

/* ── Session warning banner ── */
#hl-session-warn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: #7c3a0a; color: #fde68a; padding: 9px 18px;
  display: flex; align-items: center; gap: 14px; font-size: 13px;
}
#hl-session-warn button {
  margin-left: auto; background: #fde68a; color: #7c3a0a;
  border: none; border-radius: 5px; padding: 3px 12px; cursor: pointer; font-weight: 600;
}

/* ── Buttons ── */
.hl-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: 7px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: opacity .15s,filter .15s;
  background: var(--surface2); color: var(--text);
}
.hl-btn:hover:not(:disabled) { filter: brightness(1.15); }
.hl-btn:disabled { opacity: .45; cursor: not-allowed; }
.hl-btn-primary { background: var(--accent); color: #fff; }
.hl-btn-warning { background: var(--warn); color: #000; }
.hl-btn-danger  { background: var(--danger); color: #000; }
.hl-btn-sm      { padding: 5px 11px; font-size: 12px; }
.hl-btn-link    { background: none; color: var(--accent); padding: 0; font-size: 12px; font-weight: 500; }
.hl-btn-link:hover { text-decoration: underline; }
.hl-btn-back    { background: none; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; border: none; padding: 0 0 12px; display: inline-flex; align-items: center; gap: 4px; }
.hl-btn-back:hover { color: var(--text); }
.hl-btn-icon    { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 18px; padding: 4px 8px; }
.hl-btn-icon:hover { color: var(--text); }
.hl-signout-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; }
.hl-signout-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hl-signout-btn:hover { color: var(--danger); }

/* ── Inputs ── */
input[type="text"], input[type="url"], input[type="password"],
input[type="search"], select.hl-select, textarea.hl-textarea, .hl-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: 9px 12px; font-size: 13px;
  font-family: var(--font); outline: none; transition: border-color .15s;
}
input:focus, select.hl-select:focus, textarea.hl-textarea:focus {
  border-color: var(--accent);
}
select.hl-select { cursor: pointer; }
textarea.hl-textarea { resize: vertical; }

/* ── Feedback / Toast ── */
.hl-feedback { font-size: 12px; margin-top: 8px; }
.hl-feedback.ok  { color: var(--success); }
.hl-feedback.err { color: var(--danger); }
.hl-toast {
  position: sticky; top: 0; z-index: 50;
  padding: 10px 18px; border-radius: 7px; margin-bottom: 14px;
  font-size: 13px; font-weight: 600;
}
.hl-toast.ok  { background: #064e30; color: var(--success); }
.hl-toast.err { background: #4b1414; color: var(--danger); }

/* ── Persistent action status panel ── */
.hl-action-status {
  position: sticky; top: 0; z-index: 45;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.hl-action-status-head { display: flex; align-items: center; gap: 8px; }
.hl-action-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.hl-action-dot.running { background: var(--accent2); box-shadow: 0 0 0 4px rgba(91,141,239,.18); }
.hl-action-dot.ok { background: var(--success); box-shadow: 0 0 0 4px rgba(52,211,153,.16); }
.hl-action-dot.err { background: var(--danger); box-shadow: 0 0 0 4px rgba(248,113,113,.16); }
.hl-action-dot.idle { background: var(--muted); }
.hl-action-time { margin-left: auto; font-size: 11px; color: var(--muted); }
.hl-action-track {
  margin-top: 8px; height: 5px; border-radius: 999px;
  background: var(--surface2); overflow: hidden;
}
.hl-action-progress {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #5b8def, #7aa4f7);
  transition: width .25s ease;
}
.hl-action-detail { margin-top: 7px; font-size: 12px; color: var(--muted); }
.hl-action-list {
  margin-top: 8px; display: flex; flex-direction: column; gap: 4px;
  max-height: 110px; overflow: auto;
}
.hl-action-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px;
  align-items: center; font-size: 11px; color: var(--muted);
  background: var(--surface2); border-radius: 7px; padding: 4px 8px;
}
.hl-action-item strong { color: var(--text); font-weight: 600; }
.hl-action-state { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .2px; }
.hl-action-state.running { color: var(--accent2); }
.hl-action-state.ok { color: var(--success); }
.hl-action-state.err { color: var(--danger); }

/* ══════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════ */
.hl-login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.hl-login-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 36px 32px;
}
.hl-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.hl-brand-mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #3a6fd8);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff;
}
.hl-brand-name  { font-size: 18px; font-weight: 700; }
.hl-brand-tag   { font-size: 12px; color: var(--muted); }
.hl-login-card h1 { margin-bottom: 6px; }
.hl-login-card .hl-muted { margin-bottom: 24px; font-size: 13px; }
.hl-login-card label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
.hl-login-card label input { margin-top: 5px; }
.hl-login-card .hl-btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 4px; }

/* Progress bar */
#hl-login-progress { margin-top: 18px; }
.hl-progress-track { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.hl-progress-fill  { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; width: 0%; }
.hl-progress-steps { display: flex; justify-content: space-between; margin-top: 10px; }
.hl-step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.hl-step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: background .3s; }
.hl-step.active .hl-step-dot { background: var(--accent); }
.hl-step.done   .hl-step-dot { background: var(--success); }
.hl-step.error  .hl-step-dot { background: var(--danger); }
.hl-step span   { font-size: 10px; color: var(--muted); }
.hl-progress-msg { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }

/* ══════════════════════════════════════════════
   APP SHELL — sidebar + main
   ══════════════════════════════════════════════ */
.hl-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ── */
.hl-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.hl-sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.hl-brand-mark-sm { width: 28px; height: 28px; border-radius: 6px; font-size: 14px; }
.hl-sidebar-title  { font-size: 15px; font-weight: 700; }

/* Nav */
.hl-nav { list-style: none; padding: 10px 8px; flex: 1; overflow-y: auto; }
.hl-nav li { margin-bottom: 2px; }
.hl-nav-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; border-radius: 8px; cursor: pointer;
  background: none; color: var(--muted); font-size: 13px; font-weight: 500;
  text-align: left; transition: background .15s, color .15s;
  position: relative;
}
.hl-nav-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; flex-shrink: 0; }
.hl-nav-btn:hover { background: var(--surface2); color: var(--text); }
.hl-nav-btn.active { background: rgba(91,141,239,.15); color: var(--accent2); font-weight: 600; }
.hl-nav-btn.active svg { stroke: var(--accent2); }

.hl-nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; min-width: 18px; text-align: center;
}
.hl-badge-warn { background: var(--warn); color: #000; }

/* Sidebar footer */
.hl-sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 12px;
  display: flex; align-items: center; gap: 8px;
}
.hl-sidebar-admin { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.hl-admin-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3a6fd8);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.hl-admin-meta { min-width: 0; }
.hl-admin-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-admin-role { font-size: 11px; color: var(--muted); }

/* ── Mobile topbar ── */
.hl-topbar-mobile {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center; padding: 0 14px; gap: 12px;
}
.hl-menu-btn { background: none; border: none; cursor: pointer; color: var(--text); font-size: 20px; }
.hl-topbar-title { flex: 1; font-size: 15px; font-weight: 600; }
.hl-sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55);
}

/* ── Main content ── */
.hl-main {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg);
}

/* ══════════════════════════════════════════════
   PAGE LAYOUT
   ══════════════════════════════════════════════ */
.hl-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.hl-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hl-header-actions input[type="search"] { width: 220px; }

/* ── KPI row ── */
.hl-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.hl-kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.hl-kpi-val   { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.hl-kpi-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.hl-kpi-success { border-left: 3px solid var(--success); }
.hl-kpi-success .hl-kpi-val { color: var(--success); }
.hl-kpi-warn    { border-left: 3px solid var(--warn); }
.hl-kpi-warn    .hl-kpi-val { color: var(--warn); }
.hl-kpi-danger  { border-left: 3px solid var(--danger); }
.hl-kpi-danger  .hl-kpi-val { color: var(--danger); }
.hl-kpi-accent  { border-left: 3px solid var(--accent); }
.hl-kpi-accent  .hl-kpi-val { color: var(--accent2); }

/* ── Cards ── */
.hl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.hl-card h3 { margin-bottom: 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.hl-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hl-card-header h3 { margin-bottom: 0; }

/* ── Grid layouts ── */
.hl-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.hl-grid-2col { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.hl-dash-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }

/* ── Definition list ── */
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
dd { font-size: 13px; word-break: break-word; }

/* ── Customer list rows ── */
.hl-list { display: flex; flex-direction: column; gap: 6px; }
.hl-list-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.hl-list-row:hover { background: var(--surface2); border-color: var(--accent); }
.hl-list-row .hl-row-main { flex: 1; min-width: 0; }
.hl-list-row .hl-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-list-row .hl-row-sub  { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-list-row .hl-row-meta { font-size: 11px; color: var(--muted); text-align: right; flex-shrink: 0; }
.hl-list-row .hl-row-badge { margin-left: auto; }

/* ── Pills / badges ── */
.hl-pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.hl-pill-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill-green  { background: rgba(52,211,153,.15); color: var(--success); }
.pill-yellow { background: rgba(251,191,36,.15);  color: var(--warn); }
.pill-red    { background: rgba(248,113,113,.15);  color: var(--danger); }
.pill-blue   { background: rgba(91,141,239,.15);   color: var(--accent2); }
.pill-gray   { background: var(--surface2); color: var(--muted); }

/* ── Detail header ── */
.hl-detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }

/* ── Action strip ── */
.hl-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ── Tabs ── */
.hl-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.hl-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 16px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--muted); transition: color .15s, border-color .15s;
}
.hl-tab:hover { color: var(--text); }
.hl-tab.active { color: var(--accent2); border-bottom-color: var(--accent); }


/* ── Ticket list ── */
.hl-ticket-list, .hl-mini-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.hl-ticket-item {
  background: var(--surface2); border-radius: 8px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
.hl-ticket-item .hl-ti-subject { flex: 1; font-size: 13px; font-weight: 500; }
.hl-ticket-item .hl-ti-meta    { font-size: 11px; color: var(--muted); }
.hl-ticket-item .hl-ti-actions { display: flex; gap: 6px; flex-shrink: 0; }
.hl-mini-item  { background: var(--surface2); border-radius: 8px; padding: 8px 12px; font-size: 12px; }
.hl-mini-item .hl-mi-title { font-weight: 600; margin-bottom: 2px; }
.hl-mini-item .hl-mi-sub   { color: var(--muted); }

/* ── Health score ── */
.hl-health { font-size: 28px; font-weight: 800; color: var(--success); }
.hl-health.warn   { color: var(--warn); }
.hl-health.danger { color: var(--danger); }

/* ── Ticket thread in modal ── */
.hl-ticket-thread {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 7px;
  padding: 10px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.hl-thread-msg { padding: 8px 12px; border-radius: 7px; font-size: 13px; }
.hl-thread-msg.admin    { background: rgba(91,141,239,.15); margin-left: 20%; }
.hl-thread-msg.customer { background: var(--surface2); margin-right: 20%; }
.hl-thread-msg .hl-tm-meta { font-size: 10px; color: var(--muted); margin-bottom: 3px; }

/* ══════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════ */
.hl-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.hl-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); cursor: pointer; }
.hl-modal-card {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.hl-modal-wide { max-width: 600px; }
.hl-modal-card h3 { margin-bottom: 8px; }
.hl-modal-card .hl-muted { margin-bottom: 14px; }
.hl-modal-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px;
}
.hl-modal-actions .hl-select { flex: 1; min-width: 160px; }

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hl-topbar-mobile { display: flex; }
  .hl-main { padding: 14px 16px; padding-top: calc(var(--topbar-h) + 14px); }
  .hl-action-status { top: calc(var(--topbar-h) + 6px); }
  .hl-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 95;
    transform: translateX(-100%);
  }
  .hl-sidebar.open { transform: translateX(0); }
  .hl-sidebar-overlay { display: block; }
  .hl-dash-grid { grid-template-columns: 1fr; }
  .hl-grid-2col { grid-template-columns: 1fr; }
  .hl-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .hl-login-card { padding: 26px 18px; }
  .hl-kpi-row { grid-template-columns: 1fr 1fr; }
  .hl-header-actions input[type="search"] { width: 140px; }
}

/* ══════════════════════════════════════════════
   v3.0 — Analytics, Fleet, Alerts, Audit Log
   ══════════════════════════════════════════════ */
.hl-bar-chart { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.hl-bar-row { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; gap: 10px; }
.hl-bar-label { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-bar-val { font-size: 11px; color: var(--text); font-weight: 600; }
.hl-bar-track { height: 14px; background: var(--surface2); border-radius: 7px; overflow: hidden; }
.hl-bar-fill { height: 100%; background: linear-gradient(90deg, #5b8def, #7aa4f7); border-radius: 7px; transition: width .5s cubic-bezier(.4,0,.2,1); }
.hl-pill-list { display: flex; flex-direction: column; gap: 8px; }
.hl-breakdown-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.hl-breakdown-row strong { margin-left: auto; font-size: 15px; font-weight: 700; }
.hl-breakdown-row .hl-muted { font-size: 12px; }
.hl-badge-danger { background: #f87171; color: #fff; }
#hl-auditlog-list .hl-list-row,
#fl-heartbeats .hl-list-row,
#fl-health-scores .hl-list-row { cursor: default; }
#hl-auditlog-list .hl-list-row:hover,
#fl-heartbeats .hl-list-row:hover,
#fl-health-scores .hl-list-row:hover { background: var(--surface); border-color: var(--border); }