:root {
  --charcoal: #17110f;
  --text-light: #f8fafc;
  --paper: #11100f;
  --ink: #f8fafc;
  --muted: #aab2c0;
  --line: rgba(248, 250, 252, 0.16);
  --light-line: rgba(248, 250, 252, 0.16);
  --tomato: #d85d36;
  --fire: #f29b3d;
  --olive: #657b4e;
  --basil: #86a15c;
  --steel: #376173;
  --wine: #7f2d2d;
  --shadow: 0 24px 54px rgba(0, 0, 0, 0.32);
  --soft-shadow: 0 14px 32px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
html,
body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  background:
    linear-gradient(115deg, rgba(216, 93, 54, 0.26), transparent 34%),
    linear-gradient(245deg, rgba(101, 123, 78, 0.22), transparent 36%),
    linear-gradient(180deg, var(--charcoal) 0%, #0f0c0b 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background:
    linear-gradient(90deg, transparent 0 17px, rgba(255,255,255,0.08) 18px, transparent 19px),
    linear-gradient(0deg, transparent 0 17px, rgba(255,255,255,0.06) 18px, transparent 19px);
  background-size: 96px 96px;
  mask-image: linear-gradient(180deg, black, transparent 82%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.35);
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.shell {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.login-view {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 22px;
}
.login-card {
  width: min(470px, 100%);
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid rgba(248, 250, 252, 0.18);
  border-radius: 8px;
  color: var(--text-light);
  background:
    linear-gradient(180deg, rgba(36, 24, 21, 0.88), rgba(23, 17, 15, 0.96)),
    url("https://thedoughlab.eu/wp-content/uploads/2025/12/kep-5.1-1024x1024.png") center/cover no-repeat;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.brand-logo {
  display: block;
  width: min(214px, 50vw);
  height: auto;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
}
.login-card .brand-logo { width: min(250px, 68vw); }
.brand-context {
  color: rgba(248, 250, 252, 0.74);
  font-size: 13px;
  font-weight: 900;
}
.brand-lockup strong { display: block; font-size: 18px; line-height: 1; }
.brand-lockup span:last-child { color: rgba(248, 250, 252, 0.74); font-size: 13px; }
.login-copy { display: grid; gap: 8px; padding: 20px 0 4px; }
.login-copy h1 { font-size: clamp(38px, 8vw, 62px); line-height: 0.96; }
.login-copy p:last-child, .auth-message { color: rgba(248, 250, 252,0.78); }
.auth-message.error { color: #ffd0c2; }

.eyebrow {
  color: var(--tomato);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 900;
}
input, select, textarea {
  width: 100%;
  min-height: 56px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,0.08);
  outline: none;
}
textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.35;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(216, 93, 54, 0.62);
  box-shadow: 0 0 0 4px rgba(216, 93, 54, 0.16);
}

.primary-button, .secondary-button, .ghost-button {
  min-height: 54px;
  border-radius: 8px;
  font-weight: 900;
  border: 1px solid transparent;
}
.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--tomato), var(--fire));
  box-shadow: 0 14px 28px rgba(216, 93, 54, 0.28);
}
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: var(--text-light);
  background: rgba(248, 250, 252, 0.08);
  border-color: rgba(248, 250, 252, 0.18);
}
.secondary-button {
  color: #fff;
  background:
    linear-gradient(180deg, rgba(248,250,252,0.16), rgba(248,250,252,0.075)),
    rgba(24, 23, 23, 0.82);
  border-color: rgba(248,250,252,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

#saveOrderChangesButton {
  min-height: 50px;
  background: linear-gradient(135deg, rgba(216,93,54,0.92), rgba(242,155,61,0.88));
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 14px 32px rgba(216,93,54,0.24);
}

.app-view {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
  padding: 14px;
}
.topbar {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--light-line);
  border-radius: 8px;
  color: var(--text-light);
  background: rgba(23, 17, 15, 0.82);
  backdrop-filter: blur(20px);
}
.station-pill, .top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.station-pill {
  justify-self: center;
  width: 18px;
  height: 18px;
}
.top-actions { justify-self: end; }
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--basil);
  box-shadow: 0 0 0 5px rgba(134, 161, 92, 0.18);
}

.workspace {
  min-height: 0;
  display: grid;
}
.stage-home, .list-panel, .detail-panel {
  min-height: 0;
  color: var(--ink);
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-content: stretch;
  min-height: 100%;
}
.stage-button {
  position: relative;
  min-height: 250px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 20px;
  overflow: hidden;
  text-align: left;
  color: var(--text-light);
  border: 1px solid rgba(248, 250, 252,0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(248, 250, 252,0.09), rgba(248, 250, 252,0.03));
  box-shadow: var(--soft-shadow);
  transition: transform 140ms ease, border-color 140ms ease;
}
.stage-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(216, 93, 54, 0.34), transparent 62%);
}
.stage-button:nth-child(2)::before { background: linear-gradient(135deg, rgba(242, 155, 61, 0.32), transparent 62%); }
.stage-button:nth-child(3)::before { background: linear-gradient(135deg, rgba(127, 45, 45, 0.34), transparent 62%); }
.stage-button:nth-child(4)::before { background: linear-gradient(135deg, rgba(101, 123, 78, 0.32), transparent 62%); }
.stage-button:nth-child(5)::before { background: linear-gradient(135deg, rgba(55, 97, 115, 0.34), transparent 62%); }
.stage-button:nth-child(6)::before { background: linear-gradient(135deg, rgba(134, 161, 92, 0.34), transparent 62%); }
.stage-button:hover {
  transform: translateY(-3px);
  border-color: rgba(248, 250, 252,0.34);
}
.stage-button > * { position: relative; }
.stage-index {
  width: max-content;
  padding: 6px 9px;
  border-radius: 8px;
  color: #fff;
  background: rgba(248, 250, 252,0.13);
  font-weight: 900;
}
.stage-button strong {
  max-width: 360px;
  font-size: clamp(36px, 5vw, 70px);
  line-height: 0.92;
}
.stage-button > span:last-child {
  justify-self: end;
  align-self: end;
  color: #fff;
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 900;
  line-height: 0.8;
}

