:root {
  color-scheme: light;
  --canvas: #f7f8fb;
  --surface: #fff;
  --raised: #f0f2f7;
  --line: #e0e4ed;
  --text: #202338;
  --muted: #596078;
  --accent: #4947b8;
  --accent-fill: #5150c8;
  --selected: #eeedff;
  --danger: #a23535;
  --good: #17684d;
  --warn: #85521b;
  --shadow: 0 1px 2px rgb(22 27 50 / 6%);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--canvas);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #15161e;
  --surface: #1d1f2a;
  --raised: #272a38;
  --line: #343749;
  --text: #eef0fa;
  --muted: #aeb4cb;
  --accent: #b7b5ff;
  --accent-fill: #5854ca;
  --selected: #2e2c48;
  --danger: #ffb1ab;
  --good: #89d9b8;
  --warn: #f0c181;
  --shadow: 0 1px 2px rgb(0 0 0 / 16%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
.lucide {
  display: inline-block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
button .lucide:not(:only-child) { margin-right: 5px; }
button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 11px;
  font-weight: 550;
}
button:hover:not(:disabled) { background: var(--raised); }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary, .primary:hover:not(:disabled) { background: var(--accent-fill); color: #fff; border-color: transparent; }
.quiet, .icon-button { background: transparent; border-color: transparent; }
.icon-button { height: 34px; min-width: 34px; padding: 4px; font-size: 16px; }
.icon-button .lucide { width: 17px; height: 17px; }
a { color: var(--accent); }
p { line-height: 1.5; }
h1, h2, h3 { letter-spacing: -.025em; }
h1 { margin: 0; font-size: 1.25rem; line-height: 1.35; }
h2 { margin: 0 0 11px; font-size: 1.14rem; }
h3 { margin: 0 0 9px; font-size: .99rem; }
small, .muted, .section-label { color: var(--muted); }
.error, #notice { color: var(--danger); }
#notice { margin: 0; padding: 9px 18px; background: var(--surface); }
#notice:empty { display: none; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 196px minmax(0, 1fr); }
.shell.rail-collapsed { grid-template-columns: 58px minmax(0, 1fr); }
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 10px 12px;
  border-right: 1px solid var(--line);
  background: var(--canvas);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; padding: 2px 3px; }
.mark {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-fill);
  color: #fff;
  font-size: .74rem;
  font-weight: 760;
}
nav { display: grid; gap: 4px; }
nav button, .identity button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 35px;
  text-align: left;
  white-space: nowrap;
  background: transparent;
  border-color: transparent;
}
.nav-icon { width: 15px; text-align: center; color: var(--muted); font-size: 1.08rem; }
nav button[aria-current] { background: var(--selected); color: var(--accent); }
nav button[aria-current] .nav-icon { color: inherit; }
.identity { margin-top: auto; display: grid; gap: 7px; color: var(--muted); }
.identity > span { overflow: hidden; text-overflow: ellipsis; padding-inline: 8px; }
.rail-collapsed .rail :is(.nav-label, .brand strong, #account) { display: none; }
.workspace { min-width: 0; }
.topbar {
  min-height: 63px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar p { margin: 0; color: var(--muted); font-size: .78rem; }
#theme { margin-left: auto; }
#content { min-width: 0; padding: 18px clamp(14px, 2vw, 28px); }
#content:has(.order-workspace) { padding: 0; }

.card {
  padding: 15px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.card p:last-child { margin-bottom: 0; }
.card details, details.card > :not(summary) { margin-top: 9px; }
.row, .actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.stack { display: grid; gap: 10px; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.scroll { overflow: auto; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.table th { color: var(--muted); font-weight: 600; overflow-wrap: normal; }
.table tbody tr:last-child td { border-bottom: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; }
input:not([type=checkbox]), select, textarea {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
textarea { min-height: 66px; resize: vertical; }
.check { display: flex; align-items: center; gap: 7px; }
input[type=checkbox] { accent-color: var(--accent); }
.signin {
  width: min(390px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: 25px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.signin h1 { margin: 20px 0 15px; }
.signin form { display: grid; gap: 13px; }
pre, .ellipsis { white-space: pre-wrap; overflow-wrap: anywhere; }

.order-workspace {
  --queue-width: 276px;
  --details-width: 304px;
  display: grid;
  grid-template-columns: minmax(220px, var(--queue-width)) 1px minmax(210px, 1fr) 1px minmax(246px, var(--details-width));
  height: calc(100dvh - 63px);
  background: var(--surface);
}
.order-workspace.details-collapsed { grid-template-columns: minmax(220px, var(--queue-width)) 1px minmax(210px, 1fr); }
.order-workspace:not(.has-selection) { grid-template-columns: minmax(220px, var(--queue-width)) 1px minmax(210px, 1fr); }
.pane { min-width: 0; min-height: 0; overflow: auto; }
.pane-queue { display: flex; flex-direction: column; }
.queue-toolbar { padding: 11px 12px 9px; border-bottom: 1px solid var(--line); }
.queue-tools { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 6px; }
.queue-tools .icon-button { height: auto; }
.search-control { position: relative; }
.search-control > .lucide { position: absolute; top: 50%; left: 9px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-control input { padding-left: 32px; }
.queue-tabs { display: flex; gap: 3px; margin-top: 8px; }
.queue-tabs button { font-size: .83rem; padding: 5px 8px; }
.queue-tabs button[aria-pressed="true"] { color: var(--accent); background: var(--selected); }
.order-rows { flex: 1; overflow: auto; padding: 5px 6px; }
.order-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  width: 100%;
  align-items: start;
  gap: 9px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  text-align: left;
  padding: 8px 6px;
}
.order-row[aria-current="true"] { border-color: var(--line); background: var(--selected); }
.order-row:focus-visible { outline-offset: -2px; }
.order-emblem {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--raised);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 720;
}
.order-emblem img { position: absolute; inset: 0; width: 32px; height: 32px; object-fit: cover; background: var(--raised); opacity: 0; }
.order-emblem.has-artwork img { opacity: 1; }
.order-product, .catalog-product, .artwork-preview { display: flex; align-items: center; gap: 9px; }
.artwork-preview:empty { display: none; }
.order-product { margin-bottom: 8px; }
.order-product h2 { margin: 0; }
.catalog-product { min-width: 180px; }
.artwork-editor { margin-top: 8px; }
.artwork-editor > div { margin-top: 10px; }
.order-row-main { display: grid; gap: 4px; min-width: 0; }
.order-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.order-row-meta time { color: var(--muted); font-size: .79rem; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; font-size: .78rem; color: var(--muted); }
.tag::before { content: ""; display: inline-block; margin-right: 6px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-green { color: var(--good); }
.tag-amber { color: var(--warn); }
.tag-red { color: var(--danger); }
.tag-blue { color: var(--accent); }
.queue-pages { display: flex; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--line); }
.queue-pages:empty { display: none; }
.queue-pages button { font-size: .83rem; padding: 4px 8px; }
.pane-center { background: var(--canvas); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 15px; border-bottom: 1px solid var(--line); background: var(--surface); }
.pane-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-head strong { flex: 1; }
.pane-head button { font-size: .84rem; white-space: nowrap; }
.pane-body { padding: 15px; display: grid; gap: 16px; }
.pane-detail { background: var(--surface); }
.detail-sheet { padding: 15px; display: grid; gap: 16px; }
.detail-sheet > section + section { padding-top: 14px; border-top: 1px solid var(--line); }
.detail-sheet dl { display: grid; gap: 9px; margin: 0; }
.detail-sheet dt { color: var(--muted); font-size: .84rem; }
.detail-sheet dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.detail-sheet details > * { margin-top: 8px; }
.detail-sheet summary { color: var(--accent); }
.divider {
  position: relative;
  z-index: 1;
  background: var(--line);
  cursor: col-resize;
  touch-action: none;
}
.divider::after { content: ""; position: absolute; inset: 0 -3px; }
.divider:hover, .divider:focus-visible { background: var(--accent); }
.empty { padding: 23px 15px; color: var(--muted); margin: 0; }
.pane-center > .empty { margin: clamp(24px, 15vh, 130px) auto 0; max-width: 320px; text-align: center; }
.messages { display: grid; gap: 8px; overflow: auto; max-height: 380px; }
.message {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.message + .message { margin-top: 4px; }
.message strong { font-size: .83rem; }
.message small { display: block; margin-bottom: 4px; }
.note-form { display: grid; gap: 8px; }
.note-form button { justify-self: start; }
.mobile-back, .queue-collapse { display: none; }
.no-activity .pane-head { background: var(--surface); }
.no-activity .pane-center { padding-bottom: 0; }
.no-activity { grid-template-columns: minmax(220px, var(--queue-width)) 1px minmax(0, 1fr); }
.no-activity .pane-detail { grid-column: 3; }
.work-alerts { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.work-alerts p { margin: 6px 0 0; }

@media (min-width: 1121px) {
  .queue-collapse { display: inline-block; }
  .order-workspace.queue-collapsed { grid-template-columns: minmax(0, 1fr) 1px minmax(246px, var(--details-width)); }
  .order-workspace.queue-collapsed.details-collapsed,
  .order-workspace.queue-collapsed.no-activity { grid-template-columns: minmax(0, 1fr); }
  .queue-collapsed :is(.pane-queue, .queue-divider) { display: none; }
  .queue-collapsed.no-activity .pane-detail { grid-column: 1; }
}
@media (max-width: 1120px) {
  .shell { grid-template-columns: 158px minmax(0, 1fr); }
  .order-workspace, .order-workspace.details-collapsed, .order-workspace:not(.has-selection) {
    grid-template-columns: minmax(200px, 34%) minmax(0, 1fr);
    height: auto;
    min-height: calc(100dvh - 63px);
    grid-template-rows: auto 1fr;
    align-content: start;
  }
  .pane-queue { grid-column: 1; grid-row: 1 / span 2; border-right: 1px solid var(--line); }
  .order-rows { max-height: calc(100dvh - 190px); }
  .pane-center { grid-column: 2; }
  .pane-detail, .no-activity .pane-detail { grid-column: 2; border-top: 1px solid var(--line); }
  .divider { display: none; }
}
@media (max-width: 730px) {
  .shell { grid-template-columns: 54px minmax(0, 1fr); }
  .shell.rail-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .rail { padding-inline: 8px; }
  .rail :is(.nav-label, .brand strong, #account) { display: none; }
  .rail-collapsed .rail { visibility: hidden; }
  .order-workspace, .order-workspace.details-collapsed, .order-workspace:not(.has-selection) { display: block; }
  .order-workspace.has-selection .pane-queue, .order-workspace:not(.has-selection) .pane-center { display: none; }
  .pane-center, .pane-detail { overflow: visible; }
  .pane-head { flex-wrap: wrap; }
  .pane-head strong { flex: 1 0 100%; order: 2; }
  .mobile-back { display: inline-block; }
  .topbar { padding-inline: 10px; }
  #content { padding: 13px; }
  .message { padding: 8px; }
}
