:root {
  --ink: #182126;
  --muted: #617179;
  --subtle: #8b989d;
  --line: #d9e0df;
  --soft: #f4f7f6;
  --panel: #ffffff;
  --rail: #12191d;
  --rail-2: #1b2529;
  --teal: #087b73;
  --teal-2: #0c9a8d;
  --blue: #2f66d4;
  --red: #c9473d;
  --amber: #c78618;
  --green: #13845e;
  --purple: #7257b7;
  --shadow: 0 18px 52px rgba(21, 32, 37, .10);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 750;
  cursor: pointer;
}

button:hover { border-color: #b7c5c2; }

button.primary, .primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--rail);
  color: #ecf3f2;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(135deg, #73d6cd, var(--teal));
  color: #071315;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  color: #9fb1b5;
  font-size: 12px;
}

.role-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #0c1114;
}

.role-switch button {
  border: 0;
  color: #9fb1b5;
  background: transparent;
  min-height: 34px;
  padding: 0 6px;
  font-size: 12px;
}

.role-switch button.active {
  background: #26363a;
  color: #fff;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 0;
  color: #bfced1;
  background: transparent;
  min-height: 40px;
  text-align: left;
  padding: 0 10px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--rail-2);
  color: #fff;
}

.nav-item small {
  color: #7f9499;
  font-size: 11px;
  font-weight: 800;
}

.system-box {
  margin-top: auto;
  border: 1px solid #2f4147;
  background: #162126;
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 8px;
}

.system-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.system-row strong { color: #78d2a7; }

.system-meter {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: #29393e;
}

.system-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-2), #78d2a7);
}

.system-box small {
  color: #9fb1b5;
  line-height: 1.45;
}

.main {
  min-width: 0;
  padding: 18px 20px 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  letter-spacing: .05em;
}

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

h1 {
  font-size: 27px;
  line-height: 1.08;
  margin-bottom: 5px;
}

.event-title p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.search {
  height: 38px;
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
}

.search span {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  min-width: 120px;
}

.language-select {
  height: 38px;
  min-width: 172px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
}

.language-select span {
  font-weight: 850;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.language-select select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.square {
  width: 36px;
  min-width: 36px;
  padding: 0;
  display: grid;
  place-items: center;
}

.icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  flex: 0 0 auto;
}

.icon svg {
  width: 17px;
  height: 17px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view {
  display: grid;
  gap: 16px;
}

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

.section-head h2 {
  font-size: 19px;
  margin-bottom: 4px;
}

.section-head p {
  color: var(--muted);
  max-width: 780px;
  margin-bottom: 0;
}

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

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 106px;
  box-shadow: var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi strong {
  display: block;
  font-size: 27px;
  line-height: 1;
  margin-top: 12px;
}

.kpi small {
  display: block;
  color: var(--green);
  font-weight: 750;
  margin-top: 8px;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, .8fr);
  gap: 14px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px;
  min-width: 0;
}

.panel.no-shadow {
  box-shadow: none;
}

.panel h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tab {
  background: #eef3f2;
  border-color: #eef3f2;
  color: var(--muted);
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.status-list {
  display: grid;
  gap: 9px;
}

.status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.status-row:first-child { border-top: 0; }

.status-row b {
  display: block;
  margin-bottom: 2px;
}

.status-row span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--teal);
  background: #e6f4f1;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.blue { color: var(--blue); background: #eaf0ff; }