.list-panel, .detail-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(248, 250, 252,0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(23, 17, 15, 0.96), rgba(15, 12, 11, 0.98));
  box-shadow: var(--shadow);
}
.list-panel {
  grid-template-rows: auto minmax(0, 1fr);
}
.detail-panel {
  overflow: auto;
}
.section-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}
.section-header h2 {
  margin-top: 6px;
  font-size: clamp(38px, 5vw, 70px);
  line-height: 0.92;
}
.back-button {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--tomato), var(--fire));
  font-size: 30px;
  font-weight: 900;
}
.count-pill {
  min-width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: var(--tomato);
  font-size: 24px;
  font-weight: 900;
}

.card-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  align-content: start;
}
.list-card {
  width: 100%;
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 8px solid var(--tomato);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,0.08);
  box-shadow: var(--soft-shadow);
}
.list-card:nth-child(2n) { border-left-color: var(--olive); }
.list-card:nth-child(3n) { border-left-color: var(--fire); }
.list-card.active {
  border-color: rgba(216, 93, 54, 0.45);
  border-left-color: var(--tomato);
  box-shadow: 0 0 0 3px rgba(216, 93, 54, 0.18), var(--soft-shadow);
}
.list-card h3 { font-size: clamp(26px, 3vw, 42px); line-height: 0.98; }
.card-top, .compact-line, .panel-head, .shelf-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.compact-button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
}
.compact-line { flex-wrap: wrap; color: var(--muted); font-weight: 900; }
.muted-block, .shelf-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.status-pill, .risk-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.status-pill { background: var(--steel); }
.risk-pill.low { background: var(--olive); }
.risk-pill.high { background: var(--tomato); }

.empty-state, .detail-header, .detail-view, .detail-form, .metric-grid, .shelf-list, .item-list {
  display: grid;
  gap: 12px;
}
.empty-state {
  min-height: 280px;
  align-content: center;
}
.empty-state h2, .detail-header h2 {
  font-size: clamp(34px, 5vw, 70px);
  line-height: 0.92;
}
.detail-header p:last-child, .empty-state p:last-child {
  color: var(--muted);
  font-weight: 800;
}
.metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.metric-card {
  min-height: 100px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}
.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.metric-card strong {
  font-size: 24px;
  line-height: 1;
}
.metric-card.accent {
  color: #fff;
  background: linear-gradient(135deg, var(--tomato), var(--fire));
}
.metric-card.accent span { color: rgba(255,255,255,0.82); }

