:root {
  --bg: #0b0b0c;
  --bg-elevated: #151517;
  --text: #f2f2f0;
  --text-muted: #9a9a95;
  --border: #242426;
  --accent: #7acd36;         /* brand: buttons, links, focus, selected states */
  --accent-text: #0b0b0c;
  --error: #ff8a80;
  --ok: #8adf9e;
  --brand: var(--accent);    /* tab bar */
  --brand-text: #0b0b0c;     /* text on --brand */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 40px;
}

.empty-state {
  max-width: 640px;
  margin: 14vh auto 0;
  padding: 0 24px;
  text-align: center;
}

.empty-state h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}

.message-list {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.msg { line-height: 1.6; font-size: 15px; white-space: pre-wrap; }
.msg-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.msg.user .msg-role { color: var(--accent); }
.msg.error { color: var(--error); }

/* ---------- Proposed order card ---------- */
.order-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 18px 20px;
  margin-top: 8px;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.order-card-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.order-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.order-card input, .order-card textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
}

.order-card .field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 14px;
}

.order-card .field-grid {
  overflow-x: auto;
}

.order-card table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.order-card th, .order-card td {
  text-align: left;
  font-size: 12px;
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
}

.order-card th { color: var(--text-muted); font-weight: 500; }

.order-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.order-card-result {
  margin-top: 12px;
  font-size: 13px;
}
.order-card-result.ok { color: var(--ok); }
.order-card-result.error { color: var(--error); }

/* ---------- Composer ---------- */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto 24px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.composer-input, #composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  padding: 8px 0;
}

#composer-input::placeholder { color: var(--text-muted); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
}

.icon-btn.voice-active {
  color: var(--accent);
  background: rgba(122, 205, 54, 0.12);
}

.icon-btn.recording {
  color: var(--error);
  animation: pulse 1.1s ease-in-out infinite;
}

.icon-btn.speaking {
  color: var(--ok);
  animation: pulse 0.7s ease-in-out infinite;
}

.icon-btn.thinking {
  color: var(--accent);
  animation: pulse 0.5s linear infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.attached-filename {
  font-size: 12px;
  color: var(--accent);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.send-btn:disabled { opacity: 0.5; cursor: default; }

button {
  font-family: inherit;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---------- Sign-in ---------- */
.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 10vh 16px 40px;
  background: var(--bg);
}

.login-screen[hidden] { display: none; }

.login-form {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form h1 {
  font-size: 28px;
  margin: 0;
}

.login-note,
.login-detected {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.login-detected { overflow-wrap: anywhere; }

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-form label[hidden] { display: none; }

.login-form input {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.login-error {
  margin: 0;
  font-size: 14px;
  color: var(--error);
}

.login-form .send-btn { align-self: flex-start; }

/* ---------- Confirmation card ---------- */
.msg.confirm {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-elevated);
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Assistant text (markdown) ---------- */
.msg.assistant { white-space: normal; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md h4 { margin: 4px 0 8px; font-size: 15px; }
.md code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--bg-elevated); border: 1px solid var(--border); }
.md strong { color: var(--text); }

/* ---------- Visuals (tables, charts, stats, order cards) ---------- */
/* Status tones, shared by visuals and the Home screen. */
:root {
  --good: #8adf9e; --good-bg: rgba(138, 223, 158, 0.12);
  --warning: #f6c177; --warning-bg: rgba(246, 193, 119, 0.13);
  --bad: #ff8a80; --bad-bg: rgba(255, 138, 128, 0.13);
  --neutral-bg: rgba(154, 154, 149, 0.14);
}
.vz {
  margin: 14px 0 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  overflow: hidden;
  font-size: 14px;
}
.vz-head { padding: 14px 16px 10px; }
.vz-title { font-weight: 600; font-size: 15px; color: var(--text); }
.vz-subtitle { margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.vz-error { padding: 14px 16px; color: var(--text-muted); }

.vz-scroll { overflow-x: auto; }
.vz table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.vz th {
  text-align: left; font-weight: 500; font-size: 12px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-muted); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.vz td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
.vz tbody tr:last-child td { border-bottom: none; }
.vz tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.vz .num { text-align: right; white-space: nowrap; }
.vz-empty { color: var(--text-muted); text-align: center; }
.vz-head + .vz-scroll th { border-top: 1px solid var(--border); }

.vz-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; background: var(--neutral-bg); color: var(--text);
}
.vz-pill.tone-good { background: var(--good-bg); color: var(--good); }
.vz-pill.tone-warning { background: var(--warning-bg); color: var(--warning); }
.vz-pill.tone-bad { background: var(--bad-bg); color: var(--bad); }

.vz-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--border); }
.vz-head + .vz-stat-grid { border-top: 1px solid var(--border); }
.vz-stat { padding: 14px 16px; background: var(--bg-elevated); }
.vz-stat-label { font-size: 12.5px; color: var(--text-muted); }
.vz-stat-value { margin-top: 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.vz-stat-detail { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }
.vz-stat.tone-good .vz-stat-value { color: var(--good); }
.vz-stat.tone-warning .vz-stat-value { color: var(--warning); }
.vz-stat.tone-bad .vz-stat-value { color: var(--bad); }

.vz-chart-box { position: relative; height: 260px; padding: 4px 12px 12px; }

.vz-order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 16px 12px; }
.vz-order-number { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.vz-order-title { margin-top: 2px; color: var(--text); }
.vz-order-customer { margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.vz-order-head .vz-pill { font-size: 13px; padding: 4px 12px; margin-top: 2px; }

.vz-steps { display: flex; list-style: none; margin: 0; padding: 4px 16px 16px; gap: 0; overflow-x: auto; }
.vz-step { flex: 1 1 0; min-width: 84px; position: relative; padding-top: 18px; font-size: 12.5px; color: var(--text-muted); text-align: center; }
.vz-step::before { content: ''; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--border); }
.vz-step:first-child::before { left: 50%; }
.vz-step:last-child::before { right: 50%; }
.vz-step.is-done::before, .vz-step.is-current::before { background: var(--accent); }
.vz-step-dot {
  position: absolute; top: 0; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--bg-elevated); border: 2px solid var(--border); box-sizing: border-box;
}
.vz-step.is-done .vz-step-dot { background: var(--accent); border-color: var(--accent); }
.vz-step.is-current .vz-step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(122, 205, 54, 0.2); }
.vz-step.is-current { color: var(--text); font-weight: 600; }
.vz-step-name { display: block; margin-top: 6px; padding: 0 4px; }

.vz-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 0; background: var(--border); border-top: 1px solid var(--border); }
.vz-facts > div { padding: 10px 16px; background: var(--bg-elevated); }
.vz-facts > div:last-child { grid-column: auto / -1; } /* fill the last row instead of leaving a gap */
.vz-facts dt { font-size: 12px; color: var(--text-muted); }
.vz-facts dd { margin: 2px 0 0; color: var(--text); }
.vz-order > .vz { margin: 0; border: none; border-top: 1px solid var(--border); border-radius: 0; }

