:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a20;
  --panel-2: #1d2129;
  --text: #f1f3f7;
  --muted: #9aa3b2;
  --line: #303642;
  --primary: #7c5cff;
  --secondary: #3ba068;
  --warning: #d6a83f;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: inherit; }
textarea, button { font: inherit; }

.topbar { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(16,17,20,.92); position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand { font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.server-switcher { display: flex; align-items: center; gap: 6px; }
.server-option { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px; border: 1px solid transparent; color: var(--muted); text-decoration: none; white-space: nowrap; }
.server-option:hover, .server-option.active { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.server-option.active { border-bottom-color: var(--primary); }
.server-option img { width: 24px; height: 24px; object-fit: cover; background: #2a303b; border: 1px solid var(--line); }
.userbar { display: flex; gap: 16px; align-items: center; color: var(--muted); }
.page { max-width: 1440px; margin: 0 auto; padding: 22px 18px 48px; }
.hero, .ticket-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.ticket-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(24px, 4vw, 34px); }
h2 { display: flex; justify-content: space-between; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .08em; margin-bottom: 10px; }
.muted, small { color: var(--muted); }
.button { border: 1px solid var(--line); color: var(--text); background: var(--panel-2); border-radius: 0; padding: 8px 12px; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.button.secondary { background: var(--secondary); border-color: var(--secondary); color: white; }
.button.warning { background: rgba(214,168,63,.15); border-color: var(--warning); color: #ffd985; }
.button.danger { background: rgba(255,107,107,.15); border-color: var(--danger); color: #ffd1d1; }
.error { border: 1px solid var(--danger); color: #ffd1d1; background: rgba(255,107,107,.12); padding: 12px; border-radius: 0; margin-bottom: 18px; }

.ticket-sections { display: grid; gap: 18px; }
.ticket-section { background: var(--panel); border: 1px solid var(--line); padding: 12px; }
.awaiting-section { border-top: 2px solid var(--primary); }
.ticket-table-head, .ticket-row { display: grid; grid-template-columns: 90px minmax(160px, 1.2fr) minmax(210px, 1.2fr) 120px 130px 80px 80px; gap: 12px; align-items: center; }
.ticket-table-head { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.ticket-row { min-height: 34px; text-decoration: none; border-bottom: 1px solid #262b35; padding: 6px 10px; color: var(--text); }
.ticket-row:nth-child(even) { background: rgba(255,255,255,.015); }
.ticket-row:hover { background: var(--panel-2); outline: 1px solid var(--primary); outline-offset: -1px; }
.ticket-row span, .ticket-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assigned { color: #c7bfff; }
.empty { color: var(--muted); padding: 12px; border: 1px dashed var(--line); border-radius: 0; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; grid-column: 2; }
.back { color: var(--muted); text-decoration: none; }
.ticket-nav { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 10px; min-width: min(460px, 100%); justify-self: end; }
.ticket-nav-button { display: grid; gap: 2px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 9px 11px; text-decoration: none; }
.ticket-nav-button:hover { border-color: var(--primary); background: var(--panel-2); }
.ticket-nav-button > span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.ticket-nav-button strong, .ticket-nav-button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-nav-button.disabled { color: var(--muted); opacity: .55; }
.ticket-nav-button.disabled:hover { border-color: var(--line); background: var(--panel); }
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.conversation, .sidepanel { background: var(--panel); border: 1px solid var(--line); border-radius: 0; padding: 16px; }
.danger-panel { margin-top: 16px; border-color: rgba(255,107,107,.45); }
.message-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.message { background: var(--panel-2); border-radius: 0; padding: 14px; border-left: 3px solid #657082; }
.message.staff { border-left-color: var(--primary); }
.message-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); margin-bottom: 8px; }
.message-meta strong { color: var(--text); }
.message-content { white-space: pre-wrap; margin-bottom: 0; }
.embed { border: 1px solid var(--line); border-radius: 0; padding: 10px; margin-top: 8px; color: #d9dee8; background: rgba(255,255,255,.03); }
.embed p { white-space: pre-wrap; }
.embed-field { display: grid; gap: 3px; padding: 7px 0; border-top: 1px solid var(--line); }
.attachment { display: inline-block; margin-top: 8px; color: #bdb2ff; }
.composer { display: grid; gap: 10px; }
.composer-tip { color: var(--muted); font-size: 12px; margin: -4px 0 0; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line); background: #0d0e12; color: var(--text); border-radius: 0; padding: 12px; }
label { display: block; margin-bottom: 8px; color: var(--muted); }
.sidepanel form { display: grid; gap: 10px; }
.sidepanel-button { width: 100%; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); border: 1px solid var(--line); background: var(--panel); border-radius: 0; padding: 28px; text-align: center; }

@media (max-width: 820px) {
  .ticket-grid { grid-template-columns: 1fr; }
  .ticket-table-head { display: none; }
  .ticket-row { grid-template-columns: 74px 1fr; gap: 4px 10px; min-height: auto; }
  .ticket-row span:nth-of-type(3), .ticket-row .assigned, .ticket-row small { grid-column: 2; }
  .hero, .ticket-header { display: block; }
  .ticket-nav { grid-template-columns: 1fr; margin-top: 14px; }
  .actions { justify-content: flex-start; margin-top: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 10px 14px; }
  .topbar-left { align-items: flex-start; flex-direction: column; gap: 8px; width: 100%; }
  .server-switcher { width: 100%; overflow-x: auto; }
}
