:root {
  color-scheme: light;
  --canvas: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #fff;
  --surface-soft: #fafafc;
  --text: #1d1d1f;
  --muted: #526174;
  --inventory-text-body: 16px;
  --inventory-text-table: 15px;
  --inventory-text-small: 14px;
  --inventory-text-control: 16px;
  --inventory-cell-y: 14px;
  --inventory-cell-x: 14px;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --blue: #0071e3;
  --blue-strong: #005fc0;
  --blue-soft: #edf6ff;
  --green: #1a7f45;
  --green-soft: #edf8f1;
  --orange: #b65c00;
  --orange-soft: #fff6e8;
  --red: #c9342f;
  --red-soft: #fff0ef;
  --shadow: 0 2px 10px rgba(18, 28, 45, 0.035), 0 18px 50px rgba(18, 28, 45, 0.055);
  --shadow-hover: 0 4px 14px rgba(18, 28, 45, 0.05), 0 22px 60px rgba(18, 28, 45, 0.09);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--canvas); font-size: var(--inventory-text-body); }
html[data-text-size="large"] {
  --inventory-text-body: 18px;
  --inventory-text-table: 17px;
  --inventory-text-small: 16px;
  --inventory-text-control: 18px;
}
/* Density changes whitespace only; it never makes text or touch targets smaller. */
html[data-table-density="compact"] { --inventory-cell-y: 8px; --inventory-cell-x: 12px; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 86% -8%, rgba(66, 133, 244, 0.12), transparent 36rem),
    radial-gradient(circle at 5% 40%, rgba(52, 168, 83, 0.045), transparent 28rem),
    var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--inventory-text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
input, select, textarea { font-size: var(--inventory-text-control); }
small { font-size: var(--inventory-text-small); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.22);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: -80px;
  left: 18px;
  padding: 11px 16px;
  border-radius: 10px;
  color: #fff;
  background: #111;
  transition: top 160ms ease;
}
.skip-link:focus { top: 16px; }

