:root {
  color-scheme: light;
  --ink: #182234;
  --muted: #667085;
  --line: #dce2ea;
  --paper: #ffffff;
  --canvas: #f3f6f9;
  --brand: #175cd3;
  --brand-dark: #1248a8;
  --accent: #0e9384;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }

.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0b1830;
  color: white;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #2e90fa; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #b8c7df; font-size: 12px; }
.identity { font-size: 14px; color: #d1dded; }

.shell { max-width: 1320px; margin: 0 auto; padding: 42px 28px 72px; }
.hero, .panel-heading, .detail-heading, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero { margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; }
h2 { margin-bottom: 4px; font-size: 21px; }
.eyebrow { margin-bottom: 7px; color: var(--brand); font-weight: 750; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px rgba(26, 39, 61, 0.05); }
.auth-panel { padding: 30px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 36px; }
.auth-fields, .ticket-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cbd3df; border-radius: 9px; padding: 11px 12px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px #dce8ff; }
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.button { border: 0; border-radius: 9px; padding: 10px 16px; cursor: pointer; font-weight: 700; }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.quiet { background: #eef3f8; color: #344054; }

#new-ticket-panel { padding: 26px; margin-bottom: 24px; }
.workspace-grid { display: grid; grid-template-columns: minmax(320px, 0.8fr) minmax(460px, 1.2fr); gap: 22px; align-items: start; }
.ticket-list-panel, .ticket-detail { min-height: 560px; }
.ticket-list-panel .panel-heading, .ticket-detail { padding: 24px; }
.ticket-list { border-top: 1px solid var(--line); }
.ticket-card { width: 100%; padding: 18px 24px; display: grid; gap: 8px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: white; cursor: pointer; }
.ticket-card:hover, .ticket-card.active { background: #f5f8ff; }
.ticket-card-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.ticket-card strong { font-size: 15px; color: var(--ink); }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; background: #eaf2ff; color: #1849a9; font-size: 12px; font-weight: 750; text-transform: capitalize; }
.detail-meta { display: flex; gap: 18px; flex-wrap: wrap; margin: 16px 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.conversation { display: grid; gap: 14px; max-height: 500px; overflow: auto; padding-right: 4px; }
.message { padding: 14px 16px; border-radius: 12px; background: #f1f5f9; }
.message.customer { margin-right: 38px; }
.message.agent, .message.admin, .message.supervisor { margin-left: 38px; background: #e8f2ff; }
.message-meta { margin-bottom: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.message-body { white-space: pre-wrap; line-height: 1.5; }
.reply-form { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.reply-form .form-actions { margin-top: 12px; }
.empty { display: grid; place-items: center; }
.empty-state { padding: 60px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 18px; border-radius: 50%; background: #eaf2ff; color: var(--brand); font-size: 24px; font-weight: 800; }
.empty-list { padding: 50px 24px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .auth-panel, .workspace-grid { grid-template-columns: 1fr; }
  .ticket-list-panel, .ticket-detail { min-height: auto; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 18px; }
  .shell { padding: 28px 16px 50px; }
  .auth-fields, .ticket-form { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .hero { align-items: flex-start; }
}