.action-panel, .item-row, .shelf-row, .empty-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}
.create-email-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  align-items: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(248,250,252,0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248,250,252,0.1), rgba(248,250,252,0.045)),
    rgba(15, 12, 11, 0.58);
  box-shadow: 0 14px 34px rgba(0,0,0,0.14);
}
.create-email-head {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.create-email-card label:nth-of-type(2),
.create-email-card label:nth-of-type(3),
.create-email-card .checkbox-row {
  grid-column: 1 / -1;
}
.create-email-card strong {
  color: var(--text-light);
  font-size: 14px;
}
.create-email-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.create-email-card label {
  gap: 6px;
  min-width: 0;
  color: rgba(248,250,252,0.78);
  font-size: 12px;
}
.create-email-card input,
.create-email-card select {
  min-height: 44px;
  padding: 9px 11px;
}
.create-email-card textarea {
  min-height: 176px;
  padding: 12px;
  line-height: 1.48;
}
.action-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  box-shadow: var(--soft-shadow);
}
.action-form { border-top: 8px solid var(--tomato); }
.action-panel.secondary {
  background: rgba(255,255,255,0.66);
  box-shadow: none;
}
.email-panel {
  gap: 12px;
  border-color: rgba(248,250,252,0.14);
  background:
    linear-gradient(180deg, rgba(248,250,252,0.08), rgba(248,250,252,0.04)),
    rgba(15, 12, 11, 0.56);
}
.panel-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.email-thread {
  display: grid;
  gap: 10px;
  max-height: 290px;
  overscroll-behavior: contain;
  overflow: auto;
  padding-right: 2px;
}
.email-composer {
  display: grid;
  grid-template-columns: minmax(148px, 190px) minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background: rgba(248,250,252,0.055);
}
.email-composer label {
  min-width: 0;
  color: rgba(248,250,252,0.76);
  font-size: 12px;
}
.email-composer input,
.email-composer select {
  min-height: 44px;
  padding: 9px 11px;
}
.email-composer textarea {
  min-height: 190px;
  padding: 12px;
  line-height: 1.48;
}
.email-composer label:last-child {
  grid-column: 1 / -1;
}
.email-message {
  display: grid;
  gap: 7px;
  padding: 12px 13px;
  border: 1px solid rgba(248,250,252,0.14);
  border-radius: 8px;
  background: rgba(248,250,252,0.075);
}
.email-message.inbound {
  border-color: rgba(134,161,92,0.3);
  background: rgba(134,161,92,0.12);
}
.email-message.outbound {
  border-color: rgba(216,93,54,0.3);
  background: rgba(216,93,54,0.11);
}
.email-message-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.email-subject {
  color: var(--text-light);
  font-size: 16px;
  font-weight: 900;
}
.email-meta, .email-message p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}
.email-message p {
  max-height: 220px;
  overflow: auto;
}
.email-error {
  padding: 8px 10px;
  border-radius: 8px;
  color: #ffd0c2;
  background: rgba(127, 45, 45, 0.28);
  font-size: 13px;
  font-weight: 900;
}
.ekaer-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  border-left: 8px solid var(--steel);
  background: rgba(255,255,255,0.08);
}
.ekaer-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.ekaer-card strong {
  font-size: 22px;
}
.ekaer-card p {
  color: var(--muted);
  font-weight: 800;
}
.ekaer-card code {
  width: max-content;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 17, 15, 0.9);
  font-weight: 900;
  overflow-wrap: anywhere;
}
.ekaer-card.ok { border-left-color: var(--olive); }
.ekaer-card.warning { border-left-color: var(--fire); }
.ekaer-card.error { border-left-color: var(--wine); }
.ekaer-card.neutral { border-left-color: var(--steel); }
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input {
  width: 20px;
  min-height: 20px;
}
.item-row, .shelf-row, .empty-card {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 17, 15, 0.96);
  box-shadow: var(--shadow);
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }
  .station-pill {
    grid-column: 1 / -1;
    justify-self: center;
    order: 3;
  }
  .stage-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stage-button { min-height: 210px; }
}

@media (max-width: 680px) {
  .app-view { padding: 10px; }
  .topbar, .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .stage-list, .metric-grid, .split {
    grid-template-columns: 1fr;
  }
  .create-email-card, .email-composer {
    grid-template-columns: 1fr;
  }
  .stage-button {
    min-height: 150px;
  }
  .section-header {
    grid-template-columns: auto 1fr;
  }
  .count-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.command-center-view {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.command-order-queue,
.active-order-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 10px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgba(248, 250, 252, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035)),
    rgba(13, 12, 12, 0.76);
  box-shadow:
    0 22px 58px rgba(0,0,0,0.24),
    inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(22px) saturate(1.12);
}

.active-order-workspace.shortage-focus {
  grid-template-columns: minmax(0, 0.85fr) minmax(500px, 0.55fr);
  grid-template-rows: auto auto;
  align-content: start;
}

.active-order-workspace.shortage-focus .order-email-room,
.active-order-workspace.shortage-focus .order-editor {
  align-self: start;
}

.active-order-workspace.shortage-focus .order-email-room {
  grid-template-rows: auto auto;
}

.active-order-workspace.shortage-focus .command-email-thread {
  height: auto;
  align-content: start;
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
}

.command-order-queue {
  grid-template-rows: auto minmax(0, 1fr);
}

.active-order-workspace {
  grid-template-areas:
    "bar bar"
    "mail inspector";
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  grid-template-rows: auto minmax(0, 1fr);
  padding: 10px;
  background:
    linear-gradient(145deg, rgba(248,250,252,0.095), rgba(248,250,252,0.03)),
    rgba(11, 10, 10, 0.78);
}

.active-order-workspace.email-focus {
  grid-template-areas:
    "bar"
    "mail";
  grid-template-columns: minmax(0, 1fr);
}

.active-order-workspace.email-focus .order-editor {
  display: none;
}

.active-order-workspace.details-focus:not(.shortage-focus) {
  grid-template-areas:
    "bar"
    "inspector";
  grid-template-columns: minmax(0, 1fr);
}

.active-order-workspace.details-focus:not(.shortage-focus) .order-email-room {
  display: none;
}

.active-order-workspace.details-focus:not(.shortage-focus) .order-editor {
  display: grid;
  max-width: 720px;
  justify-self: center;
  width: 100%;
}

.active-workspace-bar {
  grid-area: bar;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(248,250,252,0.1);
  border-radius: 8px;
  background: rgba(248,250,252,0.045);
}

