:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-subtle: #f7f9fc;
  --border: #d5dee8;
  --border-strong: #b6c4d4;
  --ink: #0f1f30;
  --ink-muted: #4b6078;
  --primary: #0b5cad;
  --primary-hover: #08488a;
  --primary-soft: #e6f1fc;
  --primary-ring: rgba(11, 92, 173, 0.22);
  --formula-bg: #fff6db;
  --formula-border: #e8c563;
  --formula-ink: #8a5300;
  --day-bg: #fef3c7;
  --day-ink: #b45309;
  --day-border: #f59e0b;
  --night-bg: #e0e7ff;
  --night-ink: #3730a3;
  --night-border: #6366f1;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --ok-border: #86efac;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --warn-border: #fcd34d;
  --danger: #c81e1e;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;
  --shadow-sm: 0 1px 2px rgba(15, 31, 48, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 31, 48, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Be Vietnam Pro", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 1px;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  transition: max-width 0.18s ease;
}

body.view-summary-mode .app-shell {
  max-width: 1180px;
}

/* 3-Mode Language Visibility & Typography */
.t-block {
  display: block;
}

.t-zh.t-block {
  font-size: 0.86em;
  font-weight: 500;
  color: var(--ink-muted);
  margin-top: 2px;
}

html[data-lang="vi"] .t-zh,
html[data-lang="vi"] .t-sep {
  display: none !important;
}

html[data-lang="zh"] .t-vi,
html[data-lang="zh"] .t-sep {
  display: none !important;
}

html[data-lang="zh"] .t-zh,
html[data-lang="zh"] .t-zh.t-block {
  font-size: 1em;
  font-weight: inherit;
  color: inherit;
  margin-top: 0;
}

html[data-lang="zh"] .title-zh {
  font-size: 1em;
  font-weight: 800;
  color: #ffffff;
}

html[data-lang="zh"] .sub-zh {
  font-size: 12.5px;
  color: #dbeafe;
}

html[data-lang="zh"] .key-zh {
  display: inline;
  font-size: inherit;
  font-weight: 700;
  color: var(--formula-ink);
  margin-top: 0;
}

html[data-lang="zh"] .th-zh {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 0;
}

html[data-lang="vi"] .report-table,
html[data-lang="zh"] .report-table {
  min-width: 860px;
}

.bi-vi {
  color: var(--ink);
}

.bi-zh {
  display: block;
  font-size: 0.86em;
  font-weight: 500;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Header */
.app-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.company-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #ffffff;
  border-bottom: 1px solid #dbeafe;
}

.company-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}

.company-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.company-name {
  font-size: 14px;
  font-weight: 800;
  color: #0b3c70;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.company-name .t-zh {
  font-size: 13px;
  font-weight: 700;
  color: #1e40af;
}

@media (min-width: 640px) {
  .company-bar {
    padding: 10px 16px;
    gap: 12px;
  }

  .company-logo {
    width: 44px;
    height: 44px;
  }

  .company-name {
    font-size: 16px;
  }

  .company-name .t-zh {
    font-size: 14.5px;
  }
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px 14px;
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, #0b3c70 0%, #0b5cad 100%);
  color: #ffffff;
}

.brand-block {
  flex: 1 1 280px;
  min-width: 0;
}

.brand-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #bfdbfe;
  margin-bottom: 3px;
}

.brand-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.title-zh {
  font-size: 0.9em;
  font-weight: 700;
  color: #e0f2fe;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: #dbeafe;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sub-zh {
  font-size: 12px;
  color: #bfdbfe;
}

.header-actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.lang-select {
  min-height: 36px;
  max-width: 52%;
  padding: 5px 22px 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  appearance: auto;
  transition: background 0.15s ease;
}

.lang-select:hover {
  background: rgba(255, 255, 255, 0.26);
}

