/* ═══ Components ═══════════════════════════════════════════════════════════ */

/* ── HUD panel: the signature element (chamfered top-right corner) ───────── */
.panel {
  position: relative;
  background: var(--grad-panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ink) 3%, transparent);
}
.panel::after {                      /* gold notch in the cut corner */
  content: ""; position: absolute; top: 0; right: 0; width: calc(var(--cut) * 1.42); height: 1px;
  background: var(--gold); transform-origin: top right; transform: rotate(-45deg) translateY(-0.5px);
  opacity: 0.55;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-neutral);
}
.panel-head h2, .label {
  font: 600 11px var(--font-display); letter-spacing: 2.5px; text-transform: uppercase; color: var(--gold);
}
.panel-head h2::before { content: "// "; color: var(--faint); }
.panel-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }
.panel.hoverable { transition: border-color var(--t), transform var(--t) var(--ease); cursor: pointer; }
.panel.hoverable:hover { border-color: var(--line-strong); transform: translateY(-2px); }

/* ── stat tile ───────────────────────────────────────────────────────────── */
.stat { padding: 16px 18px; }
.stat .label { display: block; margin-bottom: 8px; color: var(--muted); }
.stat .value { font: 700 var(--fs-2xl)/1 var(--font-display); color: var(--text); letter-spacing: 0.5px; }
.stat .value small { font: 500 var(--fs-sm) var(--font-body); color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat .sub { margin-top: 8px; font-size: var(--fs-xs); color: var(--muted); }
.stat.accent .value { background: var(--grad-gold); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  cursor: pointer; transition: all var(--t-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--gold); background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad-fire); border-color: transparent; box-shadow: var(--glow-fire); color: var(--on-fire); }
.btn.primary:hover { filter: brightness(1.1); box-shadow: 0 0 32px color-mix(in srgb, var(--orange) 50%, transparent); }
.btn.gold { background: transparent; border-color: var(--gold); color: var(--gold-light); }
.btn.gold:hover { background: var(--gold); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger-a15); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger-text); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok-a15); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok-text); }
.btn.ok:hover { background: var(--ok); color: #04130a; }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn.on { background: var(--gold); color: var(--on-accent); border-color: var(--gold); }

/* ── forms ───────────────────────────────────────────────────────────────── */
.input, input:not([type]), input[type=text], input[type=password], input[type=number], input[type=search],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--bg-2); border: 1px solid var(--line-neutral); border-radius: var(--r-md);
  color: var(--text); outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--font-mono); font-size: 13px; min-height: 60vh; white-space: pre; tab-size: 2; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-a10); }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); letter-spacing: 0.3px; }
.field .help { font-size: var(--fs-xs); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-sm); }
.check input { accent-color: var(--orange); width: 16px; height: 16px; }

/* ── chips / badges / status ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: var(--r-sm); font-size: 11px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-neutral);
}
.badge.ok { background: var(--ok-a15); color: var(--ok-text); border-color: transparent; }
.badge.warn { background: var(--warn-a15); color: var(--warn-text); border-color: transparent; }
.badge.danger { background: var(--danger-a15); color: var(--danger-text); border-color: transparent; }
.badge.info { background: var(--info-a15); color: var(--info-text); border-color: transparent; }
.badge.gold { background: var(--gold-a10); color: var(--gold-light); border-color: var(--gold-a20); }
.badge.blue { color: var(--blue-side); } .badge.red { color: var(--red-side); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: var(--r-full); cursor: pointer;
  border: 1px solid var(--line-neutral); background: var(--surface); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.on { background: var(--gold-a10); border-color: var(--gold); color: var(--gold-light); }

.dot { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); }
.dot.info { background: var(--info); }
.dot.live::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.8s var(--ease) infinite;
}
.status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surface);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
}

/* ── tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; padding: 10px 14px; position: sticky; top: 0;
  font: 600 10px var(--font-display); letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-neutral); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--row-hover); }
.table tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .primary-cell { color: var(--text); font-weight: 600; }
.table.compact td { padding: 7px 12px; }

/* ── tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--gap); overflow-x: auto; }
.tab {
  position: relative; padding: 10px 14px; background: none; border: 0; cursor: pointer; white-space: nowrap;
  font: 600 11px var(--font-display); letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); }
.tab.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--grad-fire); box-shadow: var(--glow-fire); }
.tab .count { margin-left: 6px; color: var(--gold); }

/* ── key/value list ──────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* ── avatar ──────────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  background: var(--surface-3); border: 1px solid var(--line);
  display: inline-grid; place-items: center; font: 700 12px var(--font-display); color: var(--gold);
}
.avatar.lg { width: 72px; height: 72px; font-size: 22px; border: 2px solid var(--gold); box-shadow: var(--glow-gold); }

/* ── feedback ────────────────────────────────────────────────────────────── */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.empty svg { width: 32px; height: 32px; margin: 0 auto 10px; opacity: 0.4; }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.loading-block { padding: 26px 18px; display: grid; gap: 12px; }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fs-sm); border: 1px solid; }
.callout svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.callout.warn { background: var(--warn-a15); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn-text); }
.callout.danger { background: var(--danger-a15); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger-text); }
.callout.info { background: var(--info-a15); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info-text); }

