@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5c6b7a;
  --line: #d5dde5;
  --accent: #0d7a6f;
  --accent-2: #c45c26;
  --accent-soft: #d8f0ed;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #067647;
  --sidebar: #12202c;
  --sidebar-text: #c5d0da;
  --shadow: 0 10px 30px rgba(18, 32, 44, 0.08);
  --radius: 14px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  height: auto;
  min-height: 100%;
  /* 避免手机端横向溢出把整页滚轮锁死 */
  overflow-x: clip;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(13, 122, 111, 0.12), transparent 55%),
    radial-gradient(700px 360px at -5% 100%, rgba(196, 92, 38, 0.08), transparent 50%),
    var(--bg);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  overflow-x: clip;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; height: auto; }

/* Mobile top bar — hidden on desktop */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #152636 0%, var(--sidebar) 100%);
  color: var(--sidebar-text);
  box-shadow: 0 4px 16px rgba(18, 32, 44, 0.18);
}
.mobile-bar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.mobile-bar-brand .brand-name { font-size: 14px; }
.mobile-bar-brand .brand-sub { font-size: 11px; }
.menu-toggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: 0.2s ease;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(10, 18, 26, 0.45);
}

.sidebar {
  width: 230px;
  background: linear-gradient(180deg, #152636 0%, var(--sidebar) 100%);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex-shrink: 0;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #1aa897, #0d7a6f);
  color: #fff; font-weight: 700; display: grid; place-items: center;
  letter-spacing: 0.5px;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; opacity: 0.7; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  border: 0; background: transparent; color: inherit;
  text-align: left; padding: 11px 14px; border-radius: 10px;
  transition: 0.15s ease;
}
.nav-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-btn.active {
  background: rgba(26, 168, 151, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 #1aa897;
}

.main { flex: 1; min-width: 0; min-height: 0; padding: 22px 28px 40px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; gap: 12px;
}
.topbar h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; font-weight: 500;
  transition: 0.15s ease;
}
.btn:hover { border-color: #b7c3cf; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { background: #fff5f4; border-color: #f3c4bf; color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

.grid-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.stat-card.warn .stat-value { color: var(--accent-2); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; /* desktop: clip radius; mobile overrides below */
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-body { padding: 16px; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.filter-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 8px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.filter-panel .toolbar { margin-bottom: 8px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px 12px;
  padding-bottom: 8px;
}
.filter-advanced {
  display: none;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.filter-advanced.open { display: block; }
.filter-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filter-field .input, .filter-field .select { min-width: 0; width: 100%; }
.filter-checks {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 12px 16px;
  padding-top: 4px;
}
.plan-board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.plan-board-card {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: #fff; cursor: pointer;
}
.plan-board-card.on {
  border-color: #9fc7c1;
  background: linear-gradient(180deg, #f4fbfa, #fff);
}
.plan-board-body { flex: 1; min-width: 0; }
.plan-board-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; word-break: break-word; }
.plan-qty-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted);
}
.merge-pick-list { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow: auto; }
.merge-pick-card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  cursor: pointer; background: #fff;
}
.merge-pick-card:has(input:checked) {
  border-color: #9fc7c1;
  background: linear-gradient(180deg, #f4fbfa, #fff);
}
.merge-pick-card input { margin-top: 4px; }
.merge-pick-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input, .select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: #fff; min-width: 180px; color: var(--ink);
}
.input:focus, .select:focus { outline: 2px solid rgba(13,122,111,0.25); border-color: var(--accent); }
.input.grow { flex: 1; min-width: 220px; }

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  max-height: calc(100dvh - 220px);
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.activity-table { max-height: min(60vh, 480px); }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }
.row-actions .btn:last-child { margin-right: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  position: sticky; top: 0; background: #f7f9fb; color: var(--muted);
  font-weight: 600; font-size: 12px; text-transform: none; z-index: 1;
}
th.sortable {
  cursor: pointer; user-select: none; white-space: nowrap;
}
th.sortable:hover { color: var(--text); background: #eef5f4; }
th.sortable.sorted { color: var(--accent); }
th.sortable .sort-ind {
  font-size: 11px; opacity: 0.55; margin-left: 2px;
}
th.sortable.sorted .sort-ind { opacity: 1; }
tr:hover td { background: #f8fbfb; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
}
.tag.warn { background: #fff4e8; color: var(--warn); }
.tag.danger { background: #fef3f2; color: var(--danger); }
.tag.neutral { background: #eef2f6; color: var(--muted); }
.tag.ok { background: #e8f8ef; color: var(--ok); }
.tag.purchased { background: #fff4e8; color: var(--warn); }
.tag.arrived { background: #e8f8ef; color: var(--ok); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.board-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: linear-gradient(180deg, #fff, #f9fbfc); cursor: pointer;
  transition: 0.15s ease;
}
.board-card:hover { border-color: #9fc7c1; transform: translateY(-1px); }
.board-card h3 { margin: 0 0 6px; font-size: 15px; }
.board-meta { color: var(--muted); font-size: 12px; line-height: 1.5; }
.board-cost { color: var(--accent); font-weight: 600; }
.sub-notice {
  margin-top: 4px;
  color: #b42318;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 500;
}
.sub-notice .linkish { color: #b42318; text-decoration: underline; }
.sub-chosen {
  font-size: 13px;
  padding: 6px 8px;
  background: #fff5f5;
  border: 1px solid #fecdca;
  border-radius: 8px;
  color: #7a271a;
}
.board-actions { margin-top: 12px; display: flex; gap: 8px; }
.product-card-hint { font-size: 11px; opacity: 0.85; }
.seg-tabs {
  display: inline-flex; gap: 4px; padding: 3px; margin-bottom: 14px;
  background: #eef2f6; border-radius: 10px;
}
.seg-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.seg-tab:hover { color: var(--ink); }
.seg-tab.active {
  background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(18, 32, 44, 0.08);
}
.cost-share-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) 1fr;
  gap: 18px;
  align-items: start;
}
.cost-share-pie {
  display: grid; place-items: center;
  background: linear-gradient(180deg, #f6faf9, #fff);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.pie-svg { display: block; max-width: 100%; height: auto; }
.pie-swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  vertical-align: middle;
}
.cost-share-table td, .cost-share-table th { white-space: nowrap; }
@media (max-width: 720px) {
  .cost-share-layout { grid-template-columns: 1fr; }
}

.dropzone {
  border: 2px dashed #b7c8c4; border-radius: 16px; padding: 36px 20px;
  text-align: center; background: linear-gradient(180deg, #f4fbfa, #fff);
  transition: 0.15s ease;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone h3 { margin: 0 0 8px; }
.dropzone p { margin: 0; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: center; margin: 12px 0; }
.edit-form .form-row { margin: 8px 0; grid-template-columns: 88px 1fr; }
.edit-form .input { min-width: 0; width: 100%; }
.check { display: flex; align-items: center; gap: 8px; }

.modal.hidden, .toast.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 18, 26, 0.45); }
.modal-panel {
  position: relative; width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  padding: 20px;
}
.modal-panel.modal-wide { width: min(1180px, calc(100vw - 24px)); }
.board-detail-table .col-actions {
  position: sticky; left: 0; z-index: 2;
  background: #fff; box-shadow: 4px 0 8px rgba(0,0,0,0.04);
}
.board-detail-table thead .col-actions { z-index: 3; }
.modal-panel h2 { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.batch-stock-table td { vertical-align: top; }
.batch-stock-table .row-done { opacity: 0.55; }
.row-muted { opacity: 0.55; }
.batch-filter-bar .batch-filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.plan-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  background: #15202b; color: #fff; padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow); max-width: 360px;
}
.toast.error { background: #7f1d1d; }

.detail-grid {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px;
}
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.merge-group {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px;
}
.merge-group.caution { border-color: #f0c9a0; background: #fffaf5; }
.merge-group h3 { margin: 0 0 8px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.caution-text { margin: 0 0 10px; color: var(--warn); font-size: 13px; }
.boards-cell { min-width: 200px; max-width: 320px; }
.board-use { margin-bottom: 6px; line-height: 1.35; }
.board-use .desig { font-size: 11px; margin-top: 2px; word-break: break-all; }
button.linkish {
  border: 0; background: none; padding: 0; color: var(--accent);
  font-weight: 600; text-align: left; cursor: pointer;
}
button.linkish:hover { text-decoration: underline; }

.empty {
  text-align: center; padding: 40px 16px; color: var(--muted);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user {
  font-size: 12px;
  opacity: 0.75;
  padding: 0 14px;
}
.nav-btn.logout {
  color: #f0b4ae;
}
.nav-btn.logout:hover {
  background: rgba(180, 35, 24, 0.18);
  color: #fff;
}

/* Login */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-wrap { width: min(420px, 100%); }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
}
.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}
.login-brand .brand-name { color: var(--ink); }
.login-brand .brand-sub { color: var(--muted); }
.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.login-hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.login-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}
.login-form input:focus {
  outline: 2px solid rgba(13, 122, 111, 0.25);
  border-color: var(--accent);
}
.login-submit { width: 100%; padding: 11px 14px; margin-top: 4px; }
.login-error {
  color: var(--danger);
  background: #fff5f4;
  border: 1px solid #f3c4bf;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 14px;
}
.login-tabs { width: 100%; margin-bottom: 16px; }
.login-title { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.login-card > .login-form > .login-title { margin-top: 0; }
.hidden { display: none !important; }
.admin-only.hidden { display: none !important; }
body.role-viewer .nav-btn[data-view="import"],
body.role-viewer .nav-btn[data-view="merge"] {
  display: none;
}
.sidebar-user .tag {
  margin-top: 6px;
  font-size: 11px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row,
  .edit-form .form-row { grid-template-columns: 1fr; align-items: stretch; }
  .form-row > label,
  .form-row > span,
  .edit-form .form-row > label,
  .edit-form .form-row > span {
    margin-bottom: -4px;
    color: var(--muted);
    font-size: 13px;
  }
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .plan-board-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
  }
  body {
    display: block; /* 文档流滚动，避免 flex+height 锁死手机滚动 */
    overflow-x: clip;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .mobile-bar { display: flex; }
  .nav-backdrop:not([hidden]) { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 45;
    width: min(280px, 86vw);
    height: 100%;
    height: 100dvh;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.28);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  body.nav-open .menu-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .main {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 14px 14px 32px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
    overflow: visible;
  }
  .panel {
    overflow: visible;
    max-width: 100%;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 14px;
    gap: 10px;
  }
  .topbar h1 { font-size: 22px; }
  .topbar-actions {
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1 1 auto;
    min-height: 40px;
    justify-content: center;
  }
  .topbar-actions .muted {
    width: 100%;
    margin: 0 0 4px !important;
  }

  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-card .stat-value[style*="font-size:22px"] { font-size: 18px !important; }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .panel-head > .btn,
  .panel-head > div { width: 100%; }
  .panel-body { padding: 12px; }

  .toolbar { gap: 8px; }
  .toolbar .input,
  .toolbar .select,
  .input,
  .select,
  .input.grow {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }
  .filter-panel { padding: 12px; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-checks { gap: 10px 14px; }
  .seg-tabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .seg-tab { flex: 1; white-space: nowrap; text-align: center; }

  .table-wrap {
    max-height: none;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    /* 提示可横向滑动 */
    background:
      linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
      linear-gradient(to right, rgba(255,255,255,0), #fff 70%) 100% 0,
      radial-gradient(farthest-side at 0 50%, rgba(18,32,44,0.12), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(18,32,44,0.12), transparent) 100% 0;
    background-repeat: no-repeat;
    background-size: 28px 100%, 28px 100%, 10px 100%, 10px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  table { font-size: 12.5px; min-width: 560px; }
  th, td { padding: 8px 10px; }
  .boards-cell { min-width: 140px; max-width: 220px; }

  .board-actions {
    flex-wrap: wrap;
  }
  .board-actions .btn { flex: 1 1 calc(50% - 4px); min-height: 38px; }

  .modal {
    place-items: end center;
    align-items: stretch;
  }
  .modal-panel,
  .modal-panel.modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, calc(100vh - 24px));
    margin: 0;
    border-radius: 16px 16px 0 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  }
  .modal-actions {
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, #fff 28%);
    padding-top: 12px;
  }
  .modal-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 42px;
  }

  .kv { grid-template-columns: 96px 1fr; font-size: 13px; }
  .dropzone { padding: 28px 14px; }
  .toast {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: none;
  }
  .login-body { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .login-card { padding: 22px 18px; }
}

@media (max-width: 480px) {
  .grid-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cards { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  table { min-width: 520px; }
  .board-detail-table,
  .batch-stock-table { min-width: 640px; }
}
