:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #111318;
  --text: #111318;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #2f6df6;
  --blue-dark: #1f53c9;
  --mint: #1f9d7a;
  --amber: #b26a00;
  --red: #c4362e;
  --shadow: 0 18px 45px rgba(18, 26, 38, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
}

h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
}

.auth-form,
.detail-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #394150;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
  white-space: normal;
}

.primary-button {
  background: var(--surface-strong);
  color: #ffffff;
}

.primary-button:hover {
  background: #232832;
}

.secondary-button {
  border-color: rgba(47, 109, 246, 0.28);
  background: rgba(47, 109, 246, 0.08);
  color: var(--blue-dark);
}

.ghost-button {
  border-color: var(--line);
  background: var(--surface);
  color: #394150;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
}

.message {
  min-height: 20px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-view {
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 18px;
  max-width: 1500px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.session-label {
  max-width: 240px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 10px;
  max-width: 1500px;
  margin: 0 auto 14px;
}

.stat-card {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

.ticket-pane,
.detail-pane {
  min-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ticket-pane {
  padding: 14px;
}

.detail-pane {
  position: sticky;
  top: 16px;
  padding: 18px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.search-label {
  grid-column: span 2;
}

.filter-button {
  align-self: end;
  min-height: 42px;
}

.request-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 350px);
  min-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.ticket-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  min-height: 94px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  text-align: left;
}

.ticket-row.is-stale {
  border-color: rgba(196, 54, 46, 0.34);
}

.ticket-row:hover,
.ticket-row.is-selected {
  border-color: rgba(47, 109, 246, 0.55);
  background: rgba(47, 109, 246, 0.06);
}

.ticket-topic {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 850;
}

.ticket-meta,
.detail-meta,
.load-status {
  color: var(--muted);
  font-size: 12px;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ticket-flags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.status-pill,
.priority-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-new {
  background: rgba(47, 109, 246, 0.12);
  color: var(--blue-dark);
}

.status-open {
  background: rgba(178, 106, 0, 0.14);
  color: var(--amber);
}

.status-answered {
  background: rgba(31, 157, 122, 0.14);
  color: var(--mint);
}

.status-closed {
  background: rgba(17, 19, 24, 0.09);
  color: #4a5260;
}

.priority-urgent,
.priority-high {
  background: rgba(196, 54, 46, 0.12);
  color: var(--red);
}

.priority-normal {
  background: rgba(31, 157, 122, 0.12);
  color: var(--mint);
}

.priority-low {
  background: rgba(102, 112, 133, 0.14);
  color: #4a5260;
}

.age-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  background: rgba(102, 112, 133, 0.11);
  color: #4a5260;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.age-stale {
  background: rgba(196, 54, 46, 0.12);
  color: var(--red);
}

.empty-detail {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.field-list div,
.message-block,
.context-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 750;
}

.message-block p {
  margin: 0;
  white-space: pre-wrap;
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
}

.attachment-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.context-details summary {
  cursor: pointer;
  color: #394150;
  font-weight: 850;
}

pre {
  margin: 12px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-pane {
    position: static;
  }

  .request-list {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app-view {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
  }

  .stats-grid,
  .filters,
  .field-list,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .search-label {
    grid-column: auto;
  }

  .ticket-pane,
  .detail-pane {
    min-height: 0;
  }

  .ticket-row {
    grid-template-columns: 1fr;
  }

  .detail-head {
    flex-direction: column;
  }
}