.active-workspace-bar > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.active-workspace-bar strong {
  color: #fff;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.command-view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background: rgba(248,250,252,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.command-view-tab {
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  color: rgba(248,250,252,0.68);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.command-view-tab:hover {
  color: #fff;
  background: rgba(248,250,252,0.08);
  transform: translateY(-1px);
}

.command-view-tab.active {
  color: #17110f;
  background: rgba(248,250,252,0.92);
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}

.command-view-tab:disabled {
  color: rgba(248,250,252,0.34);
  background: transparent;
  box-shadow: none;
  transform: none;
}

.order-email-room {
  grid-area: mail;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 9px;
  overflow: hidden;
  grid-template-areas:
    "head"
    "thread"
    "composer";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 10px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04)),
    rgba(10, 10, 11, 0.42);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.order-editor {
  grid-area: inspector;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.045)),
    rgba(18, 17, 18, 0.54);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  scrollbar-gutter: stable;
}

.order-editor > .command-panel-head {
  padding: 12px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background: rgba(248,250,252,0.06);
}

.order-editor[hidden] {
  display: none !important;
}

.command-panel-head {
  display: grid;
  gap: 4px;
}

.command-panel-head h2 {
  font-size: 21px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.command-queue-count {
  width: max-content;
  padding: 5px 7px;
  border-radius: 7px;
  color: #fff;
  background: rgba(248,250,252,0.12);
  font-size: 11px;
  font-weight: 900;
}

.command-panel-head p:last-child,
.email-room-head p,
.reply-composer-head span,
.reply-actions span,
.supplier-contact-card span,
.supplier-contact-card em,
.manual-confirm-box p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.command-order-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  overscroll-behavior: contain;
  overflow: auto;
  padding-right: 2px;
}

.command-order-card {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 10px 11px;
  text-align: left;
  color: var(--text-light);
  border: 1px solid rgba(248, 250, 252, 0.11);
  border-left: 3px solid rgba(95, 140, 161, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.032)),
    rgba(13, 13, 14, 0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.command-order-card:hover {
  transform: translateY(-1px);
  border-color: rgba(248,250,252,0.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.105), rgba(255,255,255,0.045)),
    rgba(23, 22, 23, 0.78);
}

.command-order-card.active {
  border-left-color: var(--tomato);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.032)),
    rgba(216, 93, 54, 0.11);
  box-shadow: 0 0 0 2px rgba(216, 93, 54, 0.13);
}

.command-order-card.needs-email {
  border-left-color: #e68a3a;
  background: rgba(230, 138, 58, 0.13);
}

.command-order-card.waiting-reply {
  border-left-color: #d6b252;
  background: rgba(214, 178, 82, 0.12);
}

.command-order-card.needs-confirm {
  border-left-color: #4fb6a3;
  background: rgba(79, 182, 163, 0.14);
}

.command-order-card.problem {
  border-left-color: #d85d36;
  background: rgba(127, 45, 45, 0.2);
}

.command-order-card.shortage-card {
  border-color: rgba(216, 93, 54, 0.26);
  border-left-color: #ff5131;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.072), rgba(255,255,255,0.03)),
    rgba(48, 20, 15, 0.58);
}

.command-order-card.shortage-card em {
  background: #d85d36;
}

.command-order-card.confirmed {
  border-left-color: var(--basil);
}

.command-order-card strong {
  font-size: 13px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.command-order-card span {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.command-order-card em {
  width: max-content;
  max-width: 100%;
  padding: 4px 6px;
  border-radius: 8px;
  color: #fff;
  background: rgba(248,250,252,0.13);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.email-room-head {
  grid-area: head;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 300px) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04)),
    rgba(16,15,15,0.52);
}

.email-room-head h1 {
  margin-top: 2px;
  font-size: clamp(20px, 1.35vw, 26px);
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.supplier-contact-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(248,250,252,0.13);
  border-radius: 8px;
  background: rgba(248,250,252,0.045);
}

.supplier-contact-card strong,
.supplier-contact-card em {
  overflow-wrap: anywhere;
}

.supplier-contact-card strong {
  font-size: 13px;
}

.email-room-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.email-room-actions .compact-button,
.command-order-queue .compact-button {
  min-height: 36px;
}

.command-email-thread {
  grid-area: thread;
  min-height: 0;
  height: 100%;
  display: grid;
  align-content: start;
  gap: 10px;
  overscroll-behavior: contain;
  overflow: auto;
  padding: 18px 20px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248,250,252,0.045), rgba(248,250,252,0.018)),
    rgba(3, 3, 4, 0.46);
  scrollbar-gutter: stable;
}

.command-email-thread .email-message {
  width: min(980px, 76%);
  max-width: 76%;
  box-shadow: 0 16px 34px rgba(0,0,0,0.2);
}

.active-order-workspace.email-focus .order-email-room {
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 9px;
  padding-bottom: 10px;
}

.active-order-workspace.email-focus .email-room-head {
  grid-template-columns: minmax(0, 1fr) minmax(230px, 300px) auto;
  padding: 9px 10px;
}

.active-order-workspace.email-focus .command-email-thread {
  padding: 18px 20px;
}

.active-order-workspace.email-focus .command-email-thread .email-message {
  width: min(980px, 76%);
  max-width: 76%;
  border-radius: 12px;
  padding: 10px 12px;
}

.active-order-workspace.email-focus .command-email-thread .email-message p {
  max-height: none;
  overflow: visible;
}

.command-email-thread .email-message p {
  font-size: 14px;
  line-height: 1.52;
}

.email-message.supplier {
  justify-self: start;
  border-color: rgba(134,161,92,0.34);
  background: rgba(134, 161, 92, 0.13);
}