/* ── toast ───────────────────────────────────────────────────────────────── */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 280px; max-width: 420px; padding: 12px 16px 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--gold);
  border-radius: var(--r-md); box-shadow: var(--shadow); color: var(--text); font-size: var(--fs-sm);
  animation: rise 200ms var(--ease);
}
.toast.ok { border-left-color: var(--ok); } .toast.error { border-left-color: var(--danger); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ── modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(2, 3, 8, 0.72); backdrop-filter: blur(4px); animation: rise 150ms var(--ease);
}
.modal { width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow); }
.modal.wide { width: min(860px, 100%); }
.modal .panel-body { overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line-neutral); }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line-neutral); }
.modal-head h2 { font: 700 var(--fs-md) var(--font-display); letter-spacing: 1.5px; text-transform: uppercase; color: var(--text); }
.modal-head .btn { margin-left: auto; }

/* ── dropdown menu ───────────────────────────────────────────────────────── */
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; padding: 6px;
  max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.menu button, .menu a {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-2); font-size: var(--fs-sm); text-align: left; cursor: pointer;
}
.menu button:hover, .menu a:hover { background: var(--surface-hover); color: var(--text); }
.menu button.danger { color: var(--danger-text); }
.menu svg { width: 16px; height: 16px; opacity: 0.8; }
.menu hr { border: 0; border-top: 1px solid var(--line-neutral); margin: 6px 0; }
.menu .menu-label { padding: 6px 10px 2px; font: 600 9px var(--font-display); letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }

/* ── log / chat lines ────────────────────────────────────────────────────── */
.log {
  font: 12px/1.6 var(--font-mono); color: var(--text-2); background: var(--bg); padding: 12px 14px;
  max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-all; border-radius: var(--r-md);
}
.log .err { color: var(--danger-text); } .log .warn { color: var(--warn-text); }
.chat-list { display: flex; flex-direction: column; }
.chat-line { display: grid; grid-template-columns: 112px 1fr; gap: 12px; padding: 7px 16px; border-bottom: 1px solid var(--line-neutral); font-size: var(--fs-sm); }
.chat-line:last-child { border-bottom: 0; }
.chat-line time { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; padding-top: 2px; }
.chat-line .who { color: var(--gold-light); font-weight: 600; margin-right: 6px; }
.chat-line .where { color: var(--muted); font-size: var(--fs-xs); margin-left: 6px; }
.chat-line.flagged { background: linear-gradient(90deg, var(--danger-a15), transparent 60%); }
.chat-line .msg { color: var(--text); overflow-wrap: anywhere; }
.chat-line .deleted { text-decoration: line-through; opacity: 0.6; }

/* ── bars ────────────────────────────────────────────────────────────────── */
.bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--grad-gold); }
.bar.fire > i { background: var(--grad-fire); }
.bar.danger > i { background: var(--danger); }

.copy { cursor: copy; border-bottom: 1px dashed var(--faint); }
.copy:hover { color: var(--gold-light); }
