:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-subtle: #f7f8fa;
  --surface-raised: #fbfcfd;
  --ink: #1d2329;
  --muted: #68727d;
  --line: #e0e5e9;
  --line-strong: #cbd3da;
  --primary: #147d64;
  --primary-dark: #0d654f;
  --primary-soft: #e8f4f0;
  --blue: #2d64a8;
  --blue-soft: #edf3fb;
  --amber: #ad5d0b;
  --amber-soft: #fff5e6;
  --danger: #b4322b;
  --danger-soft: #fff0ef;
  --shadow: 0 18px 50px rgba(24, 32, 38, 0.14);
  --shadow-soft: 0 2px 8px rgba(26, 34, 40, 0.05);
  --sidebar-width: 248px;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button, input, textarea, select { outline: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.18); }
svg { width: 18px; height: 18px; stroke-width: 2; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 30px;
  background: #eef2f4;
}
.auth-brand { display: flex; align-items: center; gap: 11px; color: #20272d; font-size: 15px; font-weight: 760; }
.auth-brand .brand-mark { color: #fff; background: var(--primary); border-color: var(--primary); }
.auth-panel {
  width: min(420px, 100%);
  align-self: center;
  justify-self: center;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.auth-icon { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 22px; color: var(--primary); background: var(--primary-soft); border: 1px solid #c7e0d8; border-radius: 8px; }
.auth-icon svg { width: 22px; height: 22px; }
.auth-panel h1 { font-size: 22px; }
.auth-subtitle { margin: 6px 0 24px; color: var(--muted); font-size: 12px; }
.auth-input { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; color: #86909a; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; }
.auth-input:focus-within { color: var(--primary); border-color: #66a994; box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12); }
.auth-input svg { width: 16px; height: 16px; }
.auth-input input { min-width: 0; flex: 1; padding: 0; color: var(--ink); background: transparent; border: 0; }
.auth-error { margin: -4px 0 14px; padding: 9px 10px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f4cbc7; border-radius: 5px; font-size: 11px; line-height: 1.5; }
.auth-submit { width: 100%; margin-top: 2px; }
.auth-switch { width: 100%; margin-top: 14px; padding: 4px; color: var(--primary-dark); background: transparent; border: 0; font-size: 12px; font-weight: 650; }
.auth-footnote { display: flex; align-items: center; justify-content: center; gap: 7px; color: #788781; font-size: 11px; }
.auth-footnote svg { width: 14px; height: 14px; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #f4f7f8;
  background: #1b2024;
  border-right: 1px solid #2b3136;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #329079; border-radius: 7px; color: #ffffff; background: var(--primary); box-shadow: 0 5px 16px rgba(20, 125, 100, 0.28); }
.brand-mark svg { width: 19px; height: 19px; }
.brand strong { display: block; font-size: 15px; line-height: 1.4; }
.brand span { display: block; margin-top: 1px; color: #8f999f; font-size: 9px; text-transform: uppercase; }

.main-nav { display: grid; gap: 5px; }
.nav-item {
  position: relative; width: 100%; height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px;
  color: #aab3b8; background: transparent; border: 1px solid transparent; border-radius: 6px; text-align: left; font-size: 13px; font-weight: 580;
}
.nav-item svg { width: 17px; height: 17px; }
.nav-item:hover { color: #f5f8f9; background: #242a2f; border-color: #30373d; }
.nav-item.active { color: #ffffff; background: #29322f; border-color: #34443f; box-shadow: inset 3px 0 0 #42b795; }
.nav-item.active svg { color: #66cfaf; }

.sidebar-account { margin-top: auto; display: grid; grid-template-columns: 34px minmax(0, 1fr) 32px; align-items: center; gap: 10px; padding: 15px 8px 0; border-top: 1px solid #30373c; }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; color: #63c9aa; background: #29322f; border: 1px solid #35423e; border-radius: 6px; }
.account-avatar svg { width: 16px; height: 16px; }
.sidebar-account strong, .sidebar-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 12px; }
.sidebar-account div > span { margin-top: 2px; color: #879198; font-size: 10px; }
.sidebar-logout { width: 32px; height: 32px; color: #919ba1; background: transparent; border-color: #343b40; }
.sidebar-logout:hover { color: #fff; background: #2a3035; border-color: #495158; }

.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 10px; font-weight: 760; text-transform: uppercase; }
h1 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; }
h2 { margin: 0; font-size: 16px; line-height: 1.4; font-weight: 700; }
h3 { margin: 0; font-size: 15px; }
p { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar-title { min-width: 0; flex: 1; }
.user-chip { height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: #465159; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; font-weight: 650; }
.user-chip svg { width: 15px; height: 15px; color: var(--primary); }
.mobile-menu { display: none !important; }

main { width: min(100%, 1600px); margin: 0 auto; padding: 28px 32px 100px; }
.view { display: none; }
.view.active { display: block; animation: view-enter 150ms ease-out; }
@keyframes view-enter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; color: var(--muted); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; }
.icon-button:hover { color: var(--ink); border-color: #aeb8c0; background: var(--surface-subtle); }
.primary-button, .secondary-button, .danger-primary-button, .icon-text-button, .text-danger-button {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border-radius: 6px; font-weight: 650; white-space: nowrap;
}
.compact-button { min-height: 32px; padding-inline: 10px; font-size: 12px; }
.primary-button { color: white; background: var(--primary); border: 1px solid var(--primary); box-shadow: 0 1px 2px rgba(15, 78, 62, 0.18); }
.primary-button:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 3px 9px rgba(15, 78, 62, 0.18); }
.secondary-button { color: #344048; background: var(--surface); border: 1px solid var(--line-strong); }
.secondary-button:hover { border-color: #aab5bd; background: var(--surface-subtle); }
.danger-primary-button { color: #fff; background: var(--danger); border: 1px solid var(--danger); }
.danger-primary-button:hover { background: #912018; }
.icon-text-button { color: #2b3c37; background: var(--surface); border: 1px solid var(--line); }
.icon-text-button:hover { background: var(--surface-subtle); border-color: var(--line-strong); }
.text-danger-button { color: var(--danger); background: transparent; border: 0; padding-inline: 4px; }

.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px; }
.metric { position: relative; min-height: 112px; display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 15px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-soft); }
.metric-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 7px; }
.metric-icon svg { width: 19px; height: 19px; }
.stock-icon { color: var(--primary); background: var(--primary-soft); }
.product-icon { color: var(--blue); background: var(--blue-soft); }
.warning-icon { color: var(--amber); background: var(--amber-soft); }
.metric-copy > span { display: block; color: var(--muted); font-size: 11px; font-weight: 680; }
.metric strong { display: inline-block; margin: 5px 0 3px; font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric small { display: block; color: #89939c; font-size: 10px; }
.warning-metric strong { color: var(--amber); }

.section-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-toolbar p, .section-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.search-field { width: min(300px, 40vw); height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 12px; color: #89939b; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; }
.search-field:focus-within { border-color: #68a994; box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12); }
.search-field input { min-width: 0; flex: 1; padding: 0; color: var(--ink); background: transparent; border: 0; }

.table-frame { position: relative; min-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-soft); }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 2; color: #76818a; background: #f6f8f9; font-size: 10px; font-weight: 760; text-align: left; text-transform: uppercase; }
th, td { height: 56px; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.inventory-table tbody tr, .detail-table tbody tr, .sold-table tbody tr { transition: background-color 120ms ease, box-shadow 120ms ease; }
.inventory-table tbody tr:hover { background: #f8fafb; }
.inventory-table tbody tr.selected { background: #edf7f3; box-shadow: inset 3px 0 0 var(--primary); }
.check-cell { width: 44px; text-align: center; }
.number-cell { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.quantity-cell { width: 150px; }
.action-cell { width: 88px; text-align: center; }
.row-checkbox { width: 17px; height: 17px; accent-color: var(--primary); }
.product-name { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.product-glyph { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border: 1px solid #dce8f6; border-radius: 7px; }
.product-glyph svg { width: 16px; height: 16px; }
.product-name strong, .product-name span { display: block; }
.product-name strong { font-size: 13px; }
.product-name span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.field-list { display: flex; flex-wrap: wrap; gap: 5px; min-width: 180px; }
.field-tag { padding: 3px 7px; color: #55616a; background: #f0f3f5; border: 1px solid #e2e7ea; border-radius: 4px; font-size: 10px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border-radius: 4px; color: var(--primary-dark); background: var(--primary-soft); font-size: 10px; font-weight: 700; }
.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.status-badge.low { color: var(--amber); background: var(--amber-soft); }
.status-badge.low::before { background: var(--amber); }
.status-badge.empty { color: var(--danger); background: var(--danger-soft); }
.status-badge.empty::before { background: var(--danger); }
.stock-value { font-size: 16px; font-weight: 700; }

.stepper { width: 124px; display: grid; grid-template-columns: 34px minmax(42px, 1fr) 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: white; box-shadow: 0 1px 2px rgba(24, 32, 38, 0.04); }
.stepper button { display: grid; place-items: center; padding: 0; color: var(--muted); background: #f8faf9; border: 0; }
.stepper button:first-child { border-right: 1px solid var(--line); }
.stepper button:last-child { border-left: 1px solid var(--line); }
.stepper button:hover { color: var(--ink); background: #eef3f1; }
.stepper button:disabled { color: #b8c1be; }
.stepper input { width: 100%; padding: 0 4px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; border: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { display: none; }
.row-settings { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 5px; }
.row-settings:hover { color: var(--ink); background: #edf2f0; }
.row-actions { display: flex; align-items: center; justify-content: center; gap: 2px; }

.detail-controls { display: grid; grid-template-columns: minmax(260px, 380px) minmax(220px, 320px); align-items: end; gap: 12px; margin-bottom: 28px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-soft); }
.detail-controls .form-row { margin: 0; }
.detail-controls .search-field { width: 100%; }
.detail-toolbar { align-items: center; }
.detail-frame { min-height: 360px; }
.detail-table { min-width: 720px; }
.detail-table tbody tr:hover { background: #f8fafb; }
.detail-table tbody tr.selected { background: #edf7f3; box-shadow: inset 3px 0 0 var(--primary); }
.detail-value { min-width: 150px; max-width: 320px; overflow: hidden; cursor: copy; font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.detail-value:hover { color: var(--primary); background: var(--primary-soft); }
.imported-time-cell { width: 150px; white-space: nowrap; }
.imported-time { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.imported-time svg { width: 14px; height: 14px; }
.detail-pagination { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 11px; }
.detail-pagination > div { display: flex; gap: 6px; }

.empty-state { min-height: 278px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 14px; color: #77828b; background: #eef2f4; border: 1px solid #e0e5e8; border-radius: 8px; }
.empty-icon svg { width: 23px; height: 23px; }
.empty-state p { margin: 6px 0 16px; color: var(--muted); font-size: 12px; }

.claim-dock { position: fixed; z-index: 15; left: calc(var(--sidebar-width) + 32px); right: 32px; bottom: 20px; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 12px 11px 19px; color: white; background: #232a2e; border: 1px solid #353d42; border-radius: 8px; box-shadow: 0 14px 38px rgba(18, 24, 28, 0.25); }
.claim-dock[hidden] { display: none; }
.claim-dock strong, .claim-dock span { display: inline-block; }
.claim-dock > div > span { margin-left: 11px; color: #aeb7bd; }

.import-layout { width: min(920px, 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.import-layout:has(.import-preview:not([hidden])) { width: 100%; grid-template-columns: minmax(380px, 0.9fr) minmax(480px, 1.1fr); }
.import-source, .import-preview { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-soft); }
.import-preview[hidden] { display: none; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading > div { display: flex; align-items: flex-start; gap: 10px; }
.step-index { width: 25px; height: 25px; display: inline-grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--primary); border-radius: 5px; font-size: 11px; font-weight: 800; box-shadow: 0 2px 6px rgba(20, 125, 100, 0.18); }
.segmented-control { display: grid; grid-template-columns: repeat(2, 1fr); padding: 3px; margin-bottom: 20px; background: #edf1f3; border: 1px solid #e2e7ea; border-radius: 7px; }
.segmented-control button { min-height: 34px; padding: 0 12px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; font-weight: 650; }
.segmented-control button.active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(24, 32, 38, 0.12); }
.segmented-control.compact { width: 216px; margin: 0; }
.segmented-control.compact button { min-height: 32px; font-size: 12px; }
.form-row { display: grid; gap: 7px; margin-bottom: 18px; }
.field-label { color: #43524d; font-size: 12px; font-weight: 650; }
.text-input { width: 100%; height: 42px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; }
.text-input:focus, textarea:focus { border-color: #66a994; box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12); }
.field-setup-heading { margin-top: 28px; }
.import-field-list { display: grid; gap: 8px; margin-bottom: 10px; }
.import-field-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 34px; gap: 8px; align-items: center; }
.import-field-index { display: grid; place-items: center; height: 36px; color: #647079; background: #f1f4f6; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.import-field-row input { width: 100%; height: 36px; padding: 0 10px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; }
.import-field-row input:focus { border-color: #66a994; box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12); }
.field-empty-toggle {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: #51605b;
  background: #f4f6f7;
  border: 1px solid var(--line);
  border-radius: 5px;
  user-select: none;
  white-space: nowrap;
}
.field-empty-toggle:hover { border-color: var(--line-strong); background: #edf1f3; }
.field-empty-toggle.active { color: var(--primary-dark); background: var(--primary-soft); border-color: #b8dccf; }
.field-empty-toggle.locked { cursor: not-allowed; opacity: 0.48; }
.field-empty-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.import-field-row button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; color: var(--danger); background: var(--danger-soft); border: 1px solid #f5c4be; border-radius: 5px; }
.import-field-row button:hover { background: #fde2de; }
.quick-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }
.quick-fields button { min-height: 29px; padding: 0 10px; color: #46545d; background: #f4f6f7; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 650; }
.quick-fields button:hover { color: var(--primary-dark); border-color: #9fc8ba; background: var(--primary-soft); }
.source-heading { margin-top: 28px; }
.format-badge { padding: 4px 7px; color: var(--blue); background: var(--blue-soft); border-radius: 4px; font-size: 10px; font-weight: 700; }
textarea { width: 100%; min-height: 300px; resize: vertical; padding: 14px 15px; color: #283139; background: #fafbfc; border: 1px solid var(--line-strong); border-radius: 6px; font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
textarea::placeholder { color: #9da8a4; }
textarea.text-area {
  min-height: 108px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.55;
}
textarea.text-area::placeholder { color: #8c9894; }
.source-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 12px; }
.source-actions > span { color: var(--muted); font-size: 11px; }
.field-editor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.field-editor label { display: grid; gap: 4px; }
.field-editor span { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.field-editor input { width: 116px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 5px; }
.preview-table-wrap { max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.preview-table th, .preview-table td { height: 43px; padding: 7px 10px; white-space: nowrap; }
.preview-table td { max-width: 220px; overflow: hidden; color: #354048; font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-overflow: ellipsis; }
.preview-table th:first-child, .preview-table td:first-child { width: 46px; color: #8c9894; text-align: center; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 15px; }
.preview-footer > span { color: var(--muted); font-size: 11px; }

.sold-summary-band { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; padding: 18px 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-soft); }
.sold-summary-band > div { display: flex; align-items: center; gap: 13px; }
.sold-summary-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border: 1px solid #dce8f6; border-radius: 7px; }
.sold-summary-band span, .sold-summary-band strong, .sold-summary-band small { display: inline-block; }
.sold-summary-band > div > div > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.sold-summary-band strong { margin-right: 5px; font-size: 25px; font-variant-numeric: tabular-nums; }
.sold-summary-band small { color: var(--muted); font-size: 11px; }
.sold-summary-band > p { display: flex; align-items: center; gap: 7px; padding: 8px 10px; color: var(--amber); background: var(--amber-soft); border: 1px solid #f0d9b7; border-radius: 6px; font-size: 11px; }
.sold-summary-band > p svg { width: 15px; height: 15px; color: var(--amber); }
.sold-toolbar { align-items: center; }
.sold-frame { min-height: 330px; }
.sold-table { min-width: 720px; }
.sold-table tbody tr:hover { background: #f8fafb; }
.sold-table td { font-size: 12px; }
.sold-product-list { display: flex; flex-wrap: wrap; gap: 5px; }
.sold-product-list span { padding: 3px 7px; color: #4c5860; background: #f0f3f5; border: 1px solid #e2e7ea; border-radius: 4px; font-size: 10px; }
.sold-expiry { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.sold-expiry.soon { color: var(--amber); }
.sold-expiry svg { width: 14px; height: 14px; }
.sold-actions-cell { width: 128px; text-align: right; }
.sold-row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.sold-row-actions button { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.sold-row-actions button:hover { color: var(--primary); border-color: #9fc8ba; background: var(--primary-soft); }
.sold-row-actions button[data-delete-sold]:hover { color: var(--danger); border-color: #f0b8b2; background: var(--danger-soft); }
.sold-row-actions svg { width: 15px; height: 15px; }

.modal { max-width: calc(100vw - 28px); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(20, 25, 29, 0.58); }
.confirm-modal { width: 430px; }
.confirm-modal form { padding: 26px; text-align: center; }
.modal-icon { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 8px; }
.modal-icon.warning { color: var(--amber); background: var(--amber-soft); }
.confirm-modal > form > p { margin: 8px auto 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.confirm-summary { padding: 10px 12px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 6px; text-align: left; }
.confirm-summary div { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.confirm-modal .modal-actions > button { flex: 1; }

.result-modal { width: min(1060px, calc(100vw - 36px)); max-height: calc(100vh - 36px); overflow: hidden; }
.result-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.success-title { display: flex; align-items: center; gap: 12px; }
.success-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--primary); background: var(--primary-soft); border-radius: 7px; }
.success-title p { margin-bottom: 2px; color: var(--primary); font-size: 11px; font-weight: 800; }
.success-title h2 { font-size: 17px; }
.result-security { display: flex; align-items: center; gap: 8px; padding: 10px 20px; color: var(--amber); background: var(--amber-soft); border-bottom: 1px solid #f0dfc6; font-size: 11px; }
.result-security svg { width: 15px; height: 15px; }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.result-actions { display: flex; gap: 7px; }
.result-content { max-height: calc(100vh - 290px); overflow: auto; padding: 0 20px 16px; }
.result-group { margin-top: 18px; }
.result-group-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.result-group-heading span { color: var(--muted); font-size: 11px; }
.result-instructions {
  margin: 10px 0 12px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f6f8f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
}
.result-instructions > span {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.result-instructions > div { white-space: pre-wrap; }
.result-table { border: 1px solid var(--line); border-radius: 6px; box-shadow: none; }
.result-table th, .result-table td { height: 40px; padding: 7px 10px; white-space: nowrap; }
.result-table td { max-width: 320px; overflow: hidden; font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-overflow: ellipsis; }
.result-table td.copy-cell { cursor: copy; }
.result-table td.copy-cell:hover { color: var(--primary); background: var(--primary-soft); }
.truncated-note { padding: 11px; color: var(--muted); background: #f6f8f9; border: 1px solid var(--line); border-top: 0; font-size: 11px; text-align: center; }
.result-footer { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 20px; border-top: 1px solid var(--line); }
.result-footer span { color: var(--muted); font-size: 11px; }

.settings-modal { width: 520px; }
.settings-modal form { padding: 24px; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-heading p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.split-actions { align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 15px; }
.split-actions > div { display: flex; gap: 8px; }

.toast-region { position: fixed; z-index: 100; right: 18px; top: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: #fff; background: #252d31; border: 1px solid #394247; border-radius: 7px; box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.error { background: #8f2019; }
.toast svg { flex: 0 0 auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.loading svg { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.mobile-scrim { display: none; }

@media (max-width: 1080px) {
  .import-layout, .import-layout:has(.import-preview:not([hidden])) { width: 100%; grid-template-columns: 1fr; }
  .import-preview { min-width: 0; }
}

@media (max-width: 760px) {
  :root { --sidebar-width: 220px; }
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease-out; }
  .sidebar.open { transform: translateX(0); }
  .mobile-scrim { position: fixed; inset: 0; z-index: 25; display: block; visibility: hidden; opacity: 0; background: rgba(20, 25, 29, 0.5); transition: opacity 180ms; }
  .mobile-scrim.open { visibility: visible; opacity: 1; }
  .main-area { margin-left: 0; }
  .topbar { min-height: 74px; padding: 13px 16px; gap: 12px; }
  .topbar > div:nth-child(2) { flex: 1; min-width: 0; }
  .mobile-menu { display: inline-grid !important; }
  .user-chip { display: none; }
  .topbar-actions .primary-button { width: 38px; padding: 0; }
  .topbar-actions .primary-button span:last-child { display: none; }
  main { padding: 18px 14px 92px; }
  h1 { font-size: 17px; }
  .metric-strip { gap: 8px; margin-bottom: 24px; }
  .metric { min-height: 112px; grid-template-columns: 1fr; align-content: center; gap: 8px; padding: 12px; }
  .metric-icon { width: 32px; height: 32px; }
  .metric-icon svg { width: 16px; height: 16px; }
  .metric strong { font-size: 22px; }
  .metric-copy > span { font-size: 10px; }
  .metric small { display: none; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .table-frame { min-height: 260px; }
  .inventory-table { min-width: 780px; }
  .detail-controls { grid-template-columns: 1fr; padding: 13px; }
  .detail-table { min-width: 680px; }
  .claim-dock { left: 14px; right: 14px; bottom: 12px; }
  .claim-dock > div > span { display: block; margin: 2px 0 0; font-size: 11px; }
  .import-source, .import-preview { padding: 16px; }
  textarea { min-height: 260px; }
  .result-modal { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .result-toolbar { align-items: stretch; flex-direction: column; }
  .segmented-control.compact { width: 100%; }
  .result-actions { display: grid; grid-template-columns: 1.4fr 1fr 1fr; }
  .result-actions button { padding-inline: 8px; }
  .result-content { max-height: calc(100vh - 360px); padding-inline: 12px; }
  .result-footer { padding-inline: 14px; }
  .result-footer span { display: none; }
  .result-footer button { width: 100%; }
  textarea.text-area { min-height: 96px; }
  .settings-modal { width: calc(100vw - 20px); }
  .auth-shell { padding: 18px; }
  .auth-panel { padding: 24px 20px; }
  .sold-summary-band { align-items: flex-start; flex-direction: column; padding: 16px; }
  .sold-summary-band > p { width: 100%; }
}

@media (max-width: 430px) {
  .topbar { padding-inline: 12px; }
  .topbar-actions { gap: 6px; }
  main { padding-inline: 12px; }
  .metric { padding: 10px; }
  .metric-icon { width: 30px; height: 30px; }
  .metric strong { font-size: 21px; }
  .claim-dock { left: 10px; right: 10px; padding-left: 14px; }
  .claim-dock .primary-button { padding-inline: 11px; }
  .import-source, .import-preview { padding: 15px; }
  .section-heading { gap: 10px; }
  .field-setup-heading { align-items: center; }
  .import-field-row { grid-template-columns: 28px minmax(0, 1fr) auto 34px; gap: 6px; }
  .field-empty-toggle { padding-inline: 7px; }
  .import-field-row button { width: 34px; }
  .preview-footer { align-items: stretch; flex-direction: column; }
  .preview-footer .primary-button { width: 100%; }
}