@media (max-width: 560px) {
  .vz th, .vz td { padding: 8px 10px; }
  .vz-stat-value { font-size: 22px; }
}

/* ---------- Model picker and token usage ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.models-menu { position: relative; }
.models-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.models-btn:hover, .models-btn[aria-expanded="true"] { border-color: var(--accent); }
.models-btn-name { color: var(--text-muted); }
.models-btn-summary { font-weight: 600; }
.models-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 12px;
  width: 340px; max-width: calc(100vw - 32px);
  padding: 14px 16px 16px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--text);
}
.models-panel[hidden] { display: none; }
.models-panel-title { font-weight: 600; font-size: 14px; }
.models-panel-hint { margin-top: -8px; font-size: 12px; color: var(--text-muted); }
.models-row { display: flex; flex-direction: column; gap: 3px; }
.models-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.models-row-hint { font-size: 12px; color: var(--text-muted); }
.models-row select {
  margin-top: 3px; padding: 7px 8px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.models-row select:focus, .models-btn:focus-visible, .deep-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.deep-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 6px 10px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 999px;
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.deep-btn:hover { color: var(--text); }
.deep-btn[aria-pressed="true"] {
  color: var(--accent-text); background: var(--accent); border-color: var(--accent); font-weight: 600;
}
.usage-total { font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-line {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .session-info { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .deep-btn span { display: none; }
}

/* ---------- Screens and bottom tab bar ---------- */
.app-views { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app-views[hidden] { display: none; }
.view { flex: 1; min-height: 0; overflow-y: auto; }
.view[hidden] { display: none; }
.view-chat { display: flex; flex-direction: column; overflow: hidden; }
.view-chat .chat-scroll { flex: 1; min-height: 0; }
.view-chat .composer { margin-bottom: 12px; }
.view-chat .composer[hidden], .view-chat .chat-scroll[hidden] { display: none; }
.view-inner { max-width: 900px; margin: 0 auto; padding: 24px 16px 32px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.view-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.view-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

/* Models and Voice show on every screen (voice questions can be asked from any of them);
   the running token and cost total only in the chat. */
body:not([data-view="chat"]) #usage-total { display: none; }

.ghost-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); }
.ghost-btn:focus-visible, .tab:focus-visible, .order-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen-message { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }
.screen-message.is-error { color: var(--error); }

.tabbar {
  flex: 0 0 auto; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-top: 2px solid rgba(122, 205, 54, 0.45); background: var(--bg-elevated);
}
.tabbar[hidden] { display: none; }
.tab {
  flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border: none; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tab svg { color: var(--brand); }
.tab:hover { background: rgba(122, 205, 54, 0.12); }
.tab[aria-current="page"] { background: var(--brand); color: var(--brand-text); font-weight: 700; }
.tab[aria-current="page"] svg { color: var(--brand-text); }
.tab:focus-visible { outline-color: var(--brand); }
@media (prefers-reduced-motion: reduce) { .tab { transition: none; } }

/* ---------- Home: recent orders ---------- */
.orders-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--bg-elevated); }
.orders-list:empty { display: none; }
.orders-list > .screen-message { background: var(--bg); }
.order-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 150px; align-items: center; gap: 16px;
  width: 100%; padding: 12px 16px; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.order-row:last-child { border-bottom: none; }
