:root {
  color-scheme: light;
  --ink: #2a1718;
  --muted: #776a69;
  --navy: #9f1d22;
  --navy-2: #c22f32;
  --blue: #d94a3f;
  --sky: #fff0ee;
  --green: #18865e;
  --green-soft: #e8f7f0;
  --amber: #a96800;
  --amber-soft: #fff4d8;
  --red: #b3261e;
  --red-soft: #fff0ee;
  --surface: #ffffff;
  --page: #fff8f7;
  --line: #f0d8d4;
  --shadow: 0 12px 32px rgba(127, 29, 29, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.auth-loading {
  overflow-x: hidden;
}

.site-registration {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  padding: 20px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
  overflow-wrap: anywhere;
}

.site-registration a {
  color: inherit;
  text-underline-offset: 3px;
}

.global-sync-status {
  display: block;
  width: 100%;
  padding: 9px 16px;
  border: 0;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  text-align: center;
}

.order-toolbar,
.customer-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-left: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.search-field svg,
.customer-actions svg,
.statement-actions svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.search-field input {
  min-width: 0;
  border: 0;
  background: transparent;
}

.customer-row.customer-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.customer-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.customer-actions button,
.statement-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
}

.statement-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
  line-height: 1.7;
  font-size: 14px;
}

#statement-text {
  min-height: 210px;
  line-height: 1.8;
  font-size: 13px;
  resize: vertical;
}

#customer-age {
  grid-column: 1 / -1;
  max-width: 260px;
}

.aging-warning {
  color: var(--amber);
}

.statement-aging {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.price-options {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.price-options summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.price-options h4 {
  margin: 18px 0 10px;
  font-size: 13px;
}

.price-option-list {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

.price-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: end;
}

.price-option-row label,
.price-option-row input {
  min-width: 0;
  width: 100%;
}

.price-option-row label > span {
  min-height: 36px;
  line-height: 18px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.price-option-row .cost-icon-button {
  width: 36px;
  height: 44px;
  margin-bottom: 1px;
}

.row-main,
.dialog-heading > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cost-price-search {
  margin: 0;
}

.cost-price-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.cost-price-toolbar .search-field {
  display: flex;
  flex: 1 1 200px;
}

.cost-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cost-add-button svg,
.cost-icon-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.product-search-block {
  margin-bottom: 15px;
}

.product-search-field {
  min-height: 47px;
  padding-left: 12px;
}

.product-search-field input {
  width: 100%;
  min-height: 45px;
  padding: 0;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cost-price-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 2px;
}

.cost-price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.cost-price-row:last-child {
  border-bottom: 0;
}

.cost-price-main,
.cost-price-actions {
  min-width: 0;
}

.cost-price-main strong,
.cost-price-main span,
.cost-price-main small {
  display: block;
  overflow-wrap: anywhere;
}

.cost-price-main span,
.cost-price-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.cost-price-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  align-items: center;
  gap: 8px;
}

.cost-price-value span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.cost-price-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cost-icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--navy);
}

.cost-icon-button.danger {
  color: var(--red);
}

.cost-icon-button:disabled,
.cost-add-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cost-edit-error {
  color: var(--red);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .cost-price-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .order-toolbar,
  .customer-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }
  .statement-actions button {
    flex: 1 1 120px;
  }
}

[hidden] {
  display: none !important;
}

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--page);
}

.auth-panel {
  width: min(100%, 470px);
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 19px;
  box-shadow: 0 10px 24px rgba(159, 29, 34, 0.2);
}

.auth-panel h1 {
  margin-bottom: 8px;
}

.auth-intro {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--page);
  border-radius: 13px;
}

.auth-tabs button {
  min-height: 40px;
  border: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 10px;
  font-weight: 700;
}

.auth-tabs button.active {
  color: var(--navy);
  background: #fff;
  box-shadow: 0 3px 12px rgba(127, 29, 29, 0.08);
}

.auth-form {
  display: grid;
  gap: 13px;
}

.auth-form label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.auth-demo-button {
  margin-top: 11px;
}

.auth-panel .secondary-button.full {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.secondary-button[href] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: inherit;
  text-decoration: none;
}