.email-message.doughlab {
  justify-self: end;
  border-color: rgba(216,93,54,0.34);
  background: rgba(216,93,54,0.12);
}

.reply-composer {
  grid-area: composer;
  min-height: 0;
  display: grid;
  grid-template-areas:
    "head head"
    "fields side"
    "cc side"
    "body side"
    "actions actions";
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  grid-template-rows: auto auto auto minmax(84px, 1fr) auto;
  align-content: start;
  gap: 6px;
  max-height: min(240px, 25vh);
  padding: 9px 10px;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid rgba(248,250,252,0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.105), rgba(255,255,255,0.045)),
    rgba(15, 14, 15, 0.74);
  box-shadow:
    0 18px 44px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.active-order-workspace.email-focus .reply-composer {
  height: 252px;
  min-height: 0;
  max-height: 252px;
  grid-template-areas:
    "head"
    "fields"
    "cc"
    "body"
    "actions";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto 78px auto;
  gap: 5px;
  padding: 10px 12px;
  overflow: hidden;
}

.active-order-workspace.email-focus .reply-composer-head {
  grid-template-columns: minmax(0, 1fr);
}

.active-order-workspace.email-focus .reply-composer-head span {
  display: none;
}

.active-order-workspace.email-focus .composer-focus-strip {
  display: none;
}

.active-order-workspace.email-focus .composer-command-deck {
  display: none;
}

.active-order-workspace.email-focus .composer-field-grid {
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
}

.active-order-workspace.email-focus .composer-field-grid label {
  gap: 4px;
  font-size: 11px;
}

.active-order-workspace.email-focus .composer-body-label {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  font-size: 0;
}

.active-order-workspace.email-focus .reply-composer textarea {
  height: 78px;
  min-height: 78px;
  overflow: auto;
  font-size: 13px;
}

.active-order-workspace.email-focus .reply-actions {
  align-items: end;
  min-height: 36px;
  padding-top: 2px;
}

.active-order-workspace.email-focus .composer-tool-actions .compact-button {
  min-height: 34px;
  padding: 0 11px;
}

.active-order-workspace.email-focus .reply-actions > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-composer-head {
  grid-area: head;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.reply-composer-head > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.composer-focus-strip {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.composer-pill {
  max-width: 220px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(248,250,252,0.14);
  border-radius: 8px;
  color: #fff;
  background: rgba(248,250,252,0.08);
  font-size: 11px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-pill.accent {
  border-color: rgba(216,93,54,0.42);
  background: rgba(216,93,54,0.22);
}

.composer-pill.reply {
  border-color: rgba(134,161,92,0.4);
  background: rgba(134,161,92,0.18);
}

.composer-pill.warning {
  border-color: rgba(242,155,61,0.46);
  background: rgba(242,155,61,0.2);
}

.composer-pill.muted {
  color: var(--muted);
}

.composer-field-grid {
  grid-area: fields;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(0, 1fr);
  gap: 7px;
}

.reply-composer input,
.reply-composer select {
  min-height: 36px;
  padding: 6px 10px;
}

.composer-cc-chips {
  grid-area: cc;
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.cc-chip {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(248,250,252,0.15);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(248,250,252,0.06);
  font-size: 12px;
  font-weight: 900;
}

.cc-chip.active {
  color: #fff;
  border-color: rgba(134,161,92,0.46);
  background: rgba(134,161,92,0.2);
}

.cc-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#commandEmailLanguageLabel[hidden] + label {
  grid-column: 1 / -1;
}

.composer-body-label {
  grid-area: body;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(88px, 1fr);
}

.reply-composer textarea {
  height: 100%;
  min-height: clamp(62px, 7vh, 90px);
  max-height: none;
  resize: none;
  line-height: 1.48;
  padding: 9px 10px;
}

.composer-command-deck {
  grid-area: side;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
  align-items: stretch;
  overflow: hidden;
}

.composer-snippet-panel,
.email-readiness {
  min-width: 0;
  min-height: 0;
  max-height: none;
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background: rgba(248,250,252,0.06);
}

.composer-panel-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.composer-quick-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.quick-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(248,250,252,0.16);
  border-radius: 8px;
  color: var(--text-light);
  background: rgba(15,12,11,0.34);
  font-size: 12px;
  font-weight: 900;
}

.quick-chip:hover {
  border-color: rgba(216,93,54,0.46);
  background: rgba(216,93,54,0.18);
}

.quick-chip-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.email-readiness.ready {
  border-color: rgba(134,161,92,0.34);
  background: rgba(134,161,92,0.12);
}

.email-readiness.attention {
  border-color: rgba(242,155,61,0.28);
}

.readiness-head,
.readiness-row {
  display: grid;
  gap: 3px;
}

.readiness-head strong {
  color: #fff;
  font-size: 13px;
}

.readiness-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.readiness-row {
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
}

.readiness-row span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--fire);
}

.readiness-row.ok span {
  background: var(--basil);
}

.readiness-row strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.shortage-empty-state {
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(216,93,54,0.4);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(216,93,54,0.18), rgba(248,250,252,0.04)),
    rgba(18, 16, 16, 0.72);
}

