:root {
  --ink: #252422;
  --paper: #fffcf2;
  --line: #ddd8ca;
  --accent: #eb5e28;
  --blue: #4f6d7a;
  --mint: #d8eadf;
  --danger: #b33a2f;
  --shadow: 0 18px 45px rgba(37, 36, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Arial Narrow", "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(79, 109, 122, 0.09) 1px, transparent 1px),
    linear-gradient(0deg, rgba(79, 109, 122, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 242, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 20px;
  line-height: 1.05;
}

.brand small,
.eyebrow,
.label,
.queue-meta {
  color: rgba(37, 36, 34, 0.62);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: rgba(37, 36, 34, 0.7);
  padding: 9px 12px;
  border-radius: 6px;
  white-space: nowrap;
}

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

main {
  padding: clamp(16px, 3vw, 34px);
}

.ops-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.ops-strip div {
  min-width: 0;
  padding: 16px;
  background: rgba(255, 252, 242, 0.96);
}

.ops-strip strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.35fr) minmax(250px, 0.8fr);
  gap: 1px;
  margin-top: 22px;
  min-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  box-shadow: var(--shadow);
}

.queue-panel,
.record-panel,
.action-panel {
  min-width: 0;
  background: rgba(255, 252, 242, 0.98);
}

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

.panel-head.compact {
  align-items: center;
}

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

h1,
h2 {
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1.08;
  max-width: 100%;
}

h3 {
  font-size: 15px;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--ink);
  padding: 10px 11px;
  outline-color: var(--blue);
}

#searchInput {
  max-width: 150px;
}

.create-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff8e7;
}

.create-box button,
.primary-action {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  padding: 11px 14px;
}

.queue-list {
  display: grid;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.queue-item {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 104px;
  padding: 16px 18px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.queue-item:hover,
.queue-item.is-selected {
  background: #fff5df;
}

.queue-item.is-selected {
  box-shadow: inset 4px 0 0 var(--accent);
}

.queue-line,
.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.queue-line strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.resource-row {
  color: var(--blue);
  font-size: 13px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 25px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--mint);
  color: #244234;
  font-size: 12px;
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-chip.risk {
  background: #ffe4c8;
  color: #8a3c0f;
}

.status-chip.blocked {
  background: #f6d6d2;
  color: var(--danger);
}

.record-body,
.action-body {
  padding: 18px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.timeline span {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  color: rgba(37, 36, 34, 0.58);
  background: #fffaf0;
  text-align: center;
  overflow-wrap: anywhere;
}

.timeline .is-current {
  color: var(--paper);
  background: var(--blue);
  border-color: var(--blue);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 18px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.record-grid div {
  min-width: 0;
  padding: 13px;
  background: #fffaf0;
}

dt {
  color: rgba(37, 36, 34, 0.58);
  font-size: 12px;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.finance-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 20px;
}

.finance-line i {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--paid), #eadfcd var(--paid));
}

.subsection {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.subsection + .subsection {
  margin-top: 18px;
}

.doc-list,
.notes {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.doc-list span,
.notes p,
.next-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.doc-list b,
.doc-list em,
.notes small {
  display: block;
  font-style: normal;
}

.doc-list em,
.notes small {
  color: rgba(37, 36, 34, 0.58);
  font-size: 12px;
}

.action-body {
  display: grid;
  gap: 12px;
}

.next-card strong {
  display: block;
  margin: 5px 0;
  font-size: 18px;
  line-height: 1.25;
}

.ghost-action {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--ink);
  padding: 10px 12px;
}

.note-box {
  display: grid;
  gap: 7px;
  color: rgba(37, 36, 34, 0.7);
  font-size: 13px;
}

.empty,
.error {
  padding: 14px;
  color: rgba(37, 36, 34, 0.62);
}

.error {
  color: var(--danger);
}

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

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

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  #searchInput {
    max-width: none;
  }

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