.order-row:hover { background: rgba(255, 255, 255, 0.03); }
.order-row-main, .order-row-who { display: flex; flex-direction: column; min-width: 0; }
.order-row-number { font-weight: 600; font-variant-numeric: tabular-nums; }
.order-row-title, .order-row-date { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-row-customer { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.order-row-total { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Order drill-down sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; max-width: 760px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: 16px 16px 0 0;
  animation: sheet-up 0.18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet-panel { animation: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sheet-title { font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; }
.sheet-ask { margin-top: 16px; }
.sheet-ask + .lift-open { margin-left: 8px; }
body.sheet-open { overflow: hidden; }

/* ---------- Charts ---------- */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 16px; }
.charts-content > .vz:first-child { margin-top: 0; }

/* ---------- Apps ---------- */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.app-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 16px; min-height: 96px;
  border: 1px dashed var(--border); border-radius: 14px; background: var(--bg-elevated);
}
.app-tile-name { font-weight: 600; }
.app-tile-note { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Chat: connect Claude ---------- */
.chat-key { flex: 1; overflow-y: auto; display: flex; justify-content: center; padding: 10vh 16px 32px; }
.chat-key[hidden] { display: none; }
.chat-key-form h1 { font-size: 24px; }

@media (max-width: 640px) {
  .order-row { grid-template-columns: minmax(0, 1fr) 120px; gap: 4px 12px; }
  .order-row-who { grid-row: 2; }
  .order-row-right { grid-row: 1 / span 2; grid-column: 2; }
  .view-head h1 { font-size: 20px; }
  .topbar { padding: 12px 16px; }
  #session-label { display: none; }
}

/* ---------- "Thinking…" status line ---------- */
.thinking { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text-muted); }
.thinking-spark {
  width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 0 rgba(122, 205, 54, 0.5);
  animation: thinking-pulse 1.4s ease-in-out infinite;
}
.thinking-text {
  font-weight: 500;
  background: linear-gradient(90deg, var(--text-muted) 0%, var(--text-muted) 35%, var(--text) 50%, var(--text-muted) 65%, var(--text-muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: thinking-shimmer 2.2s linear infinite;
}
.thinking-text::after { content: '…'; }
.thinking-time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-muted); opacity: 0.8; min-width: 2.5em; }
@keyframes thinking-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes thinking-pulse {
  0%, 100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(122, 205, 54, 0.45); }
  50% { transform: scale(1); box-shadow: 0 0 0 6px rgba(122, 205, 54, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-spark, .thinking-text { animation: none; }
  .thinking-text { color: var(--text-muted); background: none; }
}
.msg.pending { white-space: normal; }

/* ---------- Charts: period switch and drill-down ---------- */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 4px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated);
}
.segmented-btn {
  padding: 7px 14px; border: none; border-radius: 9px; background: transparent;
  color: var(--text-muted); font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.segmented-btn:hover { color: var(--text); }
.segmented-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.segmented-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vz-stat-detail { font-variant-numeric: tabular-nums; }
.vz-stat.tone-good .vz-stat-detail { color: var(--good); }
.vz-stat.tone-bad .vz-stat-detail { color: var(--bad); }
.charts-drill { margin-top: 20px; scroll-margin-top: 12px; }
.charts-drill-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.charts-drill-head h2 { margin: 0; font-size: 18px; }
.charts-drill-head .ghost-btn { margin-left: auto; }
.seg-short { display: none; }
@media (max-width: 640px) {
  .segmented { display: grid; grid-template-columns: repeat(4, 1fr); flex-wrap: nowrap; }
  .segmented-btn { padding: 7px 4px; font-size: 13px; }
  .seg-long { display: none; }
  .seg-short { display: inline; }
}
/* On Charts the tone describes the change vs last year, so only that line is colored. */
.charts-content .vz-stat .vz-stat-value { color: var(--text); }

/* ---------- Home: Recent / WIP ---------- */
.home-modes { margin-bottom: 12px; }
#home-extra > .vz:first-child { margin-top: 0; }
#home-extra:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip.is-bad:not([aria-pressed="true"]) { color: var(--bad); border-color: rgba(255, 138, 128, 0.45); }
.chip.is-bad[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #1a0d0c; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.order-row-note.tone-bad { color: var(--bad); font-weight: 600; }
.order-row-note.tone-warning { color: var(--warning); }
.order-row.is-bad { box-shadow: inset 3px 0 0 var(--bad); background: rgba(255, 138, 128, 0.05); }
.order-row.is-warning { box-shadow: inset 3px 0 0 var(--warning); }
@media (max-width: 640px) { .segmented.home-modes { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Shipments, machine chart ---------- */
.shipment-list { list-style: none; margin: 0; padding: 0 16px 6px; }
.shipment { padding: 12px 0; border-top: 1px solid var(--border); }
.shipment:first-child { border-top: none; }
.shipment-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shipment-carrier { font-weight: 600; }
.shipment-tracking {
  display: inline-block; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; color: var(--accent); text-decoration: none; overflow-wrap: anywhere;
}
a.shipment-tracking:hover { text-decoration: underline; }
.shipment-facts { margin-top: 3px; font-size: 12.5px; color: var(--text-muted); }
.machine-block { margin-top: 28px; }
.machine-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.machine-head h2 { margin: 0; font-size: 18px; }
.machine-block .chips { margin: 10px 0 0; }
.machine-note { margin: 6px 0 0; max-width: 70ch; }
@media (max-width: 640px) { .segmented.home-modes { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Home: Ask, Insights, Orders cards (each collapsible) ---------- */
.home-cards { display: flex; flex-direction: column; gap: 14px; }
.home-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px;
  padding: 2px 18px 18px;
}
.home-card.is-collapsed { padding-bottom: 2px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.home-card.is-collapsed .card-head .ghost-btn { display: none; }
.card-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px 0;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.card-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-heading .view-sub { margin: 0; }
.card-kicker { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.card-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.ask-card .card-title { font-size: 24px; }
.card-chevron { flex: none; color: var(--text-muted); transition: transform 0.2s ease; }
.home-card.is-collapsed .card-chevron { transform: rotate(-90deg); }
.card-peek { display: none; flex: none; padding: 4px 10px; border-radius: 999px; background: var(--bg); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.home-card.is-collapsed .card-peek:not(:empty) { display: inline-block; }
.card-peek.tone-good, .insights-rating.tone-good, .score-change.tone-good { color: var(--good); }
.card-peek.tone-warning, .insights-rating.tone-warning, .score-change.tone-warning { color: var(--warning); }
.card-peek.tone-bad, .insights-rating.tone-bad, .score-change.tone-bad { color: var(--bad); }

/* Ask */
.ask-card { background: linear-gradient(160deg, rgba(122, 205, 54, 0.13), rgba(122, 205, 54, 0) 55%), var(--bg-elevated); }
.ask-form {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
}
.ask-form:focus-within { border-color: var(--accent); }
#ask-input { flex: 1; min-width: 0; padding: 8px 0; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 16px; }
#ask-input::placeholder { color: var(--text-muted); }
.ask-send {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.ask-send:focus-visible, .ask-chip:focus-visible, .score:focus-visible, .ask-deeper:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ask-groups { margin-top: 16px; }
.ask-group-label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--text-muted); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer;
}
.ask-chip:hover { border-color: var(--accent); }

/* Insights */
.insights-top { display: flex; align-items: center; gap: 20px; }
.ring { position: relative; flex: none; display: inline-grid; place-items: center; }
.ring svg { display: block; }
.ring-number { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-big .ring-number { font-size: 34px; letter-spacing: -0.02em; }
.ring-track { stroke: rgba(255, 255, 255, 0.08); }
.ring-fill { stroke: var(--text-muted); stroke-linecap: round; transition: stroke-dashoffset 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.ring-fill.tone-good { stroke: var(--good); }
.ring-fill.tone-warning { stroke: var(--warning); }
.ring-fill.tone-bad { stroke: var(--bad); }
.insights-words { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.insights-label { font-size: 13px; color: var(--text-muted); }
.insights-rating { font-size: 22px; font-weight: 700; }
.insights-summary { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.score-caption { margin: 18px 2px 8px; font-size: 12px; color: var(--text-muted); }
.score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.score {
  min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg);
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.score:hover, .score[aria-pressed="true"] { border-color: var(--accent); }
.score-text { min-width: 0; display: flex; flex-direction: column; }
.score-label { font-size: 12px; color: var(--text-muted); }
.score-value { overflow: hidden; font-size: 14.5px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.score-change { font-size: 12px; color: var(--text-muted); }
.score-detail { margin: 10px 2px 0; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); }
.insight-list { list-style: none; margin: 16px 0 0; padding: 0; }
.insight { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.insight-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--text-muted); }
.insight.tone-good .insight-dot { background: var(--good); }
.insight.tone-warning .insight-dot { background: var(--warning); }
.insight.tone-bad .insight-dot { background: var(--bad); }
.insight-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.insight-title { font-size: 14.5px; }
.insight-text { font-size: 13.5px; line-height: 1.45; color: var(--text-muted); }
.insight-action { flex: none; align-self: center; white-space: nowrap; }
.insights-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.topic { margin-top: 16px; }
.topic-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.topic-title { margin: 0; font-size: 15px; font-weight: 600; }
.topic .insight-list { margin-top: 8px; }
.topic .ask-deeper { margin-top: 10px; }
.ask-deeper { margin-left: auto; padding: 6px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.ask-deeper::before { content: "\2726  "; }
.ask-link { padding: 6px 0; border: 0; background: none; color: var(--text-muted); font: inherit; font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ask-link:hover { color: var(--text); }
.ask-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 640px) {
  .home-card { padding-left: 14px; padding-right: 14px; }
  .score-grid { grid-template-columns: repeat(2, 1fr); }
  .insights-top { gap: 16px; }
  .insight { flex-wrap: wrap; }
  .insight-body { flex-basis: calc(100% - 20px); }
  .insight-action { margin-left: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-fill, .card-chevron { transition: none; }
}

/* Choices: options the assistant offers; tapping one asks about it. */
.vz-choice-list { display: flex; flex-direction: column; }
.vz-head + .vz-choice-list { border-top: 1px solid var(--border); }
.vz-choice {
  display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center;
  padding: 12px 16px; border: 0; border-top: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.vz-choice:first-child { border-top: 0; }
.vz-choice:hover:not(:disabled) { background: rgba(122, 205, 54, 0.08); }
.vz-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.vz-choice.is-chosen { box-shadow: inset 3px 0 0 var(--accent); background: rgba(122, 205, 54, 0.08); }
.vz-choice-label { grid-column: 1; font-weight: 600; font-size: 14.5px; }
.vz-choice-detail { grid-column: 1; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--text-muted); }
.vz-choice-go { grid-column: 2; grid-row: 1 / span 2; color: var(--accent); font-size: 18px; }
.vz-choice:disabled { cursor: default; }

/* Links in the assistant's text (e.g. a manual page); open in a new tab. */
.md-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.md-link:hover { text-decoration-thickness: 2px; }
.md-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.md-link::after { content: " \2197"; font-size: 0.85em; }

/* ---------- Apps: tiles and the order importers ---------- */
button.app-tile {
  border-style: solid; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
button.app-tile:hover { border-color: var(--accent); background: rgba(122, 205, 54, 0.06); }
button.app-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-tile-icon { color: var(--accent); margin-bottom: 6px; }
.app-tile.is-soon { opacity: 0.7; }
.app-back { margin-bottom: 14px; }
.importer-key { max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.importer-key label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.importer-key input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); font: inherit; }
.importer-key .send-btn { align-self: flex-start; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 220px; padding: 28px 16px; border: 2px dashed var(--border); border-radius: 18px;
  background: var(--bg-elevated); text-align: center; cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: rgba(122, 205, 54, 0.06); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone-icon { font-size: 28px; color: var(--accent); }
.dropzone-title { font-weight: 600; font-size: 16px; }
.dropzone-sub { font-size: 13px; color: var(--text-muted); }
.importer .screen-message { padding: 0 0 14px; text-align: left; }
.importer-status { padding: 28px 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-elevated); display: flex; flex-direction: column; gap: 10px; }
.importer-file { font-weight: 600; overflow-wrap: anywhere; }
.importer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.ghost-btn.is-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }

/* Review card additions: notes, product picker, line states. */
.order-card-source { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.order-card-notes { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--warning-bg); color: var(--text); font-size: 13px; line-height: 1.45; }
.order-card-notes strong { color: var(--warning); }
.order-lines-wrap { overflow-x: auto; margin: 6px 0 4px; }
.order-card table.order-lines { display: table; min-width: 640px; margin: 0; }
.order-card .order-lines input { width: 100%; min-width: 60px; }
.order-card .product-cell { min-width: 230px; vertical-align: top; }
.product-picked { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.order-lines tr.is-suggested .product-picked { color: var(--warning); }
.product-picked:empty { display: none; }
.order-card select.product-pick {
  width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 12px;
}
.product-search { margin-top: 6px; }
.product-results { display: flex; flex-direction: column; margin-top: 4px; max-height: 180px; overflow-y: auto; }
.product-result { padding: 6px 8px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.product-result:hover, .product-result:focus-visible { background: rgba(122, 205, 54, 0.1); outline: none; }
.product-none { padding: 6px 8px; font-size: 12px; color: var(--text-muted); }
.order-lines tr.is-suggested { box-shadow: inset 3px 0 0 var(--warning); }
.order-lines tr.is-missing { box-shadow: inset 3px 0 0 var(--bad); background: rgba(255, 138, 128, 0.05); }
.order-card .add-line-btn { margin-top: 6px; }
.order-card .notes-field { margin-top: 12px; }
.order-card-match { margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.order-card-match:empty { display: none; }
.order-card.is-created .order-card-actions .submit-btn { display: none; }
@media (max-width: 640px) {
  .order-card { padding: 14px; }
  .order-card .field-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Importer chat: instructions under the review card. */
.order-chat { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.order-chat-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.order-chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.order-chat-log:empty { display: none; }
.order-chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.order-chat-msg.is-user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.order-chat-msg.is-assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.order-chat-msg.is-error { color: var(--error); }
.order-chat-form { display: flex; gap: 8px; margin-top: 10px; }
.order-card .order-chat-input { flex: 1; min-width: 0; padding: 10px 12px; font-size: 14px; border-radius: 10px; }

.order-card-created { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--good-bg); font-size: 13px; line-height: 1.45; }
.order-card-created strong { color: var(--good); }
.order-card.is-created .order-lines, .order-card.is-created .field-grid, .order-card.is-created .notes-field { opacity: 0.75; }

/* ---------- Busy buttons: a spinner while a request runs, so it isn't clicked twice ---------- */
button.primary:disabled, button.secondary:disabled, .ghost-btn:disabled { opacity: 0.5; cursor: default; }
button.is-busy:disabled { opacity: 0.85; cursor: progress; }
.btn-spinner {
  display: inline-block;
  width: 0.95em; height: 0.95em;
  margin-right: 7px;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation-duration: 1.6s; } }

/* ---------- Voice dock: ask about the screen you are on (Home, Charts, Apps) ---------- */
.voice-dock {
  position: absolute; right: 16px; bottom: 16px; z-index: 40;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  max-width: min(360px, calc(100% - 32px));
  pointer-events: none;
}
.voice-dock > * { pointer-events: auto; }
body[data-view="chat"] .voice-dock { display: none; }
.voice-fab {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); cursor: pointer;
}
.voice-fab:hover { border-color: var(--accent); }
.voice-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.voice-fab[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.voice-fab.recording, .voice-fab.speaking, .voice-fab.thinking { animation: pulse 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .voice-fab { animation: none !important; } }
/* A new voice answer in Chat while you are on another tab. */
.tab { position: relative; }
.tab-badge {
  position: absolute; top: 5px; left: calc(50% + 7px);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--bg-elevated);
}
.tab-badge[hidden] { display: none; }
.voice-btn { margin-left: 8px; }

/* ---------- Voice settings ---------- */
.voice-settings { z-index: 50; } /* above the voice dock */
.voice-settings .sheet-panel { max-width: 520px; }
.voice-options { display: flex; flex-direction: column; gap: 8px; }
.voice-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px;
}
.voice-option.is-selected { border-color: var(--accent); background: rgba(122, 205, 54, 0.06); }
.voice-option input { margin-top: 3px; accent-color: var(--accent); }
.voice-option-words { display: flex; flex-direction: column; gap: 2px; }
.voice-option-note { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.voice-option-state { font-size: 12px; color: var(--text-muted); }
.voice-option-state.is-ok { color: var(--accent); }
.voice-setup { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.voice-key-form, .voice-pick { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.voice-key-form input, .voice-pick select {
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.voice-key-form .send-btn { align-self: flex-start; }
.voice-setup-actions { display: flex; align-items: center; gap: 14px; }

/* The assistant's "Show me: Sales insights" button under an answer. */
.show-me-btn { display: block; margin-top: 10px; color: var(--accent); font-weight: 600; }
.show-me-btn::before { content: "\2192  "; }

/* ---------- Background work: progress pill in the top bar, and a note when it is done ---------- */
.jobs-pill {
  display: inline-flex; align-items: center; gap: 2px; margin-right: 8px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--accent);
  background: rgba(122, 205, 54, 0.1); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
}
.jobs-pill[hidden] { display: none; }
.jobs-pill .btn-spinner { color: var(--accent); }
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 60;
  max-width: min(440px, calc(100% - 32px)); padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--bg-elevated); color: var(--text);
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Chat: jump to the newest message ---------- */
.jump-wrap { position: relative; height: 0; }
.jump-bottom {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); cursor: pointer;
}
.jump-bottom[hidden] { display: none; }
.jump-bottom:hover { border-color: var(--accent); color: var(--accent); }
.jump-bottom:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Production Management (Apps) ---------- */
.prod-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.prod-chips .chip { display: inline-flex; align-items: center; gap: 6px; }
.prod-chips .chip:disabled { opacity: 0.45; cursor: default; }
.chip-count { font-variant-numeric: tabular-nums; opacity: 0.75; }
.chip-flag { font-size: 11.5px; color: var(--warning); }
.chip-flag.is-running { color: var(--accent); }
.chip[aria-pressed="true"] .chip-flag { color: inherit; }
.prod-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border);
}
.prod-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.prod-check input, .prod-order-head input { accent-color: var(--accent); width: 16px; height: 16px; }
.prod-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prod-message { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; border: 1px solid var(--border); }
.prod-message.tone-good { border-color: rgba(122, 205, 54, 0.5); }
.prod-message.tone-warning { border-color: var(--warning); }
.prod-message.tone-bad { border-color: var(--bad); color: var(--bad); }
.prod-orders { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.prod-order { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); }
.prod-order.is-running { border-color: rgba(122, 205, 54, 0.55); }
.prod-order-head { display: flex; align-items: flex-start; gap: 12px; }
.prod-order-head input { margin-top: 3px; flex: none; }
.prod-order-words { flex: 1; min-width: 0; }
.prod-order-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.prod-order-title span { color: var(--text-muted); font-size: 13.5px; }
.prod-order-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; font-size: 12.5px; color: var(--text-muted); }
.prod-order-facts .is-late { color: var(--bad); }
.prod-running { color: var(--accent); font-weight: 600; }
.prod-running::before { content: "\25CF  "; }
.prod-lines { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 13px; }
.prod-lines th { text-align: left; font-weight: 500; color: var(--text-muted); padding: 4px 8px 4px 0; }
.prod-lines td { padding: 5px 8px 5px 0; border-top: 1px solid var(--border); vertical-align: middle; }
.prod-lines td.num { font-variant-numeric: tabular-nums; }
.prod-lines td.is-here { color: var(--accent); font-weight: 600; }
.prod-lines tr.is-running td:first-child::before { content: "\25CF "; color: var(--accent); }
.prod-file { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.prod-line-actions { white-space: nowrap; text-align: right; }
.prod-line-actions .ghost-btn { padding: 4px 9px; font-size: 12px; margin-left: 4px; }
@media (max-width: 640px) {
  .prod-order-head { flex-wrap: wrap; }
  .prod-order-head .prod-actions { width: 100%; padding-left: 28px; }
  .prod-lines thead { display: none; }
  .prod-lines tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 6px 0; border-top: 1px solid var(--border); }
  .prod-lines td { border: 0; padding: 0; }
  .prod-lines td:nth-child(3), .prod-lines td:nth-child(4), .prod-lines td:nth-child(5), .prod-lines td:nth-child(6) { grid-column: 2; font-size: 12px; color: var(--text-muted); }
  .prod-lines td.prod-line-actions { grid-column: 1 / -1; text-align: left; }
  .prod-file { max-width: none; }
}
.prod-message { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.prod-message .ask-link { font-size: 12.5px; padding: 0; }
.prod-details {
  flex-basis: 100%; max-height: 280px; overflow: auto; margin: 6px 0 0; padding: 10px;
  border-radius: 8px; background: var(--bg); color: var(--text-muted); font-size: 12px; white-space: pre-wrap; word-break: break-word;
}
.prod-details[hidden] { display: none; }

/* ---------- Getting ready (public/loading.js) ---------- */
/* After sign-in: order tickets ride a conveyor into a stack while the order history loads. */
.load-splash {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(11, 11, 12, 0.92); backdrop-filter: blur(6px);
  animation: load-fade-in 0.25s ease-out;
}
.load-splash.is-leaving { opacity: 0; transition: opacity 0.35s ease; }
.load-card {
  width: min(420px, 100%); padding: 28px 24px 18px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--bg-elevated); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.load-title { margin: 18px 0 6px; font-size: 20px; }
.load-detail { margin: 0 0 16px; min-height: 2.6em; color: var(--text-muted); font-size: 14px; }
.load-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.load-bar-fill {
  display: block; width: 8%; height: 100%; border-radius: 3px; background: var(--accent);
  transition: width 0.5s ease;
}
.load-splash.is-done .load-bar-fill { background: var(--ok); }
.load-skip { margin-top: 12px; font-size: 13px; }

.load-scene { display: flex; align-items: center; justify-content: center; height: 112px; }
.load-scene .load-book { transform: scale(1.7); }
.load-splash.is-done .load-book-page { animation: none; }
.load-splash.is-done .load-book-glow { animation: none; opacity: 0; }
.load-orders { position: relative; height: 112px; margin: 0 auto; width: 300px; max-width: 100%; overflow: hidden; }
.load-belt { position: absolute; left: 0; right: 70px; bottom: 26px; height: 46px; }
.load-belt-floor {
  position: absolute; left: 0; right: 70px; bottom: 18px; height: 6px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, #2c2c30 0 10px, #1d1d20 10px 20px);
  animation: load-belt-run 0.6s linear infinite;
}
.load-ticket {
  position: absolute; bottom: 0; left: -50px; width: 40px; height: 46px; padding: 7px 6px;
  box-sizing: border-box; border-radius: 4px; background: #f2f2f0; display: flex; flex-direction: column; gap: 4px;
  animation: load-ticket-ride 2.8s linear infinite;
}
.load-ticket-line { display: block; height: 3px; border-radius: 2px; background: #b8b8b2; }
.load-ticket-line.short { width: 60%; }
.load-ticket-stamp {
  margin-top: auto; align-self: flex-end; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--accent); box-sizing: border-box;
}
.load-stack { position: absolute; right: 8px; bottom: 18px; width: 54px; height: 70px; }
.load-stack-sheet {
  position: absolute; left: 4px; right: 4px; height: 8px; border-radius: 2px; background: #d9d9d3;
  box-shadow: 0 1px 0 #9a9a95;
}
.load-stack-sheet:nth-child(1) { bottom: 0; }
.load-stack-sheet:nth-child(2) { bottom: 9px; }
.load-stack-sheet:nth-child(3) { bottom: 18px; }
.load-stack-sheet:nth-child(4) { bottom: 27px; animation: load-stack-grow 2.8s ease-in-out infinite; }
@keyframes load-ticket-ride {
  0% { transform: translateX(0) rotate(0); opacity: 0; }
  8% { opacity: 1; }
  70% { transform: translateX(240px) rotate(0); opacity: 1; }
  85% { transform: translateX(262px) translateY(-6px) rotate(80deg) scale(0.9); opacity: 1; }
  100% { transform: translateX(268px) translateY(14px) rotate(90deg) scale(0.8); opacity: 0; }
}
@keyframes load-belt-run { to { background-position: 20px 0; } }
@keyframes load-stack-grow { 0%, 60% { transform: translateY(-10px); opacity: 0; } 85%, 100% { transform: none; opacity: 1; } }
@keyframes load-fade-in { from { opacity: 0; } }

/* In Chat, once the key is connected: a book whose pages turn while the manuals are read. */
.load-manuals {
  display: flex; align-items: center; gap: 16px; margin: 8px 0 16px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated);
  animation: load-fade-in 0.25s ease-out;
}
.load-manuals.is-leaving { opacity: 0; transition: opacity 0.4s ease; }
.load-manuals-title { font-weight: 600; }
.load-manuals-detail { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.load-manuals.is-done .load-manuals-title::before { content: "✓ "; color: var(--ok); }
.load-manuals.is-failed .load-manuals-title { color: var(--text-muted); }

.load-book { position: relative; flex: 0 0 auto; width: 72px; height: 50px; perspective: 260px; }
.load-book-cover {
  position: absolute; top: 0; width: 36px; height: 50px; box-sizing: border-box; background: #2a3a1f;
  border: 2px solid var(--accent);
}
.load-book-cover.left { left: 0; border-radius: 6px 2px 2px 6px; }
.load-book-cover.right { right: 0; border-radius: 2px 6px 6px 2px; }
.load-book-page {
  position: absolute; top: 3px; left: 36px; width: 32px; height: 44px; padding: 6px 4px; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 4px; background: #f2f2f0; border-radius: 0 3px 3px 0;
  transform-origin: left center; animation: load-page-turn 1.8s ease-in-out infinite;
}
.load-book-page span { display: block; height: 2px; border-radius: 1px; background: #b8b8b2; }
.load-book-page span.short { width: 60%; }
.load-book::before {
  content: ""; position: absolute; top: 3px; left: 4px; width: 32px; height: 44px; background: #e6e6e0;
  border-radius: 3px 0 0 3px;
}
.load-book-glow {
  position: absolute; inset: -6px; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 18px rgba(122, 205, 54, 0.35); animation: load-glow 1.8s ease-in-out infinite;
}
.load-manuals.is-done .load-book-page, .load-manuals.is-failed .load-book-page { animation: none; }
.load-manuals.is-done .load-book-glow, .load-manuals.is-failed .load-book-glow { animation: none; opacity: 0; }
@keyframes load-page-turn {
  0%, 15% { transform: rotateY(0); }
  60%, 100% { transform: rotateY(-180deg); }
}
@keyframes load-glow { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .load-ticket, .load-belt-floor, .load-stack-sheet, .load-book-page, .load-book-glow { animation: none; }
  .load-ticket { opacity: 0; }
  .load-ticket:first-child { opacity: 1; left: 120px; }
}

/* "Remember this key": the checkbox under a key field, and the saved key in the Models panel. */
.remember-key { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.remember-key input { margin-top: 2px; accent-color: var(--accent); }
.models-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }

/* ---------- Quick Orders (public/quickOrder.js) ---------- */
#view-apps .view-inner:has(.qo, .qo-checkout) { max-width: 1180px; }
.qo-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.qo-search {
  flex: 1 1 240px; min-width: 0; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font: inherit; font-size: 14px;
}
.qo-search:focus, .qo-field input:focus, .qo-field textarea:focus, .qo-type select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.qo-type { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.qo-type select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text); font: inherit; font-size: 14px; max-width: 220px;
}
.qo-cart-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; }
.qo-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent-text); color: var(--accent);
  font-size: 12px; text-align: center;
}
.qo-note { margin: 0 0 10px; font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.qo-main { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.qo-cats { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 12px; }
.qo-cat {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border: none; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.qo-cat:hover { background: var(--bg-elevated); }
.qo-cat.is-active { background: rgba(122, 205, 54, 0.12); color: var(--accent); font-weight: 600; }
.qo-cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.qo-cat-n { color: var(--text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.qo-results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.qo-results-head h2 { margin: 0; font-size: 17px; }
.qo-results-head span { font-size: 12.5px; color: var(--text-muted); }
.qo-results .screen-message { text-align: left; padding: 12px 0; }
.qo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.qo-card {
  display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--bg-elevated); transition: border-color 0.15s ease;
}
.qo-card:hover { border-color: rgba(122, 205, 54, 0.5); }
.qo-tile {
  --hue: 100;
  display: flex; align-items: center; justify-content: center; aspect-ratio: 5 / 2; width: 100%; border: none;
  background: linear-gradient(135deg, hsl(var(--hue) 35% 22%), hsl(calc(var(--hue) + 40) 30% 14%));
  color: hsl(var(--hue) 60% 78%); font: inherit; font-size: 26px; font-weight: 700; letter-spacing: 0.04em; cursor: pointer;
}
.qo-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.qo-tile.is-small { width: 44px; height: 44px; aspect-ratio: auto; border-radius: 10px; font-size: 14px; flex: none; cursor: default; }
.qo-card-words { flex: 1; padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 5px; }
.qo-card-words h3 { margin: 0; font-size: 14.5px; line-height: 1.3; }
.qo-card-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--text-muted); }
.qo-badge { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); }
.qo-asks { margin: 0; font-size: 12px; color: var(--text-muted); }
.qo-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px 14px; }
.qo-in-cart { font-size: 12px; color: var(--accent); }
.qo-more { display: block; margin: 16px auto 0; }
.qo-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.qo-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(0, 0, 0, 0.55);
}
.qo-panel {
  width: min(480px, 100%); height: 100%; overflow-y: auto; padding: 18px 20px 24px; background: var(--bg-elevated);
  border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px;
}
.qo-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.qo-panel-head h2 { margin: 0; font-size: 19px; line-height: 1.3; }
.qo-x { border: none; background: transparent; color: var(--text-muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.qo-x:hover { color: var(--text); }
.qo-desc { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); }
.qo-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.qo-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.qo-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.qo-field.is-wide { grid-column: 1 / -1; }
.qo-field.is-check { flex-direction: row; align-items: center; color: var(--text); }
.qo-field.is-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.qo-field input:not([type="checkbox"]), .qo-field textarea {
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.qo-field textarea { min-height: 70px; resize: vertical; }
.qo-field small { font-size: 11.5px; line-height: 1.4; }
.qo-field input::placeholder { color: var(--text-muted); opacity: 0.7; }
.qo-qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; width: max-content; }
.qo-qty input {
  width: 64px; padding: 8px 4px; border: none; border-radius: 0; background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px; text-align: center; -moz-appearance: textfield;
}
.qo-qty input::-webkit-inner-spin-button, .qo-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qo-qty-btn { width: 34px; padding: 8px 0; border: none; background: transparent; color: var(--text); font-size: 16px; cursor: pointer; }
.qo-qty-btn:hover { background: rgba(122, 205, 54, 0.12); }
.qo-more-fields summary { cursor: pointer; font-size: 13.5px; color: var(--accent); margin-bottom: 10px; }
.qo-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.qo-actions .send-btn { padding: 10px 18px; border-radius: 10px; }
.qo-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.qo-line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.qo-line:last-child { border-bottom: none; }
.qo-line-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.qo-line-opts { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.qo-line-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 4px; font-size: 13px; }
.qo-lines.is-compact .qo-line { padding: 9px 0; }
.qo-cart-body { flex: 1; }
.qo-cart-foot {
  position: sticky; bottom: -24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -20px -24px; padding: 14px 20px 18px; background: var(--bg-elevated); border-top: 1px solid var(--border);
}
.qo-cart-foot:empty { display: none; }
.qo-total { font-size: 13.5px; color: var(--text-muted); }
.qo-cart-foot .send-btn { padding: 10px 18px; border-radius: 10px; }
.qo-checkout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; margin-top: 12px; }
.qo-checkout-fields { display: flex; flex-direction: column; gap: 16px; }
.qo-section { margin: 0; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated); }
.qo-section legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.qo-section .qo-note { margin-top: 4px; }
.qo-summary {
  position: sticky; top: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated);
  display: flex; flex-direction: column; gap: 10px;
}
.qo-summary h2 { margin: 0; font-size: 16px; }
.qo-summary .link-btn { align-self: flex-start; font-size: 13px; }
.qo-submit { padding: 12px 18px; border-radius: 10px; font-size: 15px; }
.qo-done { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.qo-done .order-card-created, .qo-done .order-card-notes { margin: 0; }
.qo-done .qo-actions { justify-content: flex-start; }
.qo-not-saved { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.qo-not-saved li { display: flex; flex-direction: column; }
.qo-not-saved small { color: var(--text-muted); }

@media (max-width: 760px) {
  .qo-main { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .qo-cats { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .qo-cat { flex: none; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; }
  .qo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .qo-card-foot { flex-direction: column; align-items: stretch; }
  .qo-checkout-grid { grid-template-columns: minmax(0, 1fr); }
  .qo-summary { position: static; }
  .qo-type { flex: 1 1 100%; }
  .qo-type select { flex: 1; max-width: none; }
}