.secondary-button[href]:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 3px;
}

.auth-status {
  min-height: 20px;
  margin: 13px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-status.error {
  color: var(--red);
}

.auth-status.success {
  color: var(--green);
}

.sync-status {
  padding: 10px 12px;
  border: 1px solid var(--amber);
  border-radius: 6px;
  color: var(--ink);
  background: var(--amber-soft);
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(217, 74, 63, 0.25);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--page);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: rgba(255, 248, 247, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(240, 216, 212, 0.85);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-right: auto;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(159, 29, 34, 0.22);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.avatar-button,
.icon-button {
  border: 0;
  color: var(--navy);
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(127, 29, 29, 0.08);
}

.avatar-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: 700;
}

.icon-button {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 12px;
  font-size: 13px;
}

#app-main {
  padding: 22px 20px calc(104px + env(safe-area-inset-bottom));
}

.view {
  display: none;
  animation: view-in 0.2s ease-out;
}

.view.active {
  display: block;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 5vw, 34px);
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.welcome-row,
.page-heading,
.section-heading,
.assistant-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.welcome-row,
.page-heading {
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.demo-badge,
.privacy-pill,
.count-pill,
.status-pill,
.source-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  white-space: nowrap;
}

.demo-badge,
.privacy-pill,
.count-pill {
  padding: 7px 10px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 12px;
  font-weight: 700;
}

.privacy-pill {
  color: var(--green);
  background: var(--green-soft);
}

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

.metric-card {
  min-height: 118px;
  padding: 17px;
  border: 1px solid rgba(240, 216, 212, 0.85);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 6px 22px rgba(127, 29, 29, 0.04);
}

.metric-card span,
.metric-card small {
  display: block;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 9px 0 5px;
  font-size: clamp(24px, 5vw, 31px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

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

.metric-card.alert strong {
  color: var(--red);
}

.assistant-card,
.form-card,
.settings-card {
  border: 1px solid rgba(240, 216, 212, 0.9);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.assistant-card {
  padding: 20px;
  overflow: hidden;
}

.assistant-heading {
  margin-bottom: 15px;
}

.assistant-intro {
  max-width: 560px;
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.voice-launch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.voice-launch svg,
.voice-icon-button svg,
.voice-control svg,
.voice-send svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.voice-launch svg:last-child { width: 17px; height: 17px; }

body.voice-open { overflow: hidden; }

.voice-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(42, 23, 24, 0.35);
}

.voice-window {
  display: flex;
  flex-direction: column;
  width: min(100%, 760px);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px rgba(42, 23, 24, 0.12);
}

.voice-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.voice-heading { min-width: 0; flex: 1; }
.voice-heading strong, .voice-heading span { display: block; }
.voice-heading strong { font-size: 16px; }
.voice-heading span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.voice-heading span { overflow-wrap: anywhere; }

.voice-dialect {
  flex: none;
  width: 102px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

.voice-icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--page);
  color: var(--navy);
}

@media (max-width: 380px) {
  .voice-header { gap: 7px; padding-left: 10px; padding-right: 10px; }
  .voice-dialect { width: 90px; padding-left: 5px; padding-right: 5px; }
  .voice-icon-button { width: 38px; height: 38px; }
}

.voice-transcript {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 22px 18px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
}

.voice-transcript .message { max-width: min(85%, 540px); }
.voice-transcript .message { flex-shrink: 0; border-radius: 8px; overflow-wrap: anywhere; }
.voice-transcript .message.assistant { background: var(--page); }
.voice-transcript .message.user { background: var(--navy); }

.voice-bottom {
  flex: none;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.voice-interim {
  min-height: 21px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-listening-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  margin-bottom: 8px;
  color: var(--navy);
}

.voice-listening-indicator span {
  width: 4px;
  height: 5px;
  border-radius: 3px;
  background: currentColor;
  transition: height 0.2s ease;
}

.voice-listening-indicator[data-state="listening"] span,
.voice-listening-indicator[data-state="speaking"] span {
  animation: voice-level 0.85s ease-in-out infinite alternate;
}
.voice-listening-indicator span:nth-child(2),
.voice-listening-indicator span:nth-child(4) { animation-delay: 0.2s; }
.voice-listening-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes voice-level { to { height: 25px; } }

.voice-controls { display: flex; justify-content: center; gap: 8px; margin-bottom: 13px; }
.voice-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

.voice-input-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 5px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.voice-input-row:focus-within { border-color: var(--navy); }
.voice-input-row input {
  flex: 1;
  min-width: 0;
  min-height: 39px;
  padding: 0;
  border: 0;
  outline: 0;
  font-size: 16px;
}
.voice-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 39px;
  height: 39px;
  border: 0;
  border-radius: 7px;
  background: var(--navy);
  color: #fff;
}
.voice-footnote {
  margin: 9px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.assistant-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 290px;
  padding: 2px 2px 4px;
  overflow-y: auto;
}

.message {
  max-width: min(88%, 640px);
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  color: var(--ink);
  background: var(--sky);
  border-bottom-left-radius: 5px;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--navy);
  border-bottom-right-radius: 5px;
}

.message-time {
  display: block;
  margin-top: 5px;
  font-size: 10px;
  opacity: 0.65;
}

.message-action {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  white-space: normal;
}

.message-action button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

.quick-commands {
  display: flex;
  gap: 8px;
  margin: 15px 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-commands::-webkit-scrollbar {
  display: none;
}

.quick-commands button,
.filter-row button,
.segment-tabs button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: #fff;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.assistant-input-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px;
  background: var(--page);
  border-radius: 17px;
}

.assistant-input-row > svg {
  width: 20px;
  height: 20px;
  margin-left: 4px;
  color: var(--navy);
}

.assistant-input-row input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
}

