:root {
  --ink: #101828;
  --muted: #667085;
  --line: #d0d5dd;
  --panel: #ffffff;
  --page: #f4f6f8;
  --brand: #c5303b;
  --good: #087443;
  --warn: #b54708;
  --bad: #b42318;
  --blue: #175cd3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  color: #fff;
  background: #071221;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 750;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.sort-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 0.55fr);
  gap: 8px;
  width: min(100%, 260px);
  margin-top: 8px;
}

.sort-controls select {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.topbar p {
  color: #cbd5e1;
  margin-top: 4px;
}

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.band {
  margin-bottom: 28px;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.search-sidebar {
  min-width: 0;
  position: sticky;
  top: 16px;
}

.search-list {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin-top: 8px;
}

.search-month-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.search-month-divider::after {
  content: "";
  flex: 1 1 auto;
  border-top: 1px solid var(--line);
}

.search-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  background: var(--panel);
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

.search-item:hover,
.search-item.active {
  border-color: var(--blue);
  color: var(--ink);
}

.search-item.active {
  box-shadow: inset 3px 0 0 var(--blue), 0 1px 2px rgb(16 24 40 / 6%);
}

.search-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.search-item-head strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-head > span {
  flex: 0 0 auto;
}

.search-route {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-compact-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}

.search-compact-meta > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-compact-meta strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-prices {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.search-prices > span {
  display: grid;
  gap: 2px;
}

.search-card-timing {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-card {
  gap: 8px;
  padding: 12px;
  background: #f9f9f9;
}

.search-item-card .search-item-head strong {
  font-size: 14px;
}

.search-item-card .search-prices strong {
  font-weight: 750;
}

.status-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
}

.status-icon.success {
  background: var(--good);
}

.status-icon.win {
  background: var(--good);
}

.status-icon.failure,
.status-icon.error {
  background: var(--bad);
}

.status-icon.warning {
  background: var(--warn);
}

.status-icon.success::after {
  content: "";
  width: 8px;
  height: 4px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: translateY(-1px) rotate(-45deg);
}

.status-icon.win::after {
  content: "$";
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.status-icon.failure::after,
.status-icon.error::after,
.status-icon.warning::after {
  content: "!";
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.status-icon.never::after,
.status-icon.info::after {
  content: "i";
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.workspace {
  min-width: 0;
}

.selected-card {
  margin-bottom: 20px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--panel);
  color: var(--muted);
}

.mode-banner {
  border: 1px solid #fdb022;
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #fffaeb;
  color: #7a2e0e;
  font-weight: 650;
}

.section-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.section-head {
  min-width: 0;
  margin-bottom: 0;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  min-width: 0;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  background: #eef4ff;
  color: var(--blue);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

button.active {
  border-color: var(--blue);
  background: #eef4ff;
  color: var(--blue);
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

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

.wide-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 10px;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check input {
  width: auto;
  min-height: auto;
}

.check span {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.left {
  justify-content: flex-start;
  margin-top: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.run-progress-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 13px;
}

.run-notice {
  display: grid;
  gap: 2px;
  margin-top: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.run-notice.success {
  border: 1px solid #abefc6;
  background: #ecfdf3;
  color: var(--good);
}

.run-notice.failure,
.run-notice.error {
  border: 1px solid #fecdca;
  background: #fee4e2;
  color: #912018;
}

.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  overflow-x: auto;
}

.chart-panel svg {
  width: 100%;
  min-width: 520px;
  height: 210px;
}

.chart-value {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.card,
.row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}

.card {
  padding: 16px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

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

.metric {
  border: 1px solid #eaecf0;
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
}

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

.value {
  font-size: 16px;
  font-weight: 750;
  word-break: break-word;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 750;
  background: #eef4ff;
  color: var(--blue);
}

.status.success {
  background: #ecfdf3;
  color: var(--good);
}

.status.win {
  background: #ecfdf3;
  color: var(--good);
}

.status.archived {
  background: #f2f4f7;
  color: var(--muted);
}

.status.failure,
.status.error {
  border: 1px solid #fecdca;
  background: #fee4e2;
  color: #912018;
}

.status.warning {
  background: #fffaeb;
  color: var(--warn);
}

.status.mock {
  background: #f4f3ff;
  color: #5925dc;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

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

.row {
  padding: 12px;
}

.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.failure-summary {
  margin-top: 10px;
  color: #912018;
  font-size: 13px;
  font-weight: 700;
}

.error-details {
  box-sizing: border-box;
  width: 100%;
  height: 112px;
  margin-top: 8px;
  resize: vertical;
  border: 1px solid #fecdca;
  border-radius: 6px;
  background: #fffbfa;
  color: #667085;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.win-summary {
  margin-top: 10px;
  color: var(--good);
  font-size: 13px;
  font-weight: 700;
}

.scratchpad {
  border-top: 1px solid #eaecf0;
  margin-top: 14px;
  padding-top: 14px;
}

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

.scratchpad h4 {
  margin: 0;
  font-size: 14px;
}

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

.note-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.note-compose textarea {
  min-height: 72px;
  resize: vertical;
}

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

.note-item {
  border: 1px solid #eaecf0;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcfd;
}

.note-item strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.note-item p {
  white-space: pre-wrap;
}

.win-note {
  border-color: #abefc6;
  background: #ecfdf3;
}

.note-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-actions button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.row-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.row-links a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.row-links a:hover {
  text-decoration: underline;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pager button {
  min-height: 32px;
  padding: 0 10px;
}

.pager button:disabled {
  cursor: default;
  opacity: 0.5;
}

@media (max-width: 1200px) {
  .meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .two-col,
  .dashboard-shell {
    grid-template-columns: 1fr;
    display: grid;
  }

  .search-sidebar {
    position: static;
  }

  main {
    padding: 16px;
  }

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

  .inline-form {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
  }
}
