/* ═══════════════════════════════════════════════════════════════════════
   QuByte Portal — App Design System
   Dark-metal + neon cyan, built to match qubytesystems.com
   Two surfaces: desk (internal PSA) · portal (client)
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* surfaces */
  --bg: #0b0f14;              /* app background */
  --panel: #121822;          /* cards / rails */
  --panel-2: #0e131b;        /* deeper wells (tables, inputs) */
  --panel-hi: #18202c;       /* hover / raised */
  --line: #1e2a38;           /* hairlines */
  --line-soft: #172230;
  /* text */
  --ink: #e6edf3;            /* headings */
  --text: #c3ced9;           /* body */
  --muted: #7d8ea1;          /* secondary */
  --faint: #5a6b7d;          /* tertiary */
  /* brand */
  --cyan: #22d3ee;
  --cyan-hi: #67e8f9;
  --cyan-dim: #0891b2;
  --violet: #8b5cf6;
  --steel-a: #f4f7fa;
  --steel-b: #c3ced9;
  --steel-c: #8fa3b8;
  /* status */
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
  --glow: rgba(34,211,238,0.40);
  /* metrics */
  --rail-w: 232px;
  --topbar-h: 60px;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(34,211,238,0.28); color: #fff; }
h1,h2,h3,h4 { color: var(--ink); font-weight: 650; letter-spacing: -0.02em; margin: 0; }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; }

