:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f5;
  --ink: #17202c;
  --muted: #637083;
  --line: #dce3ea;
  --line-strong: #c7d1dc;
  --sidebar: #151a23;
  --sidebar-soft: #1d2430;
  --blue: #2f6fed;
  --blue-soft: #e8efff;
  --green: #23875a;
  --green-soft: #e6f5ed;
  --amber: #a46100;
  --amber-soft: #fff3dc;
  --red: #c93737;
  --red-soft: #ffe8e8;
  --purple: #7252d6;
  --purple-soft: #eee9ff;
  --shadow: 0 18px 48px rgba(25, 36, 52, .12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(47, 111, 237, .07), transparent 32%),
    linear-gradient(300deg, rgba(35, 135, 90, .07), transparent 36%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #f7f9fc;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 46px;
  height: 46px;
  padding: 4px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.brand span {
  display: grid;
  gap: 1px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand strong {
  color: #9db8ff;
  font-size: 13px;
  letter-spacing: .02em;
}

.queue-nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

.queue-button {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #c8d0db;
  background: transparent;
  border-radius: 8px;
  text-align: left;
}

.queue-button:hover,
.queue-button.active {
  color: #fff;
  background: var(--sidebar-soft);
}

.queue-button strong {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #dbe6ff;
  background: rgba(255, 255, 255, .08);
  font-size: 12px;
  text-align: center;
}

.side-section {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.side-section h2 {
  margin: 0 0 13px;
  color: #8e9aae;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

.team-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .045);
}

.team-member span {
  min-width: 0;
  overflow: hidden;
  color: #edf3ff;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-member strong {
  color: #aeb8c8;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
  letter-spacing: -.045em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  width: min(320px, 34vw);
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
}

.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 12px 28px rgba(47, 111, 237, .22);
}

.ghost-button {
  padding: 0 14px;
  color: #253043;
  background: #fff;
  border: 1px solid var(--line);
}

.danger-button {
  padding: 0 14px;
  color: #fff;
  background: var(--red);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  color: var(--muted);
  background: var(--surface-soft);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 12px 30px rgba(25, 36, 52, .07);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin: 6px 0 3px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.04em;
}

.metric small {
  color: var(--muted);
}

.ticket-workbench {
  display: grid;
  grid-template-columns: minmax(420px, .96fr) minmax(420px, 1.04fr);
  gap: 16px;
  align-items: start;
}

.list-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}

.list-panel {
  overflow: hidden;
}

.panel-toolbar {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-toolbar h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: -.03em;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .14);
}

.ticket-list {
  max-height: calc(100vh - 278px);
  min-height: 320px;
  overflow: auto;
}

.ticket-row {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 15px 16px;
  color: inherit;
  background: #fff;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.ticket-row:hover,
.ticket-row.active {
  background: #f7faff;
}

.ticket-row.active {
  box-shadow: inset 4px 0 0 var(--blue);
}

.ticket-row-top,
.ticket-row-bottom,
.detail-title-row,
.detail-actions,
.note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ticket-id {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.ticket-row h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  letter-spacing: -.015em;
}

.ticket-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.chip.blue {
  color: #2255b9;
  background: var(--blue-soft);
}

.chip.green {
  color: var(--green);
  background: var(--green-soft);
}

.chip.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.chip.red {
  color: var(--red);
  background: var(--red-soft);
}

.chip.purple {
  color: var(--purple);
  background: var(--purple-soft);
}

.chip.neutral {
  color: #4d5969;
  background: #edf1f5;
}

.detail-panel {
  position: sticky;
  top: 24px;
  padding: 18px;
}

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

.detail-empty strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 18px;
}

.detail-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-title-row {
  align-items: flex-start;
}

.detail-title-row h2 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1.08;
  letter-spacing: -.04em;
}

.detail-meta {
  margin: 0;
  color: var(--muted);
}

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

.detail-field {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.detail-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-field strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.description-block,
.notes-block {
  padding-top: 16px;
}

.description-block h3,
.notes-block h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.description-block p {
  margin: 0;
  color: #354155;
  line-height: 1.55;
  white-space: pre-wrap;
}

.note-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.note {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.note-head {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.note p {
  margin: 0;
  color: #303b4d;
  line-height: 1.45;
  white-space: pre-wrap;
}

.note-form {
  display: grid;
  gap: 8px;
}

.note-form textarea {
  min-height: 76px;
}

.detail-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 16px;
}

.ticket-dialog {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(16, 26, 42, .32);
}

.ticket-dialog::backdrop {
  background: rgba(9, 15, 24, .48);
  backdrop-filter: blur(4px);
}

.ticket-form {
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-heading h2 {
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: -.04em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.span-2 {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.empty-list {
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-list strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
  }

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

  .detail-panel {
    position: static;
  }

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

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .queue-nav {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .metrics,
  .filter-row,
  .detail-grid,
  .detail-editor,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .workspace {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 14px;
  }

  .metrics {
    gap: 8px;
  }

  .metric,
  .panel-toolbar,
  .detail-panel,
  .ticket-row,
  .ticket-form {
    padding: 13px;
  }

  .ticket-row-top,
  .ticket-row-bottom,
  .detail-title-row,
  .detail-actions,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }
}