.shortage-empty-state strong {
  grid-column: 1 / -1;
  font-size: clamp(24px, 2.2vw, 40px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.shortage-empty-state span {
  min-width: 0;
  display: grid;
  align-content: center;
  padding: 13px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  color: #fff;
  background: rgba(255,255,255,0.07);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.shortage-empty-state::after {
  content: "Use the inspector on the right to create this supplier order. The email thread opens after that.";
  grid-column: 1 / -1;
  display: grid;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: 8px;
  color: rgba(248,250,252,0.68);
  background: transparent;
  font-size: 14px;
  font-weight: 850;
  text-align: left;
}

.static-order-line {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid rgba(248,250,252,0.13);
  border-radius: 8px;
  background: rgba(248,250,252,0.07);
}

.static-order-line span,
.static-order-line em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.static-order-line strong {
  font-size: 15px;
}

.catalog-fix-link {
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid rgba(216,93,54,0.45);
  border-radius: 8px;
  color: #fff;
  background: rgba(216,93,54,0.22);
  font-size: 12px;
  font-weight: 900;
}

.reply-composer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.reply-composer-head strong {
  font-size: 15px;
}

.reply-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(248,250,252,0.12);
}

.reply-actions > span {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#emailBodyCount {
  color: rgba(248,250,252,0.64);
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
}

.composer-tool-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.command-edit-form {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 9px;
  overscroll-behavior: contain;
  overflow: visible;
  padding: 12px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 8px;
  background: rgba(248,250,252,0.055);
}

.order-editor input,
.order-editor select {
  min-height: 42px;
  padding: 9px 11px;
}

.order-editor textarea {
  min-height: 88px;
  resize: none;
}

.manual-confirm-box {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 12px;
  border: 1px solid rgba(248,250,252,0.13);
  border-radius: 8px;
  background: rgba(248,250,252,0.07);
}

.command-next-action-box {
  display: grid;
  gap: 9px;
}

.command-next-action-box strong {
  color: #dbf0c2;
  font-size: 15px;
}

.command-next-action-box p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.command-next-action-box.needs-email strong {
  color: #ffd6a7;
}

.command-next-action-box.waiting-reply strong {
  color: #ffe7a3;
}

.command-next-action-box.needs-confirm strong {
  color: #bdf4e7;
}

.command-next-action-box.problem strong {
  color: #ffc7b8;
}

.command-next-action-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.problem-button {
  color: #ffc7b8;
  border-color: rgba(216,93,54,0.38);
}

.without-email-button {
  color: #d8f7df;
  background: rgba(146, 204, 171, 0.1);
  border-color: rgba(146, 204, 171, 0.34);
}

.without-email-button:hover {
  background: rgba(146, 204, 171, 0.16);
  border-color: rgba(146, 204, 171, 0.52);
}

.without-email-button[hidden] {
  display: none !important;
}

.compact-button {
  min-height: 40px;
  padding: 0 13px;
  font-size: 12px;
}

.legacy-workspace[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .command-center-view {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .active-order-workspace {
    grid-template-areas:
      "bar"
      "mail"
      "inspector";
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .active-order-workspace.shortage-focus {
    grid-template-columns: 1fr;
  }

  .order-email-room {
    grid-template-areas:
      "head"
      "thread"
      "composer";
    grid-template-rows: auto minmax(280px, 1fr) auto;
  }
}

@media (max-width: 860px) {
  .command-center-view,
  .active-workspace-bar,
  .email-room-head,
  .reply-composer-head,
  .composer-field-grid,
  .composer-command-deck,
  .reply-actions,
  .reply-composer,
  .order-editor {
    grid-template-columns: 1fr;
  }

  .composer-focus-strip,
  .composer-tool-actions {
    justify-content: flex-start;
  }

  .command-center-view {
    grid-template-columns: 1fr;
  }

  .command-center-view,
  .active-order-workspace,
  .order-email-room {
    overflow: auto;
  }

  .order-email-room {
    grid-template-areas:
      "head"
      "thread"
      "composer";
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(260px, 38vh) auto;
  }

  .email-room-head {
    grid-template-columns: 1fr;
  }

  .command-email-thread {
    min-height: 260px;
  }

  .reply-composer {
    grid-template-areas:
      "head"
      "fields"
      "cc"
      "body"
      "side"
      "actions";
    grid-template-rows: auto auto auto minmax(126px, auto) auto auto;
    max-height: none;
    overflow: auto;
  }

  .composer-command-deck {
    grid-template-rows: auto auto;
  }

  .command-email-thread .email-message {
    max-width: 100%;
  }
}

/* Purchasing board redesign */
.command-center-view {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.purchase-board-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.105), rgba(255,255,255,0.045)),
    rgba(12, 12, 13, 0.72);
  box-shadow: 0 18px 44px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(24px) saturate(1.12);
}

.purchase-board-toolbar h1 {
  margin: 2px 0 0;
  color: #fff;
  font-size: 24px;
  line-height: 1.05;
}

.purchase-board-toolbar p:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.purchase-board-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.purchase-board {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  overflow: hidden;
}

.purchase-board-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(248,250,252,0.1);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025)),
    rgba(11, 11, 12, 0.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.purchase-board-column.drag-over {
  border-color: rgba(216,93,54,0.54);
  background:
    linear-gradient(180deg, rgba(216,93,54,0.16), rgba(255,255,255,0.035)),
    rgba(18, 13, 12, 0.72);
  transform: translateY(-1px);
}

.purchase-column-head {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 4px 2px 8px;
}

.purchase-column-head strong {
  color: #fff;
  font-size: 14px;
  line-height: 1.15;
}

.purchase-column-head span {
  display: block;
  margin-top: 2px;
  color: rgba(248,250,252,0.58);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.25;
}

.purchase-column-head em,
.command-queue-count {
  min-width: 34px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(248,250,252,0.11);
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.purchase-column-scroll {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1px 2px 2px;
  scrollbar-gutter: stable;
}

.purchase-column-empty {
  min-height: 92px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px dashed rgba(248,250,252,0.12);
  border-radius: 10px;
  color: rgba(248,250,252,0.44);
  background: rgba(248,250,252,0.035);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.purchase-board-card {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  padding: 10px;
  text-align: left;
  color: var(--text-light);
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.095), rgba(255,255,255,0.04)),
    rgba(17, 17, 18, 0.72);
  box-shadow: 0 14px 34px rgba(0,0,0,0.16), inset 0 1px 0 rgba(255,255,255,0.08);
  cursor: pointer;
  user-select: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.purchase-board-card:hover,
.purchase-board-card:focus-visible {
  outline: none;
  transform: translateY(-2px);
  border-color: rgba(248,250,252,0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.052)),
    rgba(23, 22, 23, 0.86);
  box-shadow: 0 18px 42px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.1);
}