.lang-select option {
  color: #0f1f30;
  background: #ffffff;
  font-size: 14px;
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.conn-pill:hover {
  background: rgba(255, 255, 255, 0.24);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  flex-shrink: 0;
}

.conn-pill.conn-live .conn-dot {
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.28);
}

/* Deadline Bar */
.deadline-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  font-size: 12.5px;
  color: #78350f;
}

.deadline-bar .t-vi,
.deadline-bar .t-zh,
.deadline-bar .bi-vi,
.deadline-bar .bi-zh {
  color: inherit;
}

.deadline-bar .t-zh,
.deadline-bar .bi-zh {
  opacity: 0.92;
}

.deadline-bar.deadline-late {
  background: #fff7ed;
  border-bottom-color: #fdba74;
  color: #9a3412;
}

.deadline-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Tabs */
.main-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-subtle);
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.tab-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
}

.tab-btn .t-vi,
.tab-btn .bi-vi {
  color: inherit;
}

.tab-btn .t-zh,
.tab-btn .bi-zh {
  font-size: 11.5px;
  margin-top: 1px;
  color: inherit;
  opacity: 0.85;
}

html[data-lang="zh"] .tab-btn .t-zh {
  font-size: 14px;
  font-weight: 700;
  margin-top: 0;
  opacity: 1;
}

.tab-btn.active {
  color: var(--primary);
  background: var(--surface);
  border-bottom-color: var(--primary);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}

.view-panel {
  display: none;
}

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

/* Gate Mode (Choose Workshop Before Entry) */
.app-shell.gate-mode .active-ws-bar,
.app-shell.gate-mode .main-tabs,
.app-shell.gate-mode .header-utility-bar,
.app-shell.gate-mode #viewForm,
.app-shell.gate-mode #viewSummary {
  display: none !important;
}

.ws-gate {
  display: none;
}

.app-shell.gate-mode .ws-gate {
  display: block;
}

.ws-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow-sm);
}

.ws-gate-head {
  text-align: center;
  margin-bottom: 16px;
}

.ws-gate-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
}

.ws-gate-sub {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.ws-gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ws-gate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  padding: 18px 14px;
  border-radius: 14px;
  border: none;
  color: #ffffff;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 31, 48, 0.14);
}

.ws-gate-btn:active {
  transform: scale(0.98);
}