.mic-button,
.send-button {
  border: 0;
  font-weight: 700;
}

.mic-button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--navy));
  border-radius: 13px;
}

.mic-dot {
  width: 9px;
  height: 9px;
  background: #fff;
  border-radius: 50%;
}

.mic-button.listening {
  background: var(--red);
}

.mic-button.listening .mic-dot {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.7);
    opacity: 0.5;
  }
}

.send-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
}

.settings-note {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.assistant-footnote {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.insight-list {
  display: grid;
  gap: 9px;
}

.insight-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.insight-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--navy);
  background: var(--sky);
}

.insight-icon svg {
  width: 19px;
  height: 19px;
}

.insight-main {
  min-width: 0;
}

.insight-main strong,
.insight-main span {
  display: block;
}

.insight-main strong {
  font-size: 14px;
}

.insight-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.insight-row button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--navy);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.insight-row.danger {
  border-color: rgba(182, 56, 56, 0.32);
  background: var(--red-soft);
}

.insight-row.danger .insight-icon {
  color: var(--red);
  background: #fff;
}

.insight-row.warn .insight-icon {
  color: var(--amber);
  background: var(--amber-soft);
}

.insight-row.good .insight-icon {
  color: var(--green);
  background: var(--green-soft);
}

.team-form {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr 0.8fr auto;
  gap: 8px;
  margin-top: 15px;
}

.team-form input,
.team-form select,
.team-form button {
  min-width: 0;
}

.team-form button {
  min-height: 47px;
}

.team-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.team-main strong,
.team-main span {
  display: block;
}

.team-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.team-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.team-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: #fff;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}

.team-row.disabled {
  opacity: 0.58;
}

.section-block {
  margin-top: 26px;
}