.purchase-board-card.active {
  border-color: rgba(216,93,54,0.52);
  box-shadow: 0 0 0 2px rgba(216,93,54,0.18), 0 18px 42px rgba(0,0,0,0.24);
}

.purchase-board-card.dragging {
  opacity: 0.28;
}

.purchase-card-drag {
  width: 28px;
  min-height: 100%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(248,250,252,0.09);
  border-radius: 9px;
  background: rgba(248,250,252,0.045);
  color: transparent;
  font-size: 0;
  cursor: grab;
}

.purchase-card-drag::before {
  content: "";
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(248,250,252,0.86) 1.5px, transparent 2px) 0 0 / 4px 7px;
  opacity: 0.7;
}

.purchase-card-drag:hover {
  background: rgba(248,250,252,0.09);
  border-color: rgba(248,250,252,0.18);
}

.purchase-card-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.purchase-card-title-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.purchase-card-title-row strong {
  min-width: 0;
  color: #fff;
  font-size: 13px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.purchase-card-main span,
.purchase-card-main em {
  min-width: 0;
  color: rgba(248,250,252,0.64);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.purchase-card-pill,
.purchase-status-chip {
  max-width: 150px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 999px;
  color: #fff;
  background: rgba(248,250,252,0.08);
  font-size: 10px;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-card-pill.danger,
.purchase-status-chip.danger,
.purchase-status-chip.needs-email,
.purchase-status-chip.problem {
  border-color: rgba(216,93,54,0.4);
  background: rgba(216,93,54,0.2);
}

.purchase-status-chip.waiting-reply {
  border-color: rgba(214,178,82,0.38);
  background: rgba(214,178,82,0.16);
}

.purchase-status-chip.needs-confirm,
.purchase-status-chip.confirmed {
  border-color: rgba(134,161,92,0.4);
  background: rgba(134,161,92,0.18);
}

.purchase-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1200;
  pointer-events: none;
  opacity: 0.96;
  box-shadow: 0 30px 80px rgba(0,0,0,0.36);
}

.purchase-drag-active {
  cursor: grabbing;
}

.purchase-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  padding: 24px;
}

.purchase-card-overlay.hidden {
  display: none !important;
}

.purchase-card-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 2, 3, 0.66);
  backdrop-filter: blur(18px) saturate(1.18);
  cursor: default;
}

.purchase-card-dialog {
  position: relative;
  width: min(1760px, calc(100vw - 48px));
  height: min(980px, calc(100vh - 48px));
  align-self: center;
  justify-self: center;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(248,250,252,0.18);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.055)),
    rgba(12, 12, 13, 0.92);
  box-shadow: 0 38px 120px rgba(0,0,0,0.58), inset 0 1px 0 rgba(255,255,255,0.12);
  backdrop-filter: blur(28px) saturate(1.12);
  animation: purchaseDialogIn 180ms ease-out both;
}

@keyframes purchaseDialogIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.purchase-card-header {
  min-width: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(220px, 320px) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 14px;
  background: rgba(248,250,252,0.055);
}

.purchase-card-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(248,250,252,0.12);
  border-radius: 999px;
  color: #fff;
  background: rgba(248,250,252,0.075);
  font-size: 24px;
  line-height: 1;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.purchase-card-close:hover {
  transform: scale(1.04);
  border-color: rgba(248,250,252,0.24);
  background: rgba(248,250,252,0.13);
}