.ws-gate-btn.ws-theme-x3 {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.ws-gate-btn.ws-theme-x3:hover {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

.ws-gate-btn.ws-theme-x2l3 {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
}

.ws-gate-btn.ws-theme-x2l3:hover {
  background: linear-gradient(135deg, #166534 0%, #14532d 100%);
}

.ws-gate-btn.ws-theme-x2l1 {
  background: linear-gradient(135deg, #c2410c 0%, #9a3412 100%);
}

.ws-gate-btn.ws-theme-x2l1:hover {
  background: linear-gradient(135deg, #9a3412 0%, #7c2d12 100%);
}

.ws-gate-btn.ws-theme-kp {
  background: linear-gradient(135deg, #7e22ce 0%, #6b21a8 100%);
}

.ws-gate-btn.ws-theme-kp:hover {
  background: linear-gradient(135deg, #6b21a8 0%, #581c87 100%);
}

.ws-gate-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.ws-gate-name .t-vi,
.ws-gate-name .t-zh {
  color: #ffffff;
}

.ws-gate-name .t-zh {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.94;
  margin-top: 3px;
}

@media (min-width: 640px) {
  .ws-gate-btn {
    min-height: 124px;
    padding: 22px 18px;
  }

  .ws-gate-name {
    font-size: 25px;
  }

  .ws-gate-name .t-zh {
    font-size: 19px;
  }
}

/* Active Workshop Bar (Inside Form / Summary) */
.active-ws-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #e8f1fb;
  border-bottom: 1px solid #c7ddf6;
}

.active-ws-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-muted);
}

.active-ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.active-ws-info strong {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.btn-change-ws {
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1.5px solid #93c5fd;
  background: #ffffff;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-change-ws:hover {
  background: #dbeafe;
  border-color: var(--primary);
}

/* Header Utility Bar (Google Sheet View & Excel Export) */
.header-utility-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 8px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.util-btn {
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.util-sheet {
  border: 1.5px solid #93c5fd;
  background: #eff6ff;
  color: #0b5cad;
}

.util-sheet:hover {
  background: #dbeafe;
  border-color: var(--primary);
}

.util-excel {
  border: 1.5px solid #86efac;
  background: #f0fdf4;
  color: #15803d;
}

.util-excel:hover:not(:disabled) {
  background: #dcfce7;
  border-color: #16a34a;
}

.util-excel:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Sticky Formula Dock */
.formula-dock {
  position: sticky;
  top: 4px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border: 1px solid var(--formula-border);
  border-radius: var(--radius);
  padding: 5px 6px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

.dock-context {
  font-size: 11px;
  color: var(--ink-muted);
  padding: 0 2px 3px;
  margin-bottom: 4px;
  border-bottom: 1px dashed #ecd38a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-context strong {
  color: var(--primary);
  font-weight: 700;
}

.formula-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.formula-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--formula-bg);
  border: 1px solid var(--formula-border);
  border-radius: var(--radius-sm);
  padding: 3px 4px;
  text-align: center;
}

.formula-key {
  font-size: 10px;
  font-weight: 700;
  color: var(--formula-ink);
  line-height: 1.15;
}

.formula-key span {
  display: inline-block;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(138, 83, 0, 0.14);
}

.key-zh {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 9.5px;
  color: #7c4d03;
  margin-top: 1px;
}

.formula-val {
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  color: #523000;
  line-height: 1.15;
  margin-top: 0;
}

.formula-expr {
  display: none;
  font-size: 10px;
  color: #92610c;
}

.balance-strip {
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}

.balance-neutral {
  background: var(--surface-subtle);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.balance-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}

.balance-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.balance-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Cards & Form Layout */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}

.card-title .t-zh.t-block,
.card-title .bi-zh {
  font-size: 12.5px;
  font-weight: 600;
}

html[data-lang="zh"] .card-title .t-zh.t-block {
  font-size: 15px;
  font-weight: 800;
}

.col-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.col-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #b6d4f4;
  vertical-align: middle;
  margin-right: 4px;
}

.formula-chip {
  background: var(--formula-bg);
  color: var(--formula-ink);
  border-color: var(--formula-border);
}

/* Date & Shift */
.date-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.date-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.date-input-wrap .text-input {
  flex: 1 1 160px;
}

.text-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 16px;
  transition: border-color 0.15s ease;
}

.text-input:focus {
  border-color: var(--primary);
}

textarea.text-input {
  min-height: 72px;
  resize: vertical;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.shift-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.shift-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.shift-btn[data-shift="day"].active {
  background: var(--day-bg);
  color: var(--day-ink);
  border-color: var(--day-border);
  box-shadow: var(--shadow-sm);
}

.shift-btn[data-shift="night"].active {
  background: var(--night-bg);
  color: var(--night-ink);
  border-color: var(--night-border);
  box-shadow: var(--shadow-sm);
}

.friendly-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

/* Collapsible Department Dropdown & Grid */
.dept-section {
  display: flex;
  flex-direction: column;
}

.dept-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dept-picker-btn {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.dept-picker-btn:hover {
  background: #d8ebfc;
}

.dept-picker-btn.is-empty {
  background: #ffffff;
  border: 1.5px solid #60a5fa;
}

.dept-picker-btn.is-empty:hover {
  background: #f0f7ff;
  border-color: var(--primary);
}

.dept-picker-btn.is-empty .dept-picker-name {
  color: var(--ink-muted);
  font-weight: 600;
}

.dept-picker-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.dept-picker-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.picker-chevron {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.dept-picker-panel {
  margin-top: 8px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dept-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  min-height: 52px;
  padding: 8px 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.quick-copy-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-copy-prev {
  width: 100%;
  min-height: 40px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed #60a5fa;
  background: #f0f7ff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-copy-prev:hover:not(:disabled) {
  background: #dbeafe;
  border-color: var(--primary);
}

.btn-copy-prev:disabled {
  opacity: 0.6;
  cursor: wait;
}

.dept-card:hover {
  border-color: var(--primary);
}

.dept-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.dept-card.submitted {
  border-color: var(--ok-border);
}

.dept-card.submitted.active {
  border-color: var(--primary);
}

.dept-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  word-break: break-word;
}

.dept-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.dept-zh {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

.dept-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.badge-mini {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}

.badge-2shift {
  background: #e2e8f0;
  color: #334155;
}

.badge-done {
  background: var(--ok-bg);
  color: var(--ok);
}

.overwrite-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e3a8a;
  font-size: 13px;
}

.overwrite-banner span {
  display: block;
  font-size: 12px;
  margin-top: 2px;
  color: #1e40af;
}

.overwrite-icon {
  font-size: 16px;
  font-weight: 800;
}

/* Steppers & Inputs */
.field-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stepper-card {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.stepper-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.stepper-card .stepper-row {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.stepper-card .quick-chips {
  margin-top: 8px;
}

.stepper-meta {
  flex: 1 1 0;
  min-width: 0;
}

.stepper-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.stepper-zh {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-top: 2px;
}

.stepper-ctrl {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.step-btn {
  width: 40px;
  height: 42px;
  border: none;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.12s ease;
}

.step-btn:hover {
  background: #e2e8f0;
}

.step-btn:active {
  background: #cbd5e1;
}

.num-input {
  width: 52px;
  height: 42px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  background: #ffffff;
  color: var(--ink);
  -moz-appearance: textfield;
}

.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.btn-chip {
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #b6d4f4;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-chip:hover {
  background: #d2e6fb;
}

.auto-pill {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--formula-bg);
  border: 1px solid var(--formula-border);
  color: var(--formula-ink);
  font-size: 13.5px;
}

.auto-pill-val {
  font-size: 16px;
  color: #523000;
}

.divider-line {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.sub-readout {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--ink-muted);
}

/* Transfer Box (Column N) */
.transfer-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.transfer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.signed-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}

.signed-badge.neutral {
  background: #e2e8f0;
  color: #334155;
}

.signed-badge.pos {
  background: var(--ok-bg);
  color: var(--ok);
}

.signed-badge.neg {
  background: var(--danger-bg);
  color: var(--danger);
}

.transfer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sign-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex: 1 1 280px;
}

.sign-btn {
  min-height: 48px;
  padding: 6px 6px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink-muted);
  cursor: pointer;
}

.sign-btn small {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.88;
}

.sign-btn[data-sign="-1"] {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.sign-btn[data-sign="-1"]:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.sign-btn[data-sign="-1"].active {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.28);
}

.sign-btn[data-sign="0"].active {
  background: #e2e8f0;
  border-color: #64748b;
  color: var(--ink);
}

.sign-btn[data-sign="1"] {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.sign-btn[data-sign="1"]:hover {
  background: #dcfce7;
  border-color: #22c55e;
}

.sign-btn[data-sign="1"].active {
  background: #16a34a;
  border-color: #15803d;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.28);
}

.sign-btn[data-sign="-1"].active .t-vi,
.sign-btn[data-sign="-1"].active .t-zh,
.sign-btn[data-sign="1"].active .t-vi,
.sign-btn[data-sign="1"].active .t-zh {
  color: #ffffff;
}

.inline-warn {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.notes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Action Buttons */
.submit-bar {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  margin-top: 2px;
}

.btn-primary,
.btn-secondary {
  min-height: 50px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn-primary {
  width: 100%;
  min-height: 52px;
  font-size: 15.5px;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(11, 92, 173, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-submit-green {
  background: #16a34a;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.28);
}

.btn-submit-green:hover:not(:disabled) {
  background: #15803d;
}

.btn-secondary {
  width: 100%;
  background: #ffffff;
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
}

.submit-bar .btn-secondary {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  background: #f8fafc;
}

.btn-secondary:hover {
  background: #f1f5f9;
}

/* Tab 2: Summary */
.summary-toolbar {
  margin-bottom: 12px;
}

.summary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-btn {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-refresh {
  min-height: 44px;
  flex: 0 0 auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.kpi-card.kpi-amber {
  background: var(--formula-bg);
  border-color: var(--formula-border);
}

.kpi-card.kpi-blue {
  background: var(--primary-soft);
  border-color: #b6d4f4;
}

.kpi-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin: 2px 0;
}

.kpi-sub {
  font-size: 11px;
  color: var(--ink-muted);
}

.balance-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.balance-banner.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
}

.balance-banner.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
}

.balance-banner.neutral {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

.missing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.missing-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.missing-pill:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.shift-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.shift-tag.day {
  background: var(--day-bg);
  color: var(--day-ink);
}

.shift-tag.night {
  background: var(--night-bg);
  color: var(--night-ink);
}

/* Table */
.table-card {
  margin-top: 12px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 980px;
}

.report-table th,
.report-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}

.report-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--ink);
  font-size: 11.5px;
  line-height: 1.3;
  white-space: normal;
  min-width: 72px;
}

.th-vi {
  display: block;
}

.th-zh {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-top: 2px;
}

.report-table td {
  white-space: nowrap;
}

.report-table th.th-formula,
.report-table td.td-formula {
  background: #fffbeb;
  color: #78350f;
  font-weight: 700;
}

.report-table th.sticky-col,
.report-table td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #ffffff;
  text-align: left;
  min-width: 132px;
  max-width: 150px;
  font-size: 12px;
  padding: 7px 8px;
  white-space: normal;
  border-right: 1px solid var(--border);
}

/* Summary View Toggle & Mobile Cards */
.table-card-head {
  align-items: flex-start;
  gap: 10px;
}

.table-edit-hint {
  margin-top: 2px;
}

.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  gap: 3px;
  flex-shrink: 0;
}

.view-mode-btn {
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-mode-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.table-filter-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 11px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--border);
}

.table-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.table-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.table-date-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-filter-input {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 13.5px;
  background: #ffffff;
}

.btn-today-mini {
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #b6d4f4;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-today-mini:hover {
  background: #d2e6fb;
}

@media (min-width: 640px) {
  .table-filter-bar {
    grid-template-columns: 1fr 1.15fr;
    gap: 12px;
    align-items: end;
  }
}

.summary-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-cards-empty {
  text-align: center;
  padding: 20px 12px;
  font-size: 13.5px;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
}

.summary-card-item,
.summary-card-total {
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.summary-card-item {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}

.summary-card-item:hover {
  border-color: var(--primary);
  background: #f8fbff;
}

.summary-card-item:active {
  transform: scale(0.99);
}

.summary-card-total {
  background: #eef6ff;
  border: 1.5px solid #93c5fd;
}

.summary-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.summary-card-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}

.summary-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.sc-metric {
  padding: 5px 4px;
  border-radius: 7px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sc-metric-amber {
  background: var(--formula-bg);
  border-color: var(--formula-border);
}

.sc-metric-blue {
  background: var(--primary-soft);
  border-color: #b6d4f4;
}

.sc-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
  line-height: 1.2;
}

.sc-metric strong {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.sc-metric strong.val-pos {
  color: #15803d;
}

.sc-metric strong.val-neg {
  color: #b91c1c;
}

.summary-card-sub {
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.35;
}

.summary-card-note {
  font-size: 11.5px;
  color: var(--primary);
  background: #f0f7ff;
  padding: 4px 7px;
  border-radius: 6px;
  line-height: 1.3;
}

.report-table th.sticky-col {
  background: #f1f5f9;
  z-index: 3;
}

.report-table tbody tr {
  cursor: pointer;
}

.report-table tbody tr:hover td {
  background: #f0f7ff;
}

.report-table tfoot td {
  background: #e6f1fc;
  font-weight: 800;
  border-top: 2px solid var(--primary);
}

.report-table tfoot td.sticky-col {
  background: #e6f1fc;
}

.table-empty {
  text-align: center !important;
  color: var(--ink-muted);
  padding: 24px 12px !important;
}

.note-dot {
  display: inline-block;
  margin-left: 5px;
  font-size: 12px;
  color: var(--primary);
}

/* Author Corner Attribution */
.author-corner {
  margin-top: 16px;
  margin-left: auto;
  width: fit-content;
  max-width: 100%;
  padding: 9px 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px 6px;
  font-size: 12px;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.author-corner strong {
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 31, 48, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 20px 45px rgba(15, 31, 48, 0.25);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--surface-subtle);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-desc {
  margin: 0;
  font-size: 14px;
}

.modal-desc a {
  color: var(--primary);
  font-weight: 700;
}

.info-box {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
  font-size: 13px;
}

.demo-tools {
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}

.demo-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.demo-btn-row .btn-secondary {
  min-height: 42px;
  font-size: 13px;
  padding: 8px 12px;
}

.warn-list {
  margin: 0;
  padding-left: 20px;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.modal-foot .btn-primary,
.modal-foot .btn-secondary {
  flex: 1 1 140px;
  min-height: 44px;
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: #0f1f30;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 31, 48, 0.3);
  text-align: center;
}

.toast.toast-ok {
  background: #14532d;
}

.toast.toast-err {
  background: #991b1b;
}

/* Responsive Breakpoints */
@media (min-width: 480px) {
  .formula-dock {
    top: 6px;
    padding: 10px;
    margin-bottom: 12px;
  }

  .dock-context {
    font-size: 12px;
    padding: 0 2px 7px;
    margin-bottom: 7px;
  }

  .formula-cards {
    gap: 8px;
  }

  .formula-card {
    padding: 7px 6px;
  }

  .formula-key {
    font-size: 11px;
    line-height: 1.25;
  }

  .key-zh {
    font-size: 10.5px;
  }

  .formula-val {
    font-size: 20px;
    margin-top: 2px;
  }

  .formula-expr {
    display: block;
  }

  .balance-strip {
    margin-top: 8px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.35;
  }

  .step-btn {
    width: 46px;
    height: 46px;
    font-size: 20px;
  }

  .num-input {
    width: 66px;
    height: 46px;
    font-size: 17px;
  }
}

@media (min-width: 640px) {
  .app-shell {
    padding: 16px 18px 28px;
  }

  .header-actions {
    width: auto;
    gap: 8px;
  }

  .lang-select {
    font-size: 13px;
    max-width: none;
    padding: 6px 26px 6px 12px;
  }

  .conn-pill {
    padding: 7px 12px;
  }

  .header-utility-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 12px;
  }

  .util-btn {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 7px 14px;
    font-size: 13px;
    gap: 6px;
  }

  .submit-bar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .submit-bar .btn-primary {
    width: auto;
    flex: 2 1 240px;
  }

  .submit-bar .btn-secondary {
    width: auto;
    flex: 1 1 150px;
    min-height: 52px;
    padding: 11px 18px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ink);
    background: #ffffff;
  }

  .report-table th.sticky-col,
  .report-table td.sticky-col {
    min-width: 210px;
    max-width: 260px;
    font-size: 13px;
    padding: 8px 10px;
  }

  .summary-cards-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .summary-card-total {
    grid-column: 1 / -1;
  }

  .brand-title {
    font-size: 21px;
  }

  .date-row {
    grid-template-columns: 1.15fr 1fr;
    align-items: start;
  }

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

  .btn-copy-prev {
    width: auto;
  }

  .notes-grid {
    grid-template-columns: 1.35fr 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .dept-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
