:root {
  --void:    #131319;
  --panel:   #1b1c24;
  --panel-2: #21222c;
  --seam:    #2a2b36;
  --seam-lo: #212229;
  --ink:     #eef0f5;
  --dim:     #8d8fa0;
  --faint:   #5c5e6c;
  --brand:   #8b7fff;
  --brand-dim: rgba(139,127,255,.14);

  /* Status is the real color system here — it carries meaning, not decoration. */
  --open:     #f2a93c;
  --progress: #5b9dff;
  --resolved: #4fc38a;
  --closed:   #6d6f7d;
  --urgent:   #ff5d5d;

  --radius: 8px;
  --radius-lg: 12px;
  --gap: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--void); color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: 'Space Grotesk', 'Inter', sans-serif; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

a { color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--seam);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 58px;
  position: sticky; top: 0; z-index: 100;
}
header.topbar img.logo-mark { height: 22px; width: auto; opacity: .92; }
header.topbar .brand {
  font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600;
  color: var(--ink); letter-spacing: .1px;
}
header.topbar .brand span.tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; font-weight: 500;
  color: var(--brand); background: var(--brand-dim);
  border-radius: 4px; padding: 2px 6px; margin-left: 8px; letter-spacing: .4px;
  vertical-align: 2px;
}

.staff-bar { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.staff-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  background: var(--panel-2); color: var(--dim); border: 1px solid var(--seam);
  border-radius: 5px; padding: 4px 10px; font-size: 11px; letter-spacing: .3px;
}
.staff-name { font-size: 13px; color: var(--ink); }
.staff-logout {
  background: none; border: 1px solid var(--seam); color: var(--dim);
  border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.staff-logout:hover { color: var(--ink); border-color: var(--urgent); }

nav.tabs {
  background: var(--panel);
  border-bottom: 1px solid var(--seam);
  padding: 0 28px;
  display: flex; gap: 2px;
}
nav.tabs button {
  background: none; border: none; color: var(--dim);
  padding: 13px 16px; font-size: 13px; font-weight: 500; cursor: pointer; position: relative;
  transition: color .15s; font-family: inherit;
}
nav.tabs button:hover { color: var(--ink); }
nav.tabs button.active { color: var(--ink); }
nav.tabs button.active::after {
  content: ''; position: absolute; bottom: 0; left: 14px; right: 14px; height: 2px;
  background: var(--brand); border-radius: 2px 2px 0 0;
}
nav.tabs .count-badge {
  display: inline-block; margin-left: 5px; font-family: 'IBM Plex Mono', monospace;
  color: var(--faint); font-size: 11px;
}
nav.tabs button.active .count-badge { color: var(--brand); }

main { flex: 1; padding: 26px 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ── Cards ── */
.card {
  background: var(--panel); border: 1px solid var(--seam); border-radius: var(--radius-lg);
  padding: var(--gap);
}
.card + .card { margin-top: var(--gap); }

/* ── Filters ── */
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row input, .filter-row select {
  background: var(--panel-2); border: 1px solid var(--seam); color: var(--ink);
  border-radius: 6px; padding: 8px 12px; font-size: 13px; font-family: inherit;
}
.filter-row input:focus, .filter-row select:focus { outline: none; border-color: var(--brand); }
.filter-row input[type="search"] { flex: 1; min-width: 220px; font-family: 'IBM Plex Mono', monospace; }
.filter-row input[type="search"]::placeholder { font-family: 'Inter', sans-serif; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: opacity .15s, transform .1s; font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--brand); color: #0f0f14; font-weight: 600; }
.btn-danger   { background: var(--urgent); color: #1a0d0d; font-weight: 600; }
.btn-green    { background: var(--resolved); color: #0d1a13; font-weight: 600; }
.btn-ghost    { background: transparent; border: 1px solid var(--seam); color: var(--ink); }
.btn-sm       { padding: 5px 11px; font-size: 12px; }
.btn-block    { width: 100%; justify-content: center; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  color: var(--faint); font-family: 'IBM Plex Mono', monospace; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .6px; padding: 8px 12px 10px; text-align: left;
  border-bottom: 1px solid var(--seam); font-weight: 500;
}
td { padding: 0 12px; border-bottom: 1px solid var(--seam-lo); vertical-align: middle; height: 56px; }
tr.ticket-row { cursor: pointer; position: relative; }
tr.ticket-row td:first-child { border-left: 3px solid transparent; }
tr.ticket-row.pr-Urgent td:first-child { border-left-color: var(--urgent); }
tr.ticket-row.pr-High td:first-child { border-left-color: var(--open); }
tr.ticket-row.pr-Normal td:first-child { border-left-color: var(--progress); }
tr.ticket-row.pr-Low td:first-child { border-left-color: var(--seam); }
tr.ticket-row:hover td { background: rgba(139,127,255,.05); }
tr:last-child td { border-bottom: none; }
.ticket-id { color: var(--faint); font-size: 11px; }

/* ── Pills / badges ── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 600;
  font-family: 'IBM Plex Mono', monospace; letter-spacing: .2px;
  white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-open     { background: rgba(242,169,60,.13);  color: var(--open); }
.pill-progress { background: rgba(91,157,255,.13);  color: var(--progress); }
.pill-resolved { background: rgba(79,195,138,.13);  color: var(--resolved); }
.pill-closed   { background: rgba(109,111,125,.16); color: var(--closed); }
.pill-urgent   { background: rgba(255,93,93,.13);   color: var(--urgent); }
.pill-cat {
  font-family: 'Inter', sans-serif; font-weight: 600; letter-spacing: 0;
  background: rgba(139,127,255,.12); color: var(--brand);
}
.pill-cat::before { display: none; }

/* ── Ticket detail panel ── */
.detail-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(8,8,11,.7); z-index: 200; justify-content: flex-end;
}
.detail-backdrop.open { display: flex; }
.detail-panel {
  background: var(--void); border-left: 1px solid var(--seam);
  width: 100%; max-width: 740px; height: 100%; overflow-y: auto;
  padding: 0 0 60px;
  box-shadow: -30px 0 60px rgba(0,0,0,.35);
}
.detail-panel .detail-head {
  border-left: 4px solid var(--seam);
  padding: 26px 32px 20px;
  border-bottom: 1px solid var(--seam);
}
.detail-panel.pr-Urgent .detail-head { border-left-color: var(--urgent); }
.detail-panel.pr-High .detail-head { border-left-color: var(--open); }
.detail-panel.pr-Normal .detail-head { border-left-color: var(--progress); }
.detail-panel.pr-Low .detail-head { border-left-color: var(--seam); }
.detail-panel .detail-body { padding: 0 32px 40px; }
.detail-close {
  background: none; border: 1px solid var(--seam); color: var(--dim);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-family: inherit;
}
.detail-close:hover { color: var(--ink); }
.detail-panel .detail-close { float: right; }
.detail-title { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 600; margin: 10px 0 6px; padding-right: 60px; }
.detail-meta {
  color: var(--faint); font-size: 11.5px; font-family: 'IBM Plex Mono', monospace; letter-spacing: .2px;
}
.detail-section { margin-top: 24px; }
.detail-section h4 {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--faint); margin-bottom: 10px; font-weight: 500;
}
.detail-desc { white-space: pre-wrap; line-height: 1.65; font-size: 13.5px; }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--faint);
  text-transform: uppercase; letter-spacing: .4px;
}
.field select, .field input {
  background: var(--panel-2); border: 1px solid var(--seam); color: var(--ink);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: 'Inter', sans-serif;
}