.sop-workbench {
  padding: 17px;
  border: 1px solid rgba(240, 216, 212, 0.9);
  background: var(--surface);
  border-radius: 17px;
  box-shadow: 0 6px 22px rgba(127, 29, 29, 0.04);
}
.sop-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.sop-stats button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--page); text-align: left; }
.sop-stats strong { font-size: 22px; line-height: 1; }
.sop-stats span, .sop-task-row small { color: var(--muted); font-size: 11px; }
.sop-task-list { display: grid; gap: 7px; }
.sop-task-row { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; padding: 10px 0; border: 0; border-top: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.sop-task-main { display: block; min-width: 0; flex: 1; }
.sop-task-main strong, .sop-task-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sop-task-status { flex: none; padding: 4px 7px; color: var(--amber); background: var(--amber-soft); border-radius: 999px; font-size: 11px; }
.sop-task-status.active { color: var(--blue); background: var(--blue-soft); }
.sop-action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sop-action-row button { display: inline-flex; align-items: center; gap: 5px; }
.sop-action-row svg { width: 16px; height: 16px; }
.sop-empty { padding: 18px 0; color: var(--muted); font-size: 13px; text-align: center; }
.sop-order-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0; padding: 12px; color: var(--muted); background: var(--page); border-radius: 10px; font-size: 12px; }
.sop-order-summary strong { color: var(--red); }
.sop-script-list, .sop-reward-list { display: grid; gap: 8px; margin-top: 12px; max-height: 52vh; overflow: auto; }
.sop-script-row, .sop-reward-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); background: var(--page); border-radius: 10px; }
.sop-script-row > div, .sop-reward-row > div { min-width: 0; }
.sop-script-row strong, .sop-reward-row strong, .sop-reward-row span { overflow-wrap: anywhere; }
.sop-script-row > .cost-icon-button { flex: 0 0 36px; }
.sop-reward-row { flex-wrap: wrap; border-radius: 8px; }
.sop-reward-row > div:first-child { flex: 1 1 200px; }
.sop-reward-row > .sop-action-row { align-content: start; flex: 0 1 auto; }
#sop-list-results .sop-script-row { border-radius: 8px; }
.dialog-card label.search-field { display: flex; }
.dialog-card label.search-field input { flex: 1; min-width: 0; }
.sop-script-row strong, .sop-reward-row strong, .sop-reward-row span, .sop-reward-row small { display: block; }
.sop-script-row p, .sop-reward-row small { margin: 5px 0 0; color: var(--muted); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.sop-script-row .eyebrow { margin-bottom: 3px; }
.sop-review-history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sop-review-history p { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.text-button {
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.order-list {
  display: grid;
  gap: 11px;
  margin-top: 14px;
}

.order-list.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.order-card {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 17px;
}

.order-card.overdue {
  border-color: rgba(182, 56, 56, 0.35);
  background: linear-gradient(180deg, #fff, var(--red-soft));
}

.order-top,
.order-meta,
.order-bottom,
.ledger-row,
.inventory-row,
.customer-row,
.price-rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-top {
  align-items: flex-start;
}

.order-number {
  color: var(--muted);
  font-size: 11px;
}

.status-pill,
.source-pill {
  padding: 5px 8px;
  color: var(--navy);
  background: var(--sky);
  font-size: 11px;
  font-weight: 700;
}

.status-pill.danger {
  color: var(--red);
  background: var(--red-soft);
}

.status-pill.done {
  color: var(--green);
  background: var(--green-soft);
}

.order-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.order-amount {
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.order-balance {
  color: var(--red);
  font-size: 12px;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.order-actions button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: #fff;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.order-actions button.primary {
  color: #fff;
  border-color: var(--navy);
  background: var(--navy);
}

.form-card,
.settings-card {
  padding: 20px;
}

.settings-card + .settings-card {
  margin-top: 15px;
}

.form-card label,
.settings-card label {
  display: block;
}

.form-card label > span,
.settings-card label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  border-radius: 12px;
}

input,
select {
  min-height: 47px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.form-card > label,
.form-grid,
.toggle-grid {
  margin-bottom: 15px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.check-row span {
  margin: 0 !important;
  color: var(--ink) !important;
}

.quote-panel {
  margin: 4px 0 17px;
  padding: 17px;
  background: var(--sky);
  border-radius: 15px;
}

.quote-total {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.staff-shortcut { margin: 0 0 20px; }
.attendance-section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.attendance-section h2 { font-size: 20px; }
.attendance-section .section-heading { gap: 10px; flex-wrap: wrap; }
.attendance-times, .attendance-punch, .attendance-filters, .employee-filter {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0;
}
.attendance-times span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.attendance-times strong { font-size: 16px; overflow-wrap: anywhere; }
.attendance-punch button { min-height: 52px; }
.attendance-rule, .attendance-actions { display: flex; align-items: center; gap: 8px; }
.attendance-rule { justify-content: space-between; font-size: 13px; color: var(--muted); }
.attendance-filters input, .attendance-filters select, .employee-filter input, .employee-filter select,
#attendance-correct-in, #attendance-correct-out { width: 100%; min-width: 0; max-width: 100%; }
.attendance-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px 0; }
.attendance-summary span { color: var(--muted); font-size: 12px; display: block; }
.attendance-summary strong { display: block; margin-top: 5px; font-size: 22px; overflow-wrap: anywhere; }
.attendance-people > div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.attendance-people span { font-size: 12px; color: var(--muted); }
.attendance-record { padding: 15px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.attendance-record .section-heading { margin-bottom: 0; }
.attendance-record p, .attendance-record-times { font-size: 13px; line-height: 1.7; }
.attendance-record-times { display: grid; gap: 4px; color: var(--muted); }
.attendance-record details { margin-top: 10px; font-size: 12px; color: var(--muted); }
.attendance-record summary, #team-create-details summary { cursor: pointer; min-height: 36px; padding: 8px 0; }
.attendance-record details p { padding: 8px 0; border-top: 1px solid var(--line); }
#team-settings-card .team-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#team-settings-card .team-form button { grid-column: 1 / -1; }
#team-settings-card .team-main { min-width: 0; overflow-wrap: anywhere; }
#team-settings-card .team-actions { flex-shrink: 0; }
.employee-filter { grid-template-columns: minmax(0, 1fr) minmax(110px, 150px); }
.employee-filter .search-field { margin: 0; }
@media (max-width: 560px) {
  .fast-ledger-card { align-items: stretch; flex-direction: column; }
  .fast-ledger-card button { width: 100%; }
  .attendance-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #team-settings-card .team-form, .employee-filter { grid-template-columns: 1fr; }
  #team-settings-card .team-row { flex-wrap: wrap; }
  .attendance-people > div { flex-direction: column; gap: 4px; }
}

.quote-total strong {
  flex: 0 0 auto;
  max-width: 100%;
  margin-left: auto;
  font-size: 29px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.quote-total > div { min-width: 0; flex: 1 1 150px; }

.quote-breakdown {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  font-size: 13px;
}

.quote-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.quote-breakdown dt { color: var(--muted); }
.quote-breakdown dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.form-wide { grid-column: 1 / -1; }
.ledger-receipt-link { margin: 0 0 16px; }
.fast-ledger-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 16px;
  padding: 16px;
  border: 1px solid rgba(159, 29, 34, .2);
  border-radius: 14px;
  background: rgba(159, 29, 34, .05);
}
.fast-ledger-card h2 { margin: 2px 0 4px; font-size: 18px; }
.fast-ledger-card p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.fast-ledger-card button { flex: 0 0 auto; }
.manual-price-field { max-width: 360px; }
.manual-price-field .field-hint { margin-top: 5px; }
.stock-adjust-form .field-hint { margin: 0; }
.order-fees:has(label:not([hidden])) { margin-top: 12px; }

.quote-formula,
.quote-warning {
  margin: 9px 0 0;
  font-size: 12px;
  line-height: 1.6;
}

.quote-formula {
  color: var(--muted);
}

.quote-warning {
  color: var(--amber);
  font-weight: 650;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--navy);
  color: #fff;
  background: var(--navy);
}

.primary-button.small {
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
}

.primary-button.full {
  width: 100%;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--navy);
  background: #fff;
}

.danger-button {
  border: 1px solid rgba(182, 56, 56, 0.35);
  color: var(--red);
  background: var(--red-soft);
}

.filter-row,
.segment-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar,
.segment-tabs::-webkit-scrollbar {
  display: none;
}

.filter-row button.active,
.segment-tabs button.active {
  color: #fff;
  border-color: var(--navy);
  background: var(--navy);
}

.business-panel {
  display: none;
}

.business-panel.active {
  display: block;
}

.business-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 13px;
}

.business-stat {
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.business-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.business-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.list-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  overflow: hidden;
}

.ledger-row,
.inventory-row,
.customer-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.ledger-row:last-child,
.inventory-row:last-child,
.customer-row:last-child {
  border-bottom: 0;
}

.row-main strong,
.row-main span {
  display: block;
}

.row-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.money {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.money.income {
  color: var(--green);
}

.money.expense,
.money.debt {
  color: var(--red);
}

.inventory-level {
  min-width: 88px;
  text-align: right;
}

.inventory-level strong,
.inventory-level span {
  display: block;
}

.inventory-level span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.inventory-level.low strong {
  color: var(--red);
}

.inventory-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.inventory-toolbar .search-field { flex: 1 1 220px; min-width: 0; }
.inventory-toolbar .search-field input { min-width: 0; }
.inventory-toolbar .check-row { border: 0; padding: 0; }
#inventory-list { border-radius: 8px; }
#inventory-list .inventory-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
#inventory-list .row-main, #inventory-list .inventory-level { min-width: 0; overflow-wrap: anywhere; }
#inventory-list .inventory-level { max-width: 130px; }
.inventory-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.inventory-actions .cost-icon-button { width: 40px; height: 40px; flex: 0 0 40px; }
.inventory-section-title { margin: 24px 0 12px; font-size: 17px; }
#inventory-more-history { margin-top: 12px; }

.material-usage {
  color: var(--blue) !important;
}

.inventory-movements {
  margin-top: 18px;
}

.inventory-movements .section-heading {
  margin-bottom: 10px;
}

.inventory-movements h3 {
  margin-bottom: 0;
}

.movement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.movement-row:last-child {
  border-bottom: 0;
}

.movement-main strong,
.movement-main span,
.movement-delta strong,
.movement-delta span {
  display: block;
}

.movement-main span,
.movement-delta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.movement-delta {
  min-width: 92px;
  text-align: right;
}

.movement-delta.in strong {
  color: var(--green);
}

.movement-delta.out strong {
  color: var(--amber);
}

.stock-adjust-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(90px, 0.8fr) minmax(80px, 0.7fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stock-adjust-form select,
.stock-adjust-form input,
.stock-adjust-form button {
  min-width: 0;
}

.stock-adjust-form button {
  min-height: 47px;
}

.stock-note {
  margin-top: 0;
  margin-bottom: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: 0.75fr 1.2fr 0.7fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form input,
.inline-form select {
  min-width: 0;
}

.inline-form button {
  min-height: 47px;
}

.price-rule-list {
  display: grid;
  gap: 0;
  margin-top: 15px;
  max-height: 620px;
  overflow: auto;
  padding-right: 2px;
}

.price-rule {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

#price-rule-category,
#price-rule-status {
  width: auto;
  max-width: 100%;
  flex: 0 1 170px;
}

.price-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.price-check {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  min-height: 44px;
  margin: 0;
}

.price-check input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  accent-color: var(--red);
}

.price-batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-block: 1px solid var(--line);
}

.price-batch-toolbar .check-row {
  margin: 0;
}

#price-selected-count {
  color: var(--muted);
  font-size: 12px;
}

.price-preview-list {
  max-height: 300px;
  overflow: auto;
}

.price-preview-list > div {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.price-preview-list span {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 560px) {
  .price-batch-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #price-batch-delete,
  #price-selected-count {
    justify-self: end;
  }
}

#price-edit-value:read-only,
#price-edit-unit:disabled {
  background: var(--page);
  color: var(--muted);
}

.price-rule.demo {
  border-left: 4px solid #e0a934;
}

.price-rule.public {
  border-left: 4px solid var(--blue);
}

.source-pill {
  color: var(--muted);
  background: var(--page);
}

.price-rule-edit {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 11px;
}

.price-rule-edit label > span {
  font-size: 11px;
}

.price-rule-edit input {
  min-height: 42px;
}

.alias-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.alias-chip-row span {
  padding: 5px 9px;
  color: var(--navy);
  background: var(--sky);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

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

.learning-form input,
.learning-form select,
.learning-form button {
  min-width: 0;
}

.learning-form .check-row {
  margin: 0;
  min-height: 47px;
}

.learning-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 17px;
}

.learning-columns h3,
.learning-feedback h3 {
  margin-bottom: 9px;
}

.learning-feedback {
  margin-top: 16px;
}

.learning-list {
  display: grid;
  gap: 8px;
}

.learning-row,
.learning-feedback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.learning-main {
  min-width: 0;
}

.learning-main strong,
.learning-main span,
.learning-main small,
.learning-feedback-row strong,
.learning-feedback-row span {
  display: block;
}

.learning-main span,
.learning-main small,
.learning-feedback-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.learning-main small {
  overflow-wrap: anywhere;
}

.learning-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.learning-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: #fff;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}

.learning-feedback-row {
  align-items: flex-start;
  flex-direction: column;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 15px;
}

.phone-url-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  margin-top: 15px;
  padding: 15px;
  background: var(--sky);
  border-radius: 15px;
}

.phone-url-box span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.phone-url-box strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--navy);
  font-size: clamp(16px, 3.5vw, 21px);
  font-variant-numeric: tabular-nums;
}