.top-shell {
  position: sticky;
  z-index: 50;
  top: 12px;
  width: min(calc(100% - 32px), 1808px);
  min-height: 76px;
  margin: 12px auto 0;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  border: 1px solid rgba(224, 228, 235, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 14px rgba(25, 35, 55, 0.04);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.top-shell::after {
  position: absolute;
  right: 18px;
  bottom: -1px;
  left: 18px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4285f4 0 34%, #34a853 34% 58%, #fbbc05 58% 78%, #ea4335 78%);
  content: "";
  opacity: 0.78;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #1c1c1e, #36383d 58%, #006edc 145%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 8px 20px rgba(20, 28, 42, 0.18);
  font-size: var(--inventory-text-small);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: var(--inventory-text-body); }
.brand small { color: var(--muted); font-size: var(--inventory-text-small); }

.product-nav {
  display: flex;
  justify-content: center;
  gap: 4px;
}
.product-nav a {
  padding: 9px 13px;
  border-radius: 10px;
  color: #55565a;
  font-size: var(--inventory-text-small);
  font-weight: 650;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}
.product-nav a:hover { color: var(--text); background: rgba(60, 60, 67, 0.06); }
.product-nav a.active { color: #0066cc; background: rgba(0, 113, 227, 0.1); }

.network-pill {
  min-width: 118px;
  min-height: 44px;
  padding: 7px 11px;
  display: grid;
  grid-template-columns: 9px 1fr;
  align-items: center;
  gap: 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.network-pill > span { width: 8px; height: 8px; border-radius: 50%; background: #9a9aa0; }
.network-pill strong { font-size: var(--inventory-text-small); }
.network-pill small { grid-column: 2; color: var(--muted); font-size: var(--inventory-text-small); }
.network-pill[data-state="online"] > span { background: #34a853; box-shadow: 0 0 0 4px rgba(52, 168, 83, 0.11); }
.network-pill[data-state="offline"] { border-color: #f1d7ad; background: var(--orange-soft); }
.network-pill[data-state="offline"] > span { background: #f59b23; box-shadow: 0 0 0 4px rgba(245, 155, 35, 0.12); }
.network-pill[data-state="syncing"] > span { background: #4285f4; animation: pulse 1s infinite; }

main { width: min(calc(100% - 32px), 1808px); margin: 0 auto; padding: 26px 0 64px; }

.hero {
  position: relative;
  min-height: 220px;
  padding: clamp(24px, 3vw, 40px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.55fr);
  align-items: center;
  gap: 40px;
  overflow: hidden;
  border: 1px solid #dceafa;
  border-radius: 30px;
  background:
    radial-gradient(circle at 83% 5%, rgba(0, 113, 227, 0.2), transparent 26rem),
    radial-gradient(circle at 66% 120%, rgba(88, 86, 214, 0.11), transparent 26rem),
    linear-gradient(135deg, #fbfdff, #edf6ff);
  box-shadow: var(--shadow);
}
.hero::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(112deg, rgba(255,255,255,.8), transparent 42%);
  content: "";
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; }
.eyebrow { margin: 0; color: #3976b9; font-size: var(--inventory-text-small); font-weight: 800; letter-spacing: 0.14em; }
.hero h1 { max-width: 940px; margin: 10px 0 14px; font-size: clamp(30px, 3.2vw, 46px); line-height: 1.15; letter-spacing: -0.025em; }
.hero-copy > p:not(.eyebrow) { max-width: 810px; margin: 0; color: #626d79; font-size: clamp(15px, 1.2vw, 18px); line-height: 1.75; }
.hero-flow { margin-top: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.hero-flow span { padding: 8px 11px; border: 1px solid rgba(0,113,227,.13); border-radius: 999px; color: #365b7d; background: rgba(255,255,255,.76); font-size: var(--inventory-text-small); font-weight: 650; }
.hero-flow b { margin-right: 5px; color: #0066cc; }
.hero-flow i { color: #9aafc1; font-style: normal; }

.hero-orbit { position: relative; z-index: 1; width: min(26vw, 300px); aspect-ratio: 1; justify-self: center; border: 1px solid rgba(0,113,227,.12); border-radius: 50%; }
.hero-orbit::before, .hero-orbit::after { position: absolute; inset: 18%; border: 1px solid rgba(0,113,227,.14); border-radius: 50%; content: ""; }
.hero-orbit::after { inset: 38%; background: radial-gradient(circle at 34% 30%, #e0f2ff 0 8%, #258df1 27%, #0068ce 68%, #003b75 100%); box-shadow: 0 0 0 14px rgba(0,113,227,.06), 0 20px 50px rgba(0,113,227,.2); }
.hero-orbit span, .hero-orbit b, .hero-orbit i { position: absolute; width: 16px; height: 16px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 6px 16px rgba(20,40,70,.15); }
.hero-orbit span { top: 7%; left: 48%; background: #4285f4; }
.hero-orbit b { right: 10%; bottom: 22%; background: #34a853; }
.hero-orbit i { bottom: 18%; left: 13%; background: #fbbc05; }

.metrics { margin: 18px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metrics article { min-height: 116px; padding: 18px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); transition: transform 160ms ease, box-shadow 160ms ease; }
.metrics article:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.metrics span { color: var(--muted); font-size: var(--inventory-text-small); font-weight: 650; }
.metrics strong { align-self: end; font-size: 2rem; font-variant-numeric: tabular-nums; }
.metrics small { color: var(--muted); font-size: var(--inventory-text-small); }

.workspace { min-width: 0; }
.section-tabs { position: sticky; z-index: 20; top: 102px; margin: 0 0 14px; padding: 5px; display: inline-flex; gap: 3px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.88); box-shadow: 0 8px 24px rgba(20,28,40,.05); backdrop-filter: blur(18px); }
.section-tabs button, .segmented button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; color: #5e5e63; background: transparent; cursor: pointer; font-size: var(--inventory-text-small); font-weight: 700; }
.section-tabs button.active, .segmented button.active { color: #0066cc; background: var(--blue-soft); box-shadow: inset 0 0 0 1px rgba(0,113,227,.08); }

.tab-panel { display: none; }
.tab-panel.active { display: grid; gap: 14px; animation: reveal 180ms ease both; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.feature-panel { min-height: 250px; display: flex; flex-direction: column; align-items: flex-start; background: linear-gradient(145deg, #fbfdff, #f0f7ff); }
.feature-panel.blue { background: linear-gradient(145deg, #fbfffc, #eef9f1); }
.feature-panel h2, .panel h2 { margin: 8px 0 10px; font-size: clamp(23px, 2vw, 30px); letter-spacing: -0.035em; }
.feature-panel > p:not(.eyebrow), .panel-head p { margin: 0; color: var(--muted); font-size: var(--inventory-text-small); line-height: 1.7; }
.feature-panel .button { margin-top: auto; }
.feature-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.feature-actions .button { margin-top: 0; }
.process-panel header, .panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.safe-badge, .offline-ready-badge { padding: 7px 10px; border: 1px solid rgba(23,133,68,.16); border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: var(--inventory-text-small); font-weight: 800; letter-spacing: .04em; }
.process-panel ol { margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; list-style: none; }
.process-panel li { min-height: 145px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.process-panel li > b { display: inline-grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: #0066cc; background: var(--blue-soft); font-size: var(--inventory-text-small); }
.process-panel li div { margin-top: 14px; display: grid; gap: 7px; }
.process-panel li strong { font-size: var(--inventory-text-body); }
.process-panel li span { color: var(--muted); font-size: var(--inventory-text-small); line-height: 1.65; }

.panel-head { margin-bottom: 20px; }
.panel-head.compact { align-items: center; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-width: 0; }
.search { display: grid; gap: 6px; color: #68686d; font-size: var(--inventory-text-small); font-weight: 650; }
.search input, .field input, .field select, .field textarea, .audience-row :is(input, select), .transfer-line :is(input, select) {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-soft);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.search input { width: min(360px, 46vw); }
.search input:focus, .field :is(input,select,textarea):focus, .audience-row :is(input,select):focus, .transfer-line :is(input,select):focus { border-color: rgba(0,113,227,.55); background: #fff; box-shadow: 0 0 0 4px rgba(0,113,227,.09); outline: none; }

.button { min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-size: var(--inventory-text-control); font-weight: 720; transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button.primary { color: #fff; background: linear-gradient(180deg, #1883ed, #006edc); box-shadow: 0 7px 18px rgba(0,113,227,.2), inset 0 1px rgba(255,255,255,.25); }
.button.secondary { border-color: var(--line); color: #3f4043; background: #fff; box-shadow: 0 1px 2px rgba(20,27,40,.03); }
.button.ghost { min-height: 44px; border-color: #d8e7f7; color: #0066cc; background: var(--blue-soft); }
.button.success { color: #fff; background: linear-gradient(180deg, #29945a, #187d45); }
.button.danger { border-color: #f0c8c5; color: var(--red); background: var(--red-soft); }

.source-toolbar { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.source-toolbar > span { color: var(--muted); font-size: var(--inventory-text-small); }
.source-toolbar .source-master-badge { padding: 7px 11px; border: 1px solid #cfe2f8; border-radius: 999px; color: #075ea9; background: linear-gradient(180deg, #f8fbff, #edf6ff); font-weight: 760; letter-spacing: .02em; }
.segmented { padding: 4px; display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.segmented button { min-height: 44px; }
.source-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.source-card { min-height: 145px; padding: 16px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.source-card:hover { border-color: #cfdfef; box-shadow: 0 10px 26px rgba(25,42,62,.065); }
.source-card small { color: var(--muted); font-size: var(--inventory-text-small); }
.source-card strong { margin: 8px 0 4px; font-size: var(--inventory-text-body); line-height: 1.45; }
.source-card .source-meta { display: flex; flex-wrap: wrap; gap: 5px; color: var(--muted); font-size: var(--inventory-text-small); }
.source-card .button { width: 100%; margin-top: auto; min-height: 44px; }

.table-shell { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
table { width: 100%; min-width: 840px; border-collapse: collapse; }
th { padding: var(--inventory-cell-y) var(--inventory-cell-x); color: #555c66; background: #f8f9fb; font-size: var(--inventory-text-table); font-weight: 650; letter-spacing: .02em; text-align: left; white-space: nowrap; }
td { padding: var(--inventory-cell-y) var(--inventory-cell-x); border-top: 1px solid #eceef2; font-size: var(--inventory-text-table); line-height: 1.6; vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(0,113,227,.025); }
.cell-main { display: block; font-size: var(--inventory-text-small); font-weight: 700; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: var(--inventory-text-small); }
.tag { display: inline-flex; min-height: 25px; padding: 4px 8px; align-items: center; border-radius: 999px; color: #4f5358; background: #f0f1f3; font-size: var(--inventory-text-small); font-weight: 700; }
.tag.blue { color: #0066cc; background: var(--blue-soft); }
.tag.green { color: var(--green); background: var(--green-soft); }
.tag.orange { color: var(--orange); background: var(--orange-soft); }
.tag.red { color: var(--red); background: var(--red-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-button { min-height: 44px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; color: #4b4c50; background: #fff; cursor: pointer; font-size: var(--inventory-text-control); font-weight: 680; white-space: nowrap; }
.row-button.primary { border-color: #cfe2f5; color: #0066cc; background: var(--blue-soft); }
.row-button.danger { color: var(--red); }
.empty-row { padding: 34px; color: var(--muted); text-align: center; }

.task-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.task-card { min-height: 210px; padding: 19px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 17px; background: #fff; transition: transform 150ms ease, box-shadow 150ms ease; }
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.task-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-card h3 { margin: 16px 0 6px; font-size: var(--inventory-text-body); }
.task-card p { margin: 0; color: var(--muted); font-size: var(--inventory-text-small); }
.progress { height: 7px; margin: 20px 0 8px; overflow: hidden; border-radius: 999px; background: #eef0f3; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4285f4, #34a853); }
.task-card footer { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: var(--inventory-text-small); }

.toast-region { position: fixed; z-index: 200; right: 20px; bottom: 20px; width: min(380px, calc(100vw - 40px)); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 14px 16px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.96); box-shadow: 0 18px 54px rgba(15,22,34,.18); animation: toast-in 200ms ease both; }
.toast strong { font-size: var(--inventory-text-small); }
.toast span { color: var(--muted); font-size: var(--inventory-text-small); line-height: 1.5; }
.toast.error { border-color: #efc7c4; }
.toast.warning { border-color: #f1d6aa; }

dialog { width: min(calc(100vw - 28px), 760px); max-height: min(90vh, 920px); padding: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.85); border-radius: 22px; background: #fff; box-shadow: 0 30px 100px rgba(15,22,34,.25); }
dialog.wide { width: min(calc(100vw - 28px), 1240px); }
dialog.small { width: min(calc(100vw - 28px), 620px); }
dialog::backdrop { background: rgba(29,29,31,.38); backdrop-filter: blur(11px); -webkit-backdrop-filter: blur(11px); }
.dialog form, .dialog-frame { max-height: min(90vh, 920px); display: flex; flex-direction: column; overflow: hidden; }
.dialog header { flex: 0 0 auto; padding: 20px 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.dialog header h2 { margin: 6px 0 4px; font-size: 1.375rem; }
.dialog header p:last-child { margin: 0; color: var(--muted); font-size: var(--inventory-text-small); }
.dialog-body { min-height: 0; flex: 1 1 auto; padding: 22px; overflow: auto; }
.dialog footer { min-height: 70px; flex: 0 0 auto; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); background: #fbfbfc; }
.dialog footer > span { color: var(--muted); font-size: var(--inventory-text-small); }
.dialog footer > div { display: flex; gap: 8px; }
.icon-button { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: #6a6a70; background: #fff; cursor: pointer; font-size: 1.1875rem; }
.icon-button.small { width: 44px; height: 44px; }
.dialog-head-actions { display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; min-width: 0; gap: 7px; color: #62636a; font-size: var(--inventory-text-small); font-weight: 650; }
.field :is(input, select, textarea), .audience-row :is(input, select) { min-width: 0; max-width: 100%; width: 100%; }
.field.full { grid-column: 1 / -1; }
.field textarea { resize: vertical; }
.form-error { margin: 12px 0 0; padding: 11px 13px; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: var(--inventory-text-small); }
.audience-fieldset, .transfer-locations fieldset { min-width: 0; margin: 16px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 15px; }
.audience-fieldset legend, .transfer-locations legend { padding: 0 6px; font-size: var(--inventory-text-small); font-weight: 750; }
.audience-fieldset > p { margin: 0 0 12px; color: var(--muted); font-size: var(--inventory-text-small); }
#audienceRows { display: grid; gap: 8px; }
.audience-row { display: grid; min-width: 0; grid-template-columns: minmax(170px, .75fr) repeat(2, minmax(150px, 1fr)) auto; gap: 8px; align-items: center; }
.switch-field { margin-top: 15px; padding: 13px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 13px; }
.switch-field input { width: 18px; height: 18px; accent-color: var(--blue); }
.switch-field span { display: grid; gap: 3px; }
.switch-field strong { font-size: var(--inventory-text-small); }
.switch-field small { color: var(--muted); font-size: var(--inventory-text-small); }

.count-toolbar { padding: 14px 22px; display: flex; align-items: end; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); background: #fcfcfd; }
.count-toolbar > div { display: flex; gap: 8px; }
.count-body { padding: 0; }
.count-body .table-shell { border: 0; border-radius: 0; }
.count-table { min-width: 960px; }
.count-table input { min-height: 44px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.count-table input[type="number"] { width: 140px; font-variant-numeric: tabular-nums; }
.count-table input[type="text"] { width: 220px; }
.count-table tr.pending { background: var(--orange-soft); }
.count-table tr.conflict { background: var(--red-soft); }
.difference { font-weight: 750; font-variant-numeric: tabular-nums; }
.difference.positive { color: var(--green); }
.difference.negative { color: var(--red); }
.sync-state { color: var(--muted); font-size: var(--inventory-text-small); }
.conflict-actions { margin-top: 6px; display: grid; gap: 4px; }
.conflict-actions button { padding: 4px 7px; border: 1px solid rgba(201,52,47,.18); border-radius: 7px; color: #9f2723; background: rgba(255,255,255,.82); cursor: pointer; font-size: var(--inventory-text-small); font-weight: 750; }
.conflict-actions button:last-child { border-color: rgba(0,113,227,.18); color: #0066cc; }

.transfer-locations { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.transfer-locations fieldset { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.transfer-arrow { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: #0066cc; background: var(--blue-soft); font-weight: 800; }
.transfer-line-head { margin: 18px 0 9px; display: flex; align-items: center; justify-content: space-between; }
.transfer-lines { display: grid; gap: 8px; }
.transfer-line { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(100px, .35fr) minmax(180px, .8fr) auto; gap: 8px; align-items: center; }
.transfer-detail-route { padding: 18px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; border: 1px solid #dceafa; border-radius: 16px; background: linear-gradient(145deg, #fbfdff, #f1f7fd); }
.transfer-detail-route div { display: grid; gap: 4px; }
.transfer-detail-route div:last-child { text-align: right; }
.transfer-detail-route small { color: var(--muted); }
.transfer-detail-lines { margin-top: 16px; display: grid; gap: 7px; }
.transfer-detail-line { padding: 11px 13px; display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.transfer-detail-line span { color: var(--muted); }

@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

@media (max-width: 1180px) {
  .source-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .process-panel ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .top-shell { top: 8px; width: calc(100% - 20px); grid-template-columns: 1fr auto; gap: 10px; }
  .product-nav { grid-column: 1 / -1; justify-content: flex-start; overflow: auto; }
  .network-pill { grid-column: 2; grid-row: 1; }
  main { width: calc(100% - 20px); padding-top: 18px; }
  .hero { min-height: 0; grid-template-columns: 1fr; }
  .hero-orbit { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-tabs { top: 142px; width: 100%; overflow: auto; }
  .audience-row { grid-template-columns: 1fr 1fr auto; }
  .audience-row select { grid-column: 1 / -1; }
  .transfer-locations { grid-template-columns: 1fr; }
  .transfer-arrow { transform: rotate(90deg); justify-self: center; }
  .transfer-line { grid-template-columns: 1fr 110px auto; }
  .transfer-line [data-transfer-note] { grid-column: 1 / -1; }
}

@media (max-width: 580px) {
  .brand small { display: none; }
  .network-pill { min-width: 0; padding: 6px 9px; }
  .network-pill small:empty { display: none; }
  .hero { padding: 30px 22px; border-radius: 22px; }
  .hero h1 { font-size: 2.375rem; }
  .hero-flow i { display: none; }
  .metrics { gap: 9px; }
  .metrics article { min-height: 100px; padding: 14px; }
  .metrics strong { font-size: 1.6875rem; }
  .panel { padding: 18px; border-radius: 18px; }
  .panel-head { display: grid; }
  .search input { width: 100%; }
  .source-grid, .task-grid, .process-panel ol { grid-template-columns: 1fr; }
  .source-card { min-height: 135px; }
  .section-tabs { top: 137px; }
  .section-tabs button { flex: 0 0 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .audience-row { grid-template-columns: 1fr auto; }
  .audience-row :is([data-audience-store],[data-audience-department]) { grid-column: 1; }
  .audience-row [data-remove-audience] { grid-column: 2; grid-row: 2 / span 2; }
  .count-toolbar { display: grid; }
  .count-toolbar > div { flex-wrap: wrap; }
  dialog { height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
  .dialog form, .dialog-frame { height: 100%; max-height: 100%; }
  .dialog footer { align-items: stretch; flex-direction: row; flex-wrap: wrap; }
  .dialog footer > span { width: 100%; }
  .dialog footer > div { width: 100%; flex-wrap: wrap; }
  .dialog footer .button { flex: 1; }
  .transfer-locations fieldset { grid-template-columns: 1fr; }
  .transfer-line { grid-template-columns: 1fr auto; }
  .transfer-line [data-transfer-quantity], .transfer-line [data-transfer-note] { grid-column: 1; }
  .transfer-line [data-remove-transfer-line] { grid-column: 2; grid-row: 1 / span 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.transfer-line { grid-template-columns: minmax(160px,2fr) 100px 130px minmax(110px,1fr) 36px; }
.transfer-line [data-transfer-conversion] { grid-column: 1 / -1; grid-row: 2; color: #526273; overflow-wrap:anywhere; }
@media(max-width:760px){.transfer-line {grid-template-columns: minmax(0,1fr) 100px;} .transfer-line [data-transfer-conversion]{grid-row:auto;} .transfer-line [data-transfer-note]{grid-column:1 / -1;}}

/* Keep per-row search and long unit warnings usable on narrow screens. */
.transfer-picker { display: grid; gap: 6px; min-width: 0; }
.transfer-picker > span { font-size: var(--inventory-text-small); color: #526273; }
.transfer-line { padding: 12px; border: 1px solid #dbe3ed; border-radius: 12px; align-items: end; }
.transfer-line input, .transfer-line select { min-width: 0; width: 100%; }
@media (max-width: 760px) {
  .transfer-line { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
  .transfer-picker { grid-column: 1 / -1; }
  .transfer-line [data-transfer-quantity], .transfer-line [data-transfer-unit] { grid-column: auto; }
  .transfer-line [data-remove-transfer-line] { grid-column: 2; grid-row: auto; justify-self: end; min-width: 44px; min-height: 44px; }
  .transfer-line [data-transfer-conversion] { grid-row: auto; }
}
@media (max-width: 760px) {
  .dialog header > .icon-button { flex: 0 0 44px; min-width: 44px; min-height: 44px; }
}
/* A wide table scrolls inside its card, never expands the whole tab grid. */
.tab-panel.active { grid-template-columns: minmax(0, 1fr); }
.tab-panel > .panel, .source-card { min-width: 0; }
@media (max-width: 580px) {
  .panel-head .head-actions, .panel-head .search, .panel-head .search input { width: 100%; min-width: 0; }
}

/* Shared reading controls also serve counts and legacy delivery URLs. */
.display-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.display-controls label { display: grid; gap: 6px; color: var(--muted); font-size: var(--inventory-text-small); }
.display-controls select { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #fff; }
body.erp-product-page :is(button, input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { min-height: 44px; }
body.erp-product-page :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) { font-size: var(--inventory-text-control); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.4; text-decoration: none; }
.button, .row-button, .conflict-actions button { white-space: normal; overflow-wrap: anywhere; }
.dialog[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dialog > form, .dialog > .dialog-frame { min-height: 0; width: 100%; }
.dialog header > div, .dialog footer > div { min-width: 0; }
.dialog header h2, .dialog header p, .dialog footer { overflow-wrap: anywhere; }
.dialog footer { flex-wrap: wrap; }
.dialog footer > div { flex-wrap: wrap; }
.dialog-body { overscroll-behavior: contain; }
.dialog-body > .table-shell { max-height: none; }
.dialog :is(.field, .operation-confirm, .confirm-price):has(input:is([type="checkbox"], [type="radio"])) { min-height: 44px; align-content: center; }
.workflow-guide { margin: 0 0 16px; padding: 0 0 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--inventory-text-small); }
.workflow-guide > summary { display: list-item; min-height: 44px; padding: 10px 0; color: var(--text); font-weight: 650; cursor: pointer; }
.workflow-guide > p { margin: 4px 0 0; max-width: 84ch; line-height: 1.75; }
.workflow-guide a { color: var(--blue-strong); text-underline-offset: 3px; }
@media (max-width: 760px) {
  body.erp-product-page :is(button, input, select, textarea):not([type="checkbox"]):not([type="radio"]) { font-size: var(--inventory-text-control); }
  .dialog header { gap: 12px; padding: 16px; }
  .dialog footer { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
  .dialog footer > :is(span, p) { flex-basis: 100%; margin: 0; }
  .dialog footer > div { width: 100%; }
  .dialog footer .button { flex: 1 1 140px; min-width: 0; white-space: normal; }
  .dialog header .button { padding: 8px 12px; }
  .dialog header :is(.button, .icon-button) { flex-shrink: 0; }
  .display-controls { width: 100%; }
  .display-controls label { flex: 1 1 120px; min-width: 0; }
  .display-controls select { max-width: 100%; }
  .source-toolbar { flex-wrap: wrap; }
  .stock-pagination, .request-pagination > div { flex-wrap: wrap; }
}
/* Phone stocktakes keep the quantity field beside its item, not off-screen. */
@media (max-width: 600px) {
  #countDialog .dialog-head-actions { flex: 0 0 auto; flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
  #countDialog .offline-ready-badge { white-space: nowrap; flex-shrink: 0; }
  #countDialog header > div:first-child { min-width: 0; }
  #countDialog .count-toolbar .search { width: 100%; min-width: 0; }
  #countDialog .count-body { padding: 12px; }
  #countDialog .table-shell { border: 0; overflow: visible; }
  #countDialog .count-table { display: block; width: 100%; min-width: 0 !important; }
  #countDialog .count-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #countLineRows { display: grid; gap: 12px; }
  #countLineRows tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
  #countLineRows td { display: block; min-width: 0; padding: 0 !important; border: 0; background: transparent; white-space: normal; overflow-wrap: anywhere; }
  #countLineRows td:first-child { grid-column: 1 / -1; order: 0; }
  #countLineRows td:nth-child(2) { order: 1; }
  #countLineRows td:nth-child(4) { order: 2; }
  #countLineRows td:nth-child(3) { grid-column: 1 / -1; order: 3; }
  #countLineRows td:nth-child(5) { grid-column: 1 / -1; order: 4; }
  #countLineRows td:nth-child(6) { grid-column: 1 / -1; order: 5; }
  #countLineRows td:not(:first-child)::before { display: block; margin-bottom: 4px; color: var(--muted); font-size: var(--inventory-text-small); font-weight: 600; }
  #countLineRows td:nth-child(2)::before { content: "账面数量"; }
  #countLineRows td:nth-child(3)::before { content: "实盘数量"; }
  #countLineRows td:nth-child(4)::before { content: "盘点差异"; }
  #countLineRows td:nth-child(5)::before { content: "盘点备注"; }
  #countLineRows td:nth-child(6)::before { content: "同步状态"; }
  #countLineRows :is(input, textarea) { width: 100%; max-width: 100%; min-width: 0; }
  #countLineRows .conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
}