.attachment-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-chip {
  display: flex; align-items: center; gap: 8px; background: var(--panel-2);
  border: 1px solid var(--seam); border-radius: 7px; padding: 8px 12px; font-size: 12px;
  text-decoration: none; color: var(--ink); cursor: pointer; font-family: inherit;
}
.attachment-chip:hover { border-color: var(--brand); }

/* ── Attachment lightbox — attachments are viewed in-browser, never downloaded
   to disk. Untrusted user-submitted files stay inside the browser's media
   sandbox instead of landing on a support agent's filesystem. ── */
.lightbox-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(6,6,9,.86); z-index: 300; align-items: center; justify-content: center;
  padding: 32px;
}
.lightbox-backdrop.open { display: flex; }
.lightbox-shell {
  max-width: min(92vw, 1100px); max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--seam); border-radius: var(--radius-lg);
  overflow: hidden;
}
.lightbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--seam);
  font-size: 12px; color: var(--dim);
}
.lightbox-body {
  padding: 16px; overflow: auto; display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#1f2029 0% 25%, #191a21 0% 50%) 50% / 20px 20px;
}
.lightbox-body img, .lightbox-body video {
  display: block; max-width: min(86vw, 1000px); max-height: 78vh; border-radius: 6px;
}
.lightbox-body .lightbox-message { color: var(--dim); font-size: 13px; padding: 40px; }

.note-list { display: flex; flex-direction: column; gap: 10px; }
.note {
  background: var(--panel-2); border: 1px solid var(--seam); border-radius: 7px; padding: 12px 14px;
}
.note.emailed { border-left: 3px solid var(--resolved); }
.note-head {
  display: flex; justify-content: space-between; font-size: 11px; color: var(--faint);
  margin-bottom: 6px; font-family: 'IBM Plex Mono', monospace;
}
.note-body { font-size: 13px; white-space: pre-wrap; line-height: 1.55; }

.reply-box textarea {
  width: 100%; min-height: 90px; resize: vertical;
  background: var(--panel-2); border: 1px solid var(--seam); color: var(--ink);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; font-family: 'Inter', sans-serif;
}
.reply-box textarea:focus { outline: none; border-color: var(--brand); }
.reply-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.reply-hint { font-size: 11px; color: var(--faint); margin-left: auto; font-family: 'IBM Plex Mono', monospace; }

.mod-shortcuts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--faint); font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; padding: 11px 18px; border-radius: 8px;
  background: var(--resolved); color: #0d1a13; font-size: 13px; font-weight: 600;
  transform: translateY(20px); opacity: 0; transition: .22s; pointer-events: none; z-index: 999;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.error { background: var(--urgent); color: #1a0d0d; }

.hidden { display: none !important; }
