:root {
  --ink: #14213d;
  --paper: #ffffff;
  --line: #d9dee8;
  --muted: #667085;
  --soft: #f5f7fa;
  --action: #fca311;
  --teal: #2a9d8f;
  --danger: #a33b2f;
  --radius: 8px;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(20, 33, 61, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(20, 33, 61, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1;
}

.brand span {
  overflow-wrap: anywhere;
}

.tabs {
  display: grid;
  gap: 7px;
}

.tab,
.icon-action {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--paper);
  min-height: 42px;
  border-radius: var(--radius);
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.tab {
  text-align: left;
  padding: 0 12px;
}

.tab:hover,
.tab.is-active {
  background: var(--action);
  border-color: var(--action);
  color: #1d2638;
  transform: translateX(2px);
}

.rail-note {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 18px;
}

.rail-note span,
.eyebrow,
.section-head span,
.metrics span,
.case-meta span,
.case-facts span,
.record-title span,
dt {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 11px;
  font-weight: 800;
}

.rail-note strong {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.workspace {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  gap: 24px;
  align-items: end;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
}

.eyebrow {
  color: var(--teal);
  margin: 0 0 8px;
}

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

h1 {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  max-width: 820px;
}

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  border: 2px solid var(--ink);
  background: var(--paper);
  min-height: 48px;
}

.search input {
  border: 0;
  min-width: 0;
  padding: 0 14px;
  outline: none;
}

.search button,
.case-actions button,
.action-form button {
  border: 0;
  background: var(--action);
  color: #1d2638;
  font-weight: 900;
  min-height: 44px;
  padding: 0 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 2px solid var(--ink);
  background: var(--paper);
}

.metrics article {
  padding: 14px 16px;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.metrics article:last-child {
  border-right: 0;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.view {
  display: none;
  animation: liftIn 240ms ease both;
}

.view.is-visible {
  display: block;
}

.dispatch,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.case-board,
.queue,
.detail-panel,
.action-panel,
.calendar-view,
.report-view {
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--ink);
}

.section-head {
  min-height: 48px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 14px;
}

.section-head select {
  min-width: 132px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.icon-action {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-color: var(--ink);
  color: var(--ink);
}

.active-case {
  position: relative;
  min-height: 512px;
  padding: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.case-orbit {
  position: absolute;
  right: -100px;
  top: -74px;
  width: 320px;
  height: 320px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transform: rotate(-18deg);
  opacity: 0.12;
}

.case-orbit::after {
  content: "";
  position: absolute;
  inset: 56px;
  border: 16px solid var(--action);
  border-left-color: transparent;
  border-radius: 50%;
}

.case-orbit span {
  position: absolute;
  right: 40px;
  top: 72px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--teal);
}

.case-meta {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-meta span {
  border: 1px solid var(--ink);
  padding: 6px 9px;
  background: var(--paper);
}

.active-case h2 {
  position: relative;
  margin: 36px 0 10px;
  font-family: var(--serif);
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.9;
  max-width: 760px;
}

.artist {
  position: relative;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.progress {
  height: 8px;
  background: var(--line);
  margin: 22px 0 24px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
  transition: width 260ms ease;
}

.case-facts {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.case-facts div {
  padding: 14px;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.case-facts div:last-child {
  border-right: 0;
}

.case-facts strong {
  display: block;
  margin-top: 6px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.case-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.case-actions span {
  color: var(--muted);
}

.case-list {
  display: grid;
}

.case-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
  padding: 15px 14px;
  background: var(--paper);
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition: background 160ms ease, padding-left 160ms ease;
}

.case-row:hover,
.case-row.is-selected {
  background: #fff6e6;
  padding-left: 20px;
}

.case-row strong,
.case-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-row small {
  color: var(--muted);
  margin-top: 5px;
}

.case-row em {
  align-self: center;
  font-style: normal;
  font-size: 12px;
  padding: 5px 8px;
  color: var(--paper);
  background: var(--ink);
}

.detail-panel,
.action-panel {
  min-height: 560px;
}

.detail-view,
.action-form {
  padding: 18px;
}

.record-title h2 {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.95;
  margin: 8px 0;
}

.record-title p {
  color: var(--muted);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  margin: 20px 0;
}

.record-grid div {
  background: var(--paper);
  padding: 14px;
  min-width: 0;
}

dt {
  color: var(--teal);
}

dd {
  margin: 6px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.history article {
  border-left: 4px solid var(--action);
  padding: 10px 0 10px 14px;
}

.history span {
  font-weight: 900;
}

.history p {
  margin: 5px 0;
  line-height: 1.45;
}

.history time {
  color: var(--muted);
  font-size: 13px;
}

.action-form {
  display: grid;
  gap: 14px;
}

.action-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.action-form select,
.action-form textarea {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  min-width: 0;
  background: var(--paper);
}

.action-form textarea {
  resize: vertical;
}

.calendar-view {
  display: grid;
}

.calendar-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 180px 120px;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.calendar-row:last-child {
  border-bottom: 0;
}

.calendar-row time {
  font-weight: 900;
}

.calendar-row strong,
.calendar-row span {
  display: block;
}

.calendar-row span,
.calendar-row small {
  color: var(--muted);
}

.calendar-row em {
  font-style: normal;
  justify-self: start;
  border: 1px solid var(--ink);
  padding: 5px 8px;
}

.report-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  padding: 18px;
}

.report-table {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.report-table article {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(210px, auto);
  align-items: center;
  gap: 14px;
  background: var(--paper);
  padding: 16px;
}

.report-table strong {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
}

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

.entity-strip {
  display: grid;
  gap: 10px;
  align-content: start;
}

.entity-strip article {
  border: 2px solid var(--ink);
  padding: 12px;
  background: var(--soft);
}

.entity-strip span {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
}

.entity-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.empty {
  padding: 18px;
  color: var(--muted);
}

.skeleton {
  background: linear-gradient(110deg, #f6f7f8 8%, #eceff4 18%, #f6f7f8 33%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  background: var(--ink);
  color: var(--paper);
  padding: 12px 14px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab {
    text-align: center;
    padding: 0 8px;
  }

  .rail-note {
    display: none;
  }

  .topbar,
  .dispatch,
  .detail-grid,
  .report-view {
    grid-template-columns: 1fr;
  }

  .active-case {
    min-height: 440px;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 16px;
  }

  .tabs {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(132px, 1fr));
  }

  .topbar {
    align-items: stretch;
  }

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

  .search button {
    min-height: 40px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics article:nth-child(2) {
    border-right: 0;
  }

  .metrics article:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .active-case {
    min-height: auto;
    padding: 18px;
  }

  .active-case h2 {
    margin-top: 30px;
  }

  .case-facts,
  .record-grid {
    grid-template-columns: 1fr;
  }

  .case-facts div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .case-facts div:last-child {
    border-bottom: 0;
  }

  .calendar-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .report-table article {
    grid-template-columns: 1fr;
  }
}