.purchase-card-header h1 {
  margin: 2px 0 0;
  color: #fff;
  font-size: clamp(22px, 1.6vw, 30px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.purchase-card-header p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.purchase-card-status-chips {
  display: inline-flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.purchase-card-body {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 12px;
  overflow: hidden;
}

.purchase-card-overlay .order-email-room {
  grid-area: auto;
  grid-template-areas:
    "thread"
    "composer";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(320px, 1fr) auto;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.purchase-card-overlay .command-email-thread {
  min-height: 0;
  padding: 18px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(248,250,252,0.052), rgba(248,250,252,0.02)),
    rgba(3, 3, 4, 0.52);
}

.purchase-card-overlay .command-email-thread .email-message {
  width: min(980px, 82%);
  max-width: 82%;
  border-radius: 14px;
  padding: 12px 14px;
}

.purchase-card-overlay .command-email-thread .email-message p {
  max-height: none;
  overflow: visible;
  font-size: 14px;
  line-height: 1.55;
}

.purchase-card-overlay .reply-composer {
  max-height: min(430px, 44vh);
  display: grid;
  grid-template-areas:
    "head head"
    "fields side"
    "cc side"
    "body side"
    "actions actions";
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  grid-template-rows: auto auto auto minmax(184px, 1fr) auto;
  gap: 8px;
  overflow: hidden;
  padding: 12px;
  border-radius: 14px;
}

.purchase-card-overlay .reply-composer textarea {
  min-height: 0;
  max-height: none;
  height: 100%;
  overflow: auto;
  resize: none;
}

.purchase-card-overlay .composer-body-label {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  overflow: hidden;
}

.purchase-card-overlay .order-editor {
  grid-area: auto;
  min-height: 0;
  border-radius: 14px;
  overflow: auto;
}

.purchase-card-overlay .command-edit-form,
.purchase-card-overlay .manual-confirm-box,
.purchase-card-overlay .order-editor > .command-panel-head {
  border-radius: 12px;
}

.purchase-card-overlay .shortage-mode {
  grid-template-rows: minmax(0, 1fr);
}

.purchase-card-overlay .shortage-mode .command-email-thread {
  align-content: start;
}

.purchase-card-overlay .shortage-mode .shortage-empty-state {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.purchase-overlay-open {
  overflow: hidden;
}

@media (max-width: 1240px) {
  .purchase-board {
    grid-template-columns: repeat(5, minmax(260px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .purchase-card-body {
    grid-template-columns: minmax(0, 1fr);
    overflow: auto;
  }
}

@media (max-width: 860px) {
  .purchase-board-toolbar,
  .purchase-card-header,
  .purchase-card-body,
  .purchase-card-overlay .reply-composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .purchase-card-overlay {
    padding: 10px;
  }

  .purchase-card-dialog {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }

  .purchase-card-overlay .command-email-thread .email-message {
    width: 100%;
    max-width: 100%;
  }

  .purchase-card-overlay {
    padding: 6px;
  }

  .purchase-card-dialog {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    padding: 8px;
    gap: 8px;
    border-radius: 14px;
  }

  .purchase-card-header {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
  }

  .purchase-card-close {
    width: 34px;
    height: 34px;
    grid-column: 1;
    grid-row: 1;
  }

  .purchase-card-header > div:first-of-type {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .purchase-card-header h1 {
    font-size: 20px;
    line-height: 1.14;
  }

  .purchase-card-header p {
    font-size: 11px;
  }

  .purchase-card-header .supplier-contact-card {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .purchase-card-status-chips {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: flex-start;
  }

  .purchase-card-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
    gap: 8px;
    overflow: auto;
    scrollbar-gutter: stable;
  }

  .purchase-card-overlay .order-email-room {
    grid-template-areas:
      "thread"
      "composer";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 220px auto;
    gap: 8px;
    min-height: 860px;
    overflow: visible;
  }

  .purchase-card-overlay .command-email-thread {
    min-height: 220px;
    padding: 12px;
    border-radius: 12px;
  }

  .purchase-card-overlay .reply-composer {
    grid-template-areas:
      "head"
      "fields"
      "cc"
      "body"
      "actions";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    max-height: none;
    min-height: 620px;
    overflow: hidden;
    padding: 10px;
    border-radius: 12px;
  }

  .purchase-card-overlay .reply-composer-head,
  .purchase-card-overlay .composer-field-grid,
  .purchase-card-overlay .reply-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .purchase-card-overlay .composer-focus-strip,
  .purchase-card-overlay .composer-tool-actions {
    justify-content: flex-start;
  }

  .purchase-card-overlay .composer-command-deck {
    display: none;
  }

  .purchase-card-overlay .composer-body-label {
    min-height: 236px;
    grid-template-rows: auto 210px;
    gap: 6px;
    font-size: 12px;
  }

  .purchase-card-overlay .composer-snippet-panel,
  .purchase-card-overlay .email-readiness {
    max-height: 180px;
  }

  .purchase-card-overlay .reply-composer textarea {
    width: 100%;
    height: 210px !important;
    min-height: 210px;
    max-height: 210px;
  }

  .purchase-card-overlay .reply-actions {
    align-items: stretch;
    gap: 8px;
  }

  .purchase-card-overlay .reply-actions > span {
    white-space: normal;
  }

  .purchase-card-overlay .composer-tool-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .purchase-card-overlay .order-editor {
    min-height: 720px;
    max-height: none;
    overflow: visible;
  }
}