.phone-url-box button {
  white-space: nowrap;
}

.file-button {
  display: inline-flex !important;
  align-items: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.boundary-list {
  margin: 12px 0 0;
  padding-left: 21px;
  color: var(--muted);
  line-height: 1.9;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: min(100%, 1180px);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  border: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 13px;
  font-size: 11px;
}

.bottom-nav button span {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--navy);
  background: var(--sky);
  font-weight: 750;
}

.bottom-nav button svg { width: 21px; height: 21px; flex: none; }
.bottom-nav button { min-width: 0; padding: 6px 2px; }
#order-line-list { min-width: 0; }
.order-line { padding: 16px 0; border-top: 1px solid var(--line); min-width: 0; }
.order-line > label { margin-bottom: 15px; }
.order-line > .check-row { width: fit-content; margin-bottom: 0; border: 0; padding-left: 0; }
.order-line-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.order-line-heading h2 { font-size: 16px; margin: 0; }
.line-remove { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); flex: none; }
.line-remove svg { width: 18px; height: 18px; }
#add-order-line, #preview-quote { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 16px; }
#add-order-line svg, #preview-quote svg, .quotation-actions svg { width: 18px; height: 18px; flex: none; }
.quote-items { list-style: none; padding: 0; margin: 12px 0; }
.quote-items li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.quote-items strong, .quote-items small { overflow-wrap: anywhere; }
.quote-items small { grid-column: 1 / -1; color: var(--muted); line-height: 1.6; }
.quotation-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.quotation-actions button { display: inline-flex; align-items: center; gap: 6px; }
.quotation-image { width: 100%; height: auto; display: block; border: 1px solid var(--line); }
.quotation-preview-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; }
.quotation-preview-meta dd { margin: 0; overflow-wrap: anywhere; }