/* thin custom scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26333f; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #33434f; }

/* ── APP SHELL ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, #10161f, #0b1017);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  z-index: 40;
}
.rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
}
.rail-brand img { width: 34px; height: 34px; border-radius: 9px; }
.rail-brand .wm { display: flex; flex-direction: column; line-height: 1; }
.rail-brand .wm b { color: var(--ink); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.rail-brand .wm span {
  font-size: 8.5px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--cyan); margin-top: 3px; font-weight: 600;
}
.rail-section { font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 13px;
  position: relative; transition: background .14s, color .14s;
  margin-bottom: 1px; cursor: pointer;
}
.nav-item .iconify { font-size: 17px; opacity: .85; }
.nav-item:hover { background: var(--panel-hi); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(34,211,238,0.16), rgba(34,211,238,0.05)); color: var(--cyan-hi); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--cyan); border-radius: 0 3px 3px 0; box-shadow: 0 0 10px var(--glow);
}
.nav-item .badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; min-width: 19px; text-align: center;
  padding: 1px 6px; border-radius: 9px; background: var(--panel-hi); color: var(--muted);
}
.nav-item .badge.hot { background: rgba(239,68,68,0.15); color: #fca5a5; }
.nav-item .badge.cy { background: rgba(34,211,238,0.15); color: var(--cyan-hi); }
.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.rail-user:hover { background: var(--panel-hi); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #04262e;
  background: linear-gradient(135deg, var(--cyan-hi), var(--cyan-dim));
}
.avatar.v { background: linear-gradient(135deg, #c4b5fd, #7c3aed); color: #1e1035; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 42px; height: 42px; font-size: 15px; }
.rail-user .who { line-height: 1.2; }
.rail-user .who b { color: var(--ink); font-size: 12.5px; font-weight: 600; display: block; }
.rail-user .who span { color: var(--faint); font-size: 11px; }

/* ── MAIN + TOPBAR ──────────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: rgba(11,15,20,0.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; }
.topbar .crumb { color: var(--faint); font-size: 12.5px; }
.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: var(--radius-sm); width: 260px; color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: rgba(34,211,238,0.5); box-shadow: 0 0 0 3px rgba(34,211,238,0.08); }
.search input { background: none; border: none; outline: none; color: var(--text); width: 100%; font-size: 13px; }
.search .kbd { font-size: 10px; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); display: grid; place-items: center; cursor: pointer;
  position: relative; transition: .15s;
}
.icon-btn:hover { color: var(--cyan-hi); border-color: rgba(34,211,238,0.4); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--panel-2); }
.page { padding: 24px; flex: 1; }
.page-wide { max-width: 1500px; }

/* ── BUTTONS ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 8px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel-hi); color: var(--text);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: rgba(34,211,238,0.4); color: var(--cyan-hi); }
.btn .iconify { font-size: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--cyan-hi), var(--cyan-dim));
  color: #04262e; border: none; box-shadow: 0 2px 14px rgba(34,211,238,0.25);
}
.btn-primary:hover { color: #04262e; box-shadow: 0 4px 20px rgba(34,211,238,0.4); transform: translateY(-1px); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); color: #fff; border: none; }
.btn-violet:hover { color: #fff; box-shadow: 0 4px 18px rgba(139,92,246,0.4); }

/* ── CARDS / PANELS ─────────────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  position: relative;
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 13.5px; }
.card-head .iconify { color: var(--cyan); font-size: 17px; }
.card-head .sub { color: var(--faint); font-size: 11.5px; font-weight: 500; }
.card-head .spacer { margin-left: auto; }
.grid { display: grid; gap: 16px; }
.glow-hover { transition: border-color .18s, box-shadow .18s, transform .18s; }
.glow-hover:hover { border-color: rgba(34,211,238,0.35); box-shadow: 0 8px 30px rgba(0,0,0,0.35), 0 0 0 1px rgba(34,211,238,0.08); }

/* ── STAT CARDS ─────────────────────────────────────────────────────── */
.stat { padding: 16px 18px; }
.stat .lbl { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 7px; }
.stat .lbl .iconify { font-size: 15px; opacity: .8; }
.stat .val { font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: -0.03em; margin-top: 8px; line-height: 1; }
.stat .val small { font-size: 15px; color: var(--muted); font-weight: 600; }
.stat .delta { font-size: 11.5px; margin-top: 7px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--bad); }
.stat .delta.flat { color: var(--muted); }
.stat.accent-cy .val { color: var(--cyan-hi); }
.stat.accent-red .val { color: #fca5a5; }
.stat.accent-amber .val { color: #fcd34d; }

/* ── CHIPS / BADGES ─────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650;
  padding: 3px 9px; border-radius: 20px; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent;
}
.chip .iconify { font-size: 12px; }
.chip .d { width: 6px; height: 6px; border-radius: 50%; }
.chip-cy   { background: rgba(34,211,238,0.12);  color: var(--cyan-hi); border-color: rgba(34,211,238,0.22); }
.chip-green{ background: rgba(34,197,94,0.12);  color: #86efac; border-color: rgba(34,197,94,0.22); }
.chip-amber{ background: rgba(245,158,11,0.13); color: #fcd34d; border-color: rgba(245,158,11,0.22); }
.chip-red  { background: rgba(239,68,68,0.13);  color: #fca5a5; border-color: rgba(239,68,68,0.24); }
.chip-violet{background: rgba(139,92,246,0.14); color: #c4b5fd; border-color: rgba(139,92,246,0.24); }
.chip-gray { background: var(--panel-hi); color: var(--muted); border-color: var(--line); }
.pri { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; }
.pri .bar { width: 3px; height: 13px; border-radius: 2px; }
.pri-critical { color: #fca5a5; } .pri-critical .bar { background: var(--bad); box-shadow: 0 0 7px rgba(239,68,68,.6); }
.pri-high { color: #fcd34d; } .pri-high .bar { background: var(--warn); }
.pri-medium { color: var(--cyan-hi); } .pri-medium .bar { background: var(--cyan); }
.pri-low { color: var(--muted); } .pri-low .bar { background: var(--faint); }

/* ── TABLES ─────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel);
}
.tbl tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--panel-hi); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .id { font-family: 'JetBrains Mono', monospace; color: var(--cyan); font-size: 12px; }
.tbl .subj { color: var(--ink); font-weight: 550; }
.tbl .cell-2 { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.t-right { text-align: right; }
.t-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; font-size: 12px; font-weight: 500;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer;
}
.filter:hover, .filter.on { color: var(--cyan-hi); border-color: rgba(34,211,238,0.4); }
.filter .iconify { font-size: 14px; }

/* ── SLA METER ──────────────────────────────────────────────────────── */
.sla { display: flex; align-items: center; gap: 8px; }
.sla .track { width: 54px; height: 5px; border-radius: 3px; background: var(--panel-hi); overflow: hidden; }
.sla .fill { height: 100%; border-radius: 3px; }
.sla .t { font-size: 11.5px; font-weight: 600; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.sla.breach .t { color: #fca5a5; }
.sla.warn .t { color: #fcd34d; }

/* ── HEALTH RINGS + TILES ───────────────────────────────────────────── */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.health-tile { padding: 15px; display: flex; gap: 14px; align-items: center; }
.ring { --p: 90; --c: var(--ok); width: 54px; height: 54px; flex-shrink: 0; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .bg { stroke: var(--panel-hi); }
.ring .fg { stroke: var(--c); stroke-linecap: round; filter: drop-shadow(0 0 4px var(--c)); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 700; color: var(--ink); }
.health-tile .meta { min-width: 0; }
.health-tile .meta b { color: var(--ink); font-size: 13.5px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health-tile .meta .row { display: flex; gap: 6px; margin-top: 7px; }
.dotstat { width: 8px; height: 8px; border-radius: 2px; }
.dotstat.ok { background: var(--ok); box-shadow: 0 0 5px rgba(34,197,94,.5); }
.dotstat.warn { background: var(--warn); }
.dotstat.bad { background: var(--bad); box-shadow: 0 0 6px rgba(239,68,68,.6); }
.dotstat.off { background: #33414d; }

/* ── TIMELINE (ticket conversation) ─────────────────────────────────── */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 12px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before {
  content: ''; position: absolute; left: -23px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--faint);
}
.tl-item.cy::before { border-color: var(--cyan); box-shadow: 0 0 8px var(--glow); }
.tl-item.violet::before { border-color: var(--violet); box-shadow: 0 0 8px rgba(139,92,246,.5); }
.tl-item.green::before { border-color: var(--ok); }
.tl-item.amber::before { border-color: var(--warn); }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.tl-head b { color: var(--ink); font-size: 13px; font-weight: 600; }
.tl-head .when { color: var(--faint); font-size: 11.5px; margin-left: auto; }
.bubble { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--text); }
.bubble.internal { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.2); }
.bubble.ai { background: rgba(139,92,246,0.07); border-color: rgba(139,92,246,0.22); }
.bubble.client { background: rgba(34,211,238,0.05); border-color: rgba(34,211,238,0.16); }

/* ── AI BRIEFING PANEL ──────────────────────────────────────────────── */
.ai-panel { background: linear-gradient(160deg, rgba(139,92,246,0.10), rgba(34,211,238,0.05)); border: 1px solid rgba(139,92,246,0.24); }
.ai-panel .card-head { border-color: rgba(139,92,246,0.18); }
.ai-panel .card-head .iconify { color: var(--violet); }
.ai-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line-soft); font-size: 12.5px; }
.ai-row:last-child { border: none; }
.ai-row .k { color: var(--muted); width: 96px; flex-shrink: 0; font-weight: 500; }
.ai-row .v { color: var(--text); }
.conf { display: inline-flex; align-items: center; gap: 6px; }
.conf .track { width: 44px; height: 4px; background: var(--panel-hi); border-radius: 2px; overflow: hidden; }
.conf .fill { height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan)); }

/* ── FORMS ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field label .req { color: var(--cyan); }
.input, .select, .textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 13px; color: var(--ink); font-size: 13.5px; font-family: inherit; outline: none; transition: .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(34,211,238,0.5); box-shadow: 0 0 0 3px rgba(34,211,238,0.08); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .opt {
  flex: 1; min-width: 90px; text-align: center; padding: 10px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; transition: .15s;
}
.seg .opt:hover { border-color: rgba(34,211,238,0.35); color: var(--text); }
.seg .opt.sel { background: linear-gradient(135deg, rgba(34,211,238,0.14), rgba(34,211,238,0.04)); border-color: rgba(34,211,238,0.5); color: var(--cyan-hi); }
.seg .opt.sel.red { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.5); color: #fca5a5; }
.seg .opt.sel.amber { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.5); color: #fcd34d; }

/* ── MISC ───────────────────────────────────────────────────────────── */
.hr { height: 1px; background: var(--line-soft); border: none; margin: 16px 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .ink { color: var(--ink); }
.tiny { font-size: 11.5px; } .sm { font-size: 12.5px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.between { justify-content: space-between; } .wrap { flex-wrap: wrap; } .col { flex-direction: column; }
.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:18px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}
.grow { flex: 1; } .right { margin-left: auto; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); display: inline-block; animation: pulse 1.8s ease-in-out infinite; }
.live-dot.cy { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.spark { display: block; width: 100%; height: 40px; }

/* incident strip */
.incident { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line-soft); margin-bottom: 8px; }
.incident.crit { border-color: rgba(239,68,68,0.28); background: rgba(239,68,68,0.05); }
.incident .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.incident .ico.red { background: rgba(239,68,68,0.14); color: #fca5a5; }
.incident .ico.amber { background: rgba(245,158,11,0.14); color: #fcd34d; }
.incident .ico.cy { background: rgba(34,211,238,0.12); color: var(--cyan-hi); }
.incident b { color: var(--ink); font-size: 13px; font-weight: 600; }
.incident .meta { color: var(--faint); font-size: 11.5px; margin-top: 2px; }

/* ── MOBILE ─────────────────────────────────────────────────────────── */
.rail-toggle { display: none; }
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1); }
  .rail.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .rail-toggle { display: grid; }
  .rail-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .rail-backdrop.open { opacity: 1; pointer-events: auto; }
  .search { width: 150px; }
  .page { padding: 16px; }
}
@media (max-width: 620px) { .search { display: none; } .hide-sm { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