.badge.red { color: var(--red); background: #fbebe9; }
.badge.amber { color: #94600e; background: #fff2d6; }
.badge.green { color: var(--green); background: #e7f5ef; }
.badge.purple { color: var(--purple); background: #f0edf9; }
.badge.dark { color: #fff; background: var(--ink); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 8px 9px;
}

.data-table td {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #f8fbfa;
}

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

.mini-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: #fff;
  min-height: 82px;
}

.mini-card b {
  display: block;
  margin-bottom: 5px;
}

.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.timeline-row time {
  font-weight: 850;
  color: var(--teal);
}

.route-map {
  height: 330px;
  border-radius: var(--radius);
  border: 1px solid #cbd8d5;
  background:
    linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.35) 1px, transparent 1px),
    linear-gradient(135deg, #dceae5, #eef4f2);
  background-size: 38px 38px, 38px 38px, 100% 100%;
  position: relative;
  overflow: hidden;
}

.route-line {
  position: absolute;
  inset: 46px 38px 62px 38px;
  border: 10px solid rgba(8, 123, 115, .75);
  border-left-color: transparent;
  border-bottom-color: rgba(47, 102, 212, .72);
  border-radius: 48% 42% 54% 36%;
  transform: rotate(-8deg);
}

.station-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  border: 4px solid var(--red);
  box-shadow: 0 0 0 6px rgba(201, 71, 61, .16);
}

.station-dot.s1 { left: 18%; top: 43%; }
.station-dot.s2 { left: 42%; top: 20%; border-color: var(--blue); box-shadow: 0 0 0 6px rgba(47,102,212,.16); }
.station-dot.s3 { right: 20%; top: 49%; border-color: var(--amber); box-shadow: 0 0 0 6px rgba(199,134,24,.18); }
.station-dot.s4 { left: 52%; bottom: 21%; border-color: var(--green); box-shadow: 0 0 0 6px rgba(19,132,94,.16); }

.map-readout {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.map-readout div {
  border: 1px solid rgba(217,224,223,.92);
  background: rgba(255,255,255,.92);
  border-radius: var(--radius);
  padding: 10px;
}

.map-readout b {
  display: block;
}

.map-readout span {
  color: var(--muted);
  font-size: 12px;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  background: #fff;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

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

.toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.switch {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #ccd7d5;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  left: 2px;
  top: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

.toggle.on .switch { background: var(--teal); }
.toggle.on .switch::after { left: 18px; }

.progress-list {
  display: grid;
  gap: 11px;
}

.progress-row {
  display: grid;
  gap: 6px;
}

.progress-row div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 750;
  font-size: 12px;
}

.bar {
  height: 9px;
  background: #e7edeb;
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.public-shell {
  border: 1px solid #152126;
  background: #0f171a;
  color: #f1f7f6;
  border-radius: var(--radius);
  overflow: hidden;
}

.public-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid #26363a;
}

.public-head h3 { margin-bottom: 2px; }
.public-head span { color: #a8babd; }

.public-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.public-body > div {
  padding: 14px;
  border-right: 1px solid #26363a;
}

.public-body > div:last-child { border-right: 0; }

.live-feed {
  display: grid;
  gap: 8px;
}

.live-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #26363a;
  border-radius: var(--radius);
  padding: 10px;
  background: #151f23;
}

.live-item b {
  display: block;
}

.live-item span:not(.rank) {
  display: block;
  color: #a8babd;
  font-size: 12px;
  margin-top: 2px;
}

.rank {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #233237;
  font-weight: 850;
}

.tv-preview {
  min-height: 250px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(8,123,115,.82), rgba(18,33,38,.96)),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.24), transparent 28%);
  color: #fff;
  padding: 18px;
  display: grid;
  align-content: end;
  position: relative;
  overflow: hidden;
}

.tv-preview::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 7px;
}

.tv-preview h3 {
  position: relative;
  font-size: 25px;
  margin-bottom: 8px;
}

.tv-preview p {
  position: relative;
  color: #d9e5e2;
  margin-bottom: 0;
}

.inspector {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(430px, 92vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 42px rgba(16,28,32,.16);
  transform: translateX(103%);
  transition: transform .18s ease;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr;
}

.inspector.open { transform: translateX(0); }

.inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.inspector-head h2 {
  font-size: 19px;
  margin-bottom: 0;
}

.inspector-body {
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 120px);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 15px;
  box-shadow: var(--shadow);
  z-index: 20;
  transition: transform .18s ease;
  font-weight: 750;
}

.toast.show { transform: translate(-50%, 0); }

.empty {
  border: 1px dashed #b7c5c2;
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: #fff;
}

.ticket-board {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: stretch;
}

.ticket-list,
.ticket-conversation,
.ticket-properties {
  min-height: 520px;
}

.ticket-card {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 11px;
  margin-bottom: 8px;
}

.ticket-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 123, 115, .10);
}

.ticket-card strong {
  display: block;
  line-height: 1.25;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.conversation-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  margin-bottom: 10px;
}

.conversation-item.agent {
  background: #f1f7f6;
  border-color: #c7dfdb;
}

.conversation-item.private {
  background: #fff7e7;
  border-color: #f1d49c;
}

.conversation-item b {
  display: block;
  margin-bottom: 4px;
}

.conversation-item p {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

.sla-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.sla-cell {
  border-radius: var(--radius);
  background: #f8fbfa;
  border: 1px solid var(--line);
  padding: 10px;
}

.sla-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  letter-spacing: .05em;
}

.sla-cell strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

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

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-2, .layout-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
  }
  .topbar {
    grid-template-columns: 1fr;
  }
  .top-actions {
    justify-content: stretch;
  }
  .search {
    width: 100%;
    min-width: 0;
  }
  .language-select {
    width: 100%;
  }
  .kpi-grid,
  .compact-grid,
  .form-grid,
  .map-readout,
  .public-body {
    grid-template-columns: 1fr;
  }
  .public-body > div {
    border-right: 0;
    border-bottom: 1px solid #26363a;
  }
  .timeline-row {
    grid-template-columns: 1fr;
  }
  .ticket-board {
    grid-template-columns: 1fr;
  }
  .ticket-list,
  .ticket-conversation,
  .ticket-properties {
    min-height: auto;
  }
  .data-table {
    min-width: 720px;
  }
  .panel.table-wrap {
    overflow-x: auto;
  }
}
