/* Trading desk: calm, dense, informational. Light by default, dark as a switch. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #d9dce2;
  --accent: #b4531f;
  --danger: #a3242b;
  --row-height: 72px;
  --gap: 12px;
}

[data-theme="dark"] {
  --bg: #101216;
  --card: #181b21;
  --ink: #e7e9ee;
  --muted: #9aa1ad;
  --line: #2a2f38;
  --accent: #e08a4a;
  --danger: #e2686f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

button, input, select {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }

.shell-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.shell-bar-right { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 600; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

.settings { position: relative; }
.settings > summary { list-style: none; cursor: pointer; font-size: 18px; padding: 0 6px; }
.settings > summary::-webkit-details-marker { display: none; }

.settings-panel {
  position: absolute;
  right: 0;
  top: 28px;
  z-index: 20;
  display: grid;
  gap: 8px;
  min-width: 200px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.settings-who { margin: 0; color: var(--muted); }

.page { padding: 16px; }
.page h1 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }

.dashboard-list { display: grid; gap: 8px; padding: 0; margin: 0 0 16px; list-style: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.dashboard-list .card { display: flex; justify-content: space-between; gap: 12px; }
.new-dashboard { display: flex; gap: 8px; align-items: center; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: var(--row-height);
  gap: var(--gap);
}

.widget {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.widget-tools { display: none; gap: 4px; }
.widget-body { flex: 1; padding: 10px; overflow: auto; }
.widget-placeholder { color: var(--muted); margin: 0; }

/* Nothing drags at rest: the handles exist only in edit mode. */
.grid.editing .widget { border-style: dashed; }
.grid.editing .widget-head { cursor: grab; }
.grid.editing .widget-tools { display: flex; }
.grid.editing .widget.dragging { opacity: 0.75; cursor: grabbing; }

.widget-resize {
  display: none;
  align-self: flex-end;
  width: 16px;
  height: 16px;
  margin: 0 2px 2px 0;
  cursor: nwse-resize;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}

.grid.editing .widget-resize { display: block; }

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  min-width: 320px;
}

dialog h2 { font-size: 15px; margin: 0 0 10px; }
dialog ul { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 12px 0 0; }
.settings-field { display: grid; gap: 4px; margin-bottom: 10px; }
.settings-field .help { color: var(--muted); font-size: 12px; }

/* The live orders-by-status bar. Segments animate their width, because
   movement between statuses is the thing worth seeing — no other theatre. */
.status-bar { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.status-bar-title { margin: 0; font-weight: 600; }

.status-bar-track {
  display: flex;
  width: 100%;
  height: 22px;
  /* A long legend must not squash the bar: the bar is the widget. */
  flex: none;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

/* One colour rule: a segment and its legend swatch are the same status. */
.status-bar-segment, .status-bar-legend li::before {
  background: hsl(var(--segment-hue, 24) 55% 48%);
}

.status-bar-segment {
  height: 100%;
  min-width: 0;
  transition: width 600ms ease;
}

/* A read that failed: the numbers are the last true ones, said quietly. */
.status-bar-track.stale { opacity: 0.55; }

.status-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.status-bar-legend li { display: flex; align-items: center; gap: 6px; }

.status-bar-legend li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.status-bar-count { color: var(--ink); font-weight: 600; }
.status-bar-note { margin: auto 0 0; color: var(--muted); font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .status-bar-segment { transition: none; }
}
/* ^ #28 left that block open, so every feed rule below it was reduced-motion
   only. Closed here, with the feeds' own ticket's rules finally applying. */

/* The feeds: a tight log. No slide-in theatre — a line appears, and the eye
   finds it because the numbers moved, not because the page did. */
.feed { list-style: none; margin: 0; padding: 0; }

.feed-line {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "at number customer amount" ". status status status";
  gap: 0 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.feed-line:last-child { border-bottom: 0; }
.feed-at { grid-area: at; color: var(--muted); }
.feed-number { grid-area: number; font-weight: 600; }

.feed-customer {
  grid-area: customer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.feed-amount { grid-area: amount; text-align: right; }

.feed-status {
  grid-area: status;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Out of touch with the server. Said once, quietly, rather than every widget
   pretending its numbers are still live. */
[data-stream="closed"] .brand::after {
  content: " \00b7 reconnecting";
  font-weight: 400;
  color: var(--muted);
}

/* A folded burst: twenty orders in a second, read as one thing. The count is
   the accent, because "20 orders" is the number the eye is looking for. */
.feed-line.burst .feed-number { color: var(--accent); }

/* The unmute. Muted is the loud state on purpose: a wall nobody can hear
   should look like it, so that somebody fixes it. */
.sound-toggle { white-space: nowrap; }
[data-sound="muted"] .sound-toggle { border-color: var(--accent); color: var(--accent); }

.settings-heading {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sound-settings { display: grid; gap: 6px; }
.sound-voice { display: flex; align-items: center; gap: 8px; }
.sound-voice input { width: auto; margin: 0; }