dialog {
  width: min(calc(100% - 28px), 520px);
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(7, 24, 36, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 20px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 80px rgba(7, 24, 36, 0.25);
}

.dialog-card label {
  display: block;
  margin-top: 12px;
}

.dialog-card label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.dialog-close {
  width: 38px;
  height: 38px;
  border: 0;
  color: var(--muted);
  background: var(--page);
  border-radius: 50%;
  font-size: 23px;
}

.dialog-detail {
  margin: 16px 0;
  padding: 14px;
  background: var(--page);
  border-radius: 13px;
  line-height: 1.7;
}

.dialog-detail dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 7px 12px;
  margin: 0;
  font-size: 14px;
}

.dialog-detail dt {
  color: var(--muted);
}

.dialog-detail dd {
  margin: 0;
  font-weight: 650;
}

.dialog-warning {
  padding: 11px 13px;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 17px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  color: #fff;
  background: var(--navy);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(159, 29, 34, 0.28);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.empty-state {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

@media (min-width: 800px) {
  #app-main {
    padding-left: 34px;
    padding-right: 34px;
  }

  .assistant-card {
    padding: 24px;
  }

  .order-list:not(.compact) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-card {
    padding: 24px;
  }
}

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

  .metric-card {
    min-height: 105px;
  }

  .order-list.compact {
    grid-template-columns: 1fr;
  }

  .form-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid.three label:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  #app-main {
    padding: 18px 14px calc(100px + env(safe-area-inset-bottom));
  }

  .welcome-row,
  .page-heading {
    align-items: flex-start;
  }

  .demo-badge {
    margin-top: 4px;
  }

  .metric-grid {
    gap: 9px;
  }

  .metric-card {
    min-width: 0;
    min-height: 98px;
    padding: 14px;
  }

  .metric-card span,
  .metric-card small {
    font-size: 11px;
  }

  .assistant-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .assistant-card,
  .form-card,
  .settings-card {
    padding: 16px;
    border-radius: 17px;
  }

  .assistant-input-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .message {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .form-grid.three label:first-child {
    grid-column: auto;
  }

  .business-summary {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form,
  .price-rule-edit,
  .learning-form {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .team-form button {
    grid-column: 1 / -1;
  }

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

  .stock-adjust-form button {
    grid-column: 1 / -1;
  }

  .phone-url-box {
    grid-template-columns: 1fr;
  }

  .phone-url-box button {
    width: 100%;
  }

  .inline-form button,
  .price-rule-edit button,
  .learning-form button,
  .learning-form #learning-source {
    grid-column: 1 / -1;
  }

  .privacy-pill {
    white-space: normal;
  }

  .dialog-actions button {
    flex: 1 1 120px;
  }

  .auth-panel {
    padding: 20px 16px;
    border-radius: 17px;
  }

}
.access-details { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px 12px; margin: 16px 0; font-size: 14px; line-height: 1.6; }
.access-details dt { color: var(--muted); }
.access-details dd { margin: 0; overflow-wrap: anywhere; }
.session-list { display: grid; gap: 0; }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid #f0dcde; }
.session-row > div { min-width: 0; }
.session-row strong, .session-row small { display: block; overflow-wrap: anywhere; }
.session-row small { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.session-row button { flex-shrink: 0; }
.image-import-section { margin: 0 0 20px; padding: 16px 0; border-block: 1px solid var(--line); }
.image-drop-zone { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px dashed #be5360; border-radius: 6px; background: #fff9f9; }
.image-drop-zone.drag-over, .image-drop-zone:focus-visible { outline: 2px solid #aa2336; outline-offset: 2px; }
.image-drop-zone > div { flex: 1; min-width: 0; }
.image-drop-zone strong, .image-drop-zone span { display: block; }
.image-drop-zone span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.image-drop-zone .secondary-button { flex-shrink: 0; }
.image-import-section > .check-row { margin-top: 10px; }
.image-review-row { padding: 16px 0; border-top: 1px solid #e5dcdd; }
.image-review-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.image-review-heading > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.image-review-heading small { display: block; color: var(--muted); margin-top: 4px; }
.image-review-heading img, .line-artwork img { width: 72px; height: 72px; object-fit: contain; background: #f3f3f3; border-radius: 4px; flex-shrink: 0; }
.image-review-row label { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
.image-review-row input, .image-review-row select { width: 100%; min-width: 0; }
.image-review-row label > span { font-size: 13px; font-weight: 600; }
.image-review-row .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.image-review-row .form-grid.three input, .image-review-row .form-grid.three select { padding-inline: 8px; }
.image-drop-zone > svg { flex-shrink: 0; }
.image-import-warning { color: #855400; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.image-price-result { display: block; color: #a31d31; margin: 12px 0; line-height: 1.5; font-size: 14px; }
.image-ocr-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; max-height: 160px; overflow-y: auto; }
.line-artwork { display: flex; gap: 10px; align-items: center; padding: 10px 0; }
.line-artwork label { flex: 1; min-width: 0; }
.line-artwork input { width: 100%; min-width: 0; }
.quote-items .item-artwork { width: 96px; height: 96px; object-fit: contain; grid-column: 1 / -1; background: #f3f3f3; }
@media (max-width: 380px) { .image-drop-zone { flex-wrap: wrap; } .image-drop-zone > .secondary-button { width: 100%; } .image-review-heading img { width: 56px; height: 56px; } }
