:root {
  --navy-950: #10233d;
  --navy-800: #1b3959;
  --blue-600: #176b87;
  --blue-500: #2189a8;
  --teal-500: #16a394;
  --teal-100: #dff6f2;
  --slate-900: #1c2b3a;
  --slate-700: #435568;
  --slate-500: #708196;
  --slate-300: #cdd7e2;
  --slate-200: #e3e9ef;
  --slate-100: #f1f5f8;
  --surface: #ffffff;
  --danger: #c64040;
  --danger-bg: #fff1f1;
  --success: #16856f;
  --shadow: 0 18px 45px rgba(20, 45, 70, 0.09);
  --radius: 18px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--slate-900);
  background: #edf3f6;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -4%, rgba(33, 137, 168, 0.14), transparent 28rem),
    linear-gradient(180deg, #f8fbfc 0, #edf3f6 100%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    linear-gradient(135deg, rgba(16, 35, 61, 0.97), rgba(23, 107, 135, 0.92)),
    repeating-linear-gradient(45deg, transparent 0 16px, rgba(255,255,255,.04) 16px 17px);
}

.login-card {
  width: min(440px, 100%);
  padding: 46px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 32px 80px rgba(4, 20, 37, 0.34);
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-size: 27px;
  font-weight: 750;
  background: linear-gradient(145deg, var(--blue-600), var(--teal-500));
  box-shadow: 0 10px 24px rgba(23, 107, 135, 0.24);
}

.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.eyebrow, .step-label { margin: 0; color: var(--blue-600); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.login-card .eyebrow { margin-top: 30px; }
.login-card h1 { margin: 7px 0 8px; font-size: 34px; letter-spacing: -.03em; }
.login-copy { margin: 0 0 30px; color: var(--slate-500); line-height: 1.7; }
.stack { display: grid; gap: 10px; }

label { color: var(--slate-700); font-size: 14px; font-weight: 650; }
label span { color: var(--slate-500); font-size: 12px; font-weight: 500; }
input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  outline: none;
  color: var(--slate-900);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
input::placeholder { color: #9aa8b7; }
input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(33, 137, 168, .12); }

.button {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, .tab:focus-visible, summary:focus-visible { outline: 3px solid rgba(33, 137, 168, .28); outline-offset: 3px; }
.button:disabled { cursor: wait; opacity: .58; }
.button.primary { color: white; background: linear-gradient(135deg, var(--blue-600), #147c91); box-shadow: 0 9px 20px rgba(23, 107, 135, .18); }
.button.secondary { color: var(--blue-600); border: 1px solid #b9d5de; background: #eff9fb; }
.button.ghost { color: var(--slate-700); border: 1px solid var(--slate-300); background: transparent; }
.button.full { width: 100%; margin-top: 4px; }
.button.compact { min-height: 38px; padding: 0 15px; font-size: 13px; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.security-note { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid var(--slate-200); color: var(--slate-500); font-size: 12px; line-height: 1.6; }

.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(205, 215, 226, .8); background: rgba(255, 255, 255, .92); backdrop-filter: blur(15px); }
.topbar-inner { width: min(1180px, calc(100% - 40px)); height: 70px; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.brand-row, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand-row > div:last-child { display: grid; gap: 2px; }
.brand-row strong { font-size: 16px; }
.brand-row span { color: var(--slate-500); font-size: 11px; }
.network-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; color: #147464; background: var(--teal-100); font-size: 12px; font-weight: 650; }
.network-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-500); box-shadow: 0 0 0 4px rgba(22,163,148,.13); }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 80px; }
.hero h1 { margin: 7px 0 8px; font-size: clamp(30px, 5vw, 44px); letter-spacing: -.04em; }
.hero > p:last-child { margin: 0; color: var(--slate-500); }

.tabs { margin: 34px 0 24px; padding: 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border: 1px solid var(--slate-200); border-radius: 16px; background: rgba(255,255,255,.7); }
.tab { padding: 14px 18px; border: 0; border-radius: 11px; display: flex; align-items: center; gap: 13px; text-align: left; color: var(--slate-700); background: transparent; cursor: pointer; }
.tab.active { color: var(--navy-950); background: #fff; box-shadow: 0 8px 24px rgba(20,45,70,.09); }
.tab-icon { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--slate-700); background: var(--slate-100); font-weight: 800; }
.tab.active .tab-icon { color: #fff; background: linear-gradient(145deg, var(--blue-600), var(--teal-500)); }
.tab > span:last-child { display: grid; gap: 2px; }
.tab strong { font-size: 15px; }
.tab small { color: var(--slate-500); font-size: 11px; }

.layout-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 22px; align-items: stretch; }
.card { border: 1px solid rgba(205, 215, 226, .8); border-radius: var(--radius); background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.form-card, .progress-card, .file-guide { padding: 30px; }
.section-heading { margin-bottom: 27px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading h2, .file-guide h2 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.02em; }
.privacy-chip { padding: 6px 10px; border-radius: 999px; color: var(--success); background: var(--teal-100); font-size: 11px; font-weight: 700; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { display: grid; gap: 8px; }
.field small { color: var(--slate-500); font-size: 12px; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--slate-300); border-radius: 10px; background: #fff; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.input-prefix:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(33, 137, 168, .12); }
.input-prefix span { padding-left: 14px; color: var(--slate-500); }
.input-prefix input { border: 0; box-shadow: none; }
#invoice-form .form-error, #file-form .form-error { margin-top: 14px; }

.compact-heading { margin-bottom: 25px; }
.status-pill { padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.status-pill.idle { color: var(--slate-500); background: var(--slate-100); }
.status-pill.queued, .status-pill.running { color: #9a6510; background: #fff4d8; }
.status-pill.succeeded { color: var(--success); background: var(--teal-100); }
.status-pill.failed { color: var(--danger); background: var(--danger-bg); }
.progress-visual { display: flex; align-items: center; gap: 16px; }
.progress-ring { width: 58px; height: 58px; flex: none; display: grid; place-items: center; border: 6px solid #dbe9ed; border-top-color: var(--blue-500); border-radius: 50%; color: var(--blue-600); font-size: 12px; font-weight: 800; }
.progress-ring.spinning { animation: spin 1.2s linear infinite; }
.progress-ring.spinning span { animation: spin-reverse 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-reverse { to { transform: rotate(-360deg); } }
.progress-visual strong { display: block; margin-bottom: 5px; }
.progress-visual p { margin: 0; color: var(--slate-500); font-size: 13px; line-height: 1.5; }
.progress-track { height: 6px; margin: 25px 0; overflow: hidden; border-radius: 999px; background: var(--slate-100); }
.progress-track span { width: 0; height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--blue-500), var(--teal-500)); transition: width .35s ease; }
.queue-message { margin: -9px 0 18px; padding: 9px 11px; border-radius: 8px; color: #865d19; background: #fff8e8; font-size: 12px; }
.stage-list { margin: 0; padding: 0; display: grid; gap: 13px; list-style: none; }
.stage-list li { display: flex; align-items: center; gap: 10px; color: var(--slate-500); font-size: 13px; }
.stage-list i { width: 9px; height: 9px; border: 2px solid var(--slate-300); border-radius: 50%; }
.stage-list li.active { color: var(--blue-600); font-weight: 700; }
.stage-list li.active i { border-color: var(--blue-500); background: var(--blue-500); box-shadow: 0 0 0 4px rgba(33,137,168,.12); }
.stage-list li.done { color: var(--success); }
.stage-list li.done i { border-color: var(--teal-500); background: var(--teal-500); }

.result-card, .pdf-card { margin-top: 22px; padding: 30px; }
.result-banner { padding-bottom: 24px; display: flex; gap: 16px; align-items: center; border-bottom: 1px solid var(--slate-200); }
.result-symbol { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--teal-500); font-size: 24px; font-weight: 800; }
.result-symbol.failed { background: var(--danger); }
.result-banner h2 { margin: 4px 0; font-size: 21px; }
.result-banner p:last-child { margin: 0; color: var(--slate-500); font-size: 13px; }
.red-flush-card { margin-top: 22px; padding: 22px; display: grid; grid-template-columns: minmax(190px, .75fr) minmax(0, 1.5fr); gap: 22px; align-items: center; border: 1px solid #badfd8; border-left: 6px solid var(--success); border-radius: 14px; background: linear-gradient(135deg, #f3fcfa, #fff); }
.red-flush-card > div > p { margin: 0 0 5px; color: var(--slate-500); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.red-flush-card h3 { margin: 0 0 6px; color: var(--success); font-size: 27px; letter-spacing: -.03em; }
.red-flush-card > div > span { color: var(--slate-500); font-size: 12px; line-height: 1.6; }
.red-flush-card dl { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.red-flush-card dl div { padding: 12px; border-radius: 9px; background: rgba(255,255,255,.76); }
.red-flush-card dt { margin-bottom: 6px; color: var(--slate-500); font-size: 10px; }
.red-flush-card dd { margin: 0; font-size: 14px; font-weight: 750; overflow-wrap: anywhere; }
.red-flush-card.partial { border-color: #f0d39b; border-left-color: #d18b16; background: linear-gradient(135deg, #fff9ea, #fff); }
.red-flush-card.partial h3 { color: #b87811; }
.red-flush-card.full { border-color: #efbaba; border-left-color: var(--danger); background: linear-gradient(135deg, #fff2f2, #fff); }
.red-flush-card.full h3 { color: var(--danger); }
.summary-grid { margin: 24px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.summary-item { padding: 15px; border: 1px solid var(--slate-200); border-radius: 11px; background: #fbfcfd; }
.summary-item span { display: block; margin-bottom: 6px; color: var(--slate-500); font-size: 11px; }
.summary-item strong { font-size: 14px; overflow-wrap: anywhere; }
.party-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.party-card { padding: 18px; border-radius: 12px; background: var(--slate-100); }
.party-card h3, .items-section h3 { margin: 0 0 14px; font-size: 14px; }
.party-card dl { margin: 0; display: grid; gap: 9px; }
.party-card dl div { display: grid; grid-template-columns: 74px 1fr; gap: 10px; font-size: 12px; }
.party-card dt { color: var(--slate-500); }
.party-card dd { margin: 0; overflow-wrap: anywhere; }
.items-section { margin-top: 26px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--slate-200); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--slate-200); text-align: left; }
th { color: var(--slate-500); background: var(--slate-100); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
.raw-result { margin-top: 24px; border-top: 1px solid var(--slate-200); }
.raw-result summary { padding: 18px 0 0; color: var(--blue-600); font-size: 13px; font-weight: 700; cursor: pointer; }
.raw-result pre { max-height: 420px; overflow: auto; padding: 16px; border-radius: 10px; color: #dbe7ef; background: var(--navy-950); font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }

.form-intro { margin: -12px 0 24px; color: var(--slate-500); font-size: 13px; line-height: 1.7; }
#file-form { display: grid; gap: 8px; }
.file-guide ol { margin: 24px 0 0; padding: 0; display: grid; gap: 20px; list-style: none; }
.file-guide li { display: flex; gap: 13px; align-items: flex-start; }
.file-guide li > span { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; color: var(--blue-600); background: #e9f4f7; font-size: 12px; font-weight: 800; }
.file-guide strong { font-size: 13px; }
.file-guide p { margin: 4px 0 0; color: var(--slate-500); font-size: 12px; line-height: 1.5; }
.pdf-toolbar { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.pdf-toolbar h2 { margin: 5px 0 0; font-size: 20px; }
#pdf-frame { width: 100%; height: 680px; border: 1px solid var(--slate-200); border-radius: 12px; background: var(--slate-100); }

footer { padding: 24px; border-top: 1px solid var(--slate-200); color: var(--slate-500); background: rgba(255,255,255,.66); text-align: center; font-size: 11px; }

.invoice-mode-switch { width: fit-content; margin: 0 0 18px; padding: 4px; display: flex; gap: 4px; border: 1px solid var(--slate-200); border-radius: 11px; background: var(--slate-100); }
.mode-button { min-height: 38px; padding: 0 18px; border: 0; border-radius: 8px; color: var(--slate-500); background: transparent; font-weight: 700; cursor: pointer; }
.mode-button.active { color: var(--blue-600); background: white; box-shadow: 0 4px 12px rgba(20,45,70,.09); }
.batch-upload-card, .batch-card { padding: 30px; }
.drop-zone { min-height: 180px; padding: 28px; border: 2px dashed #b9ced7; border-radius: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--slate-500); background: #f8fbfc; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--blue-500); background: #eff9fb; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone strong { color: var(--navy-950); font-size: 16px; }
.drop-zone small { font-size: 12px; }
.drop-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 13px; color: white; background: linear-gradient(145deg, var(--blue-600), var(--teal-500)); font-size: 12px; font-weight: 850; }
.sheet-icon { font-size: 10px; letter-spacing: .04em; }
.selected-files { margin: 14px 0 4px; display: flex; flex-wrap: wrap; gap: 7px; }
.selected-files span { max-width: 100%; padding: 7px 10px; overflow: hidden; border-radius: 8px; color: var(--slate-700); background: var(--slate-100); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.batch-card { margin-top: 22px; }
.section-copy { margin: 7px 0 0; color: var(--slate-500); font-size: 12px; line-height: 1.6; }
.batch-table-wrap { max-height: 620px; }
.editable-table input { min-width: 125px; height: 36px; padding: 0 9px; border-radius: 7px; font-size: 12px; }
.editable-table input[data-field="fphm"] { min-width: 190px; }
.editable-table input.invalid { border-color: var(--danger); background: var(--danger-bg); box-shadow: 0 0 0 2px rgba(195,55,55,.08); }
.filename-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.parse-ready { color: var(--success); }
.parse-warning { max-width: 260px; color: #a06409; white-space: normal; }
.batch-result-toolbar { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.batch-result-toolbar h2 { margin: 5px 0 0; font-size: 21px; }
.batch-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.batch-summary { margin-bottom: 18px; display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; }
.batch-summary div { padding: 15px; border-radius: 11px; display: flex; align-items: center; justify-content: space-between; background: var(--slate-100); }
.batch-summary span { font-size: 12px; font-weight: 700; }
.batch-summary strong { font-size: 22px; }
.batch-summary .full { color: var(--danger); background: #fff0f0; }
.batch-summary .partial { color: #ad6c08; background: #fff6df; }
.batch-summary .none { color: var(--success); background: var(--teal-100); }
.batch-summary .failed { color: var(--danger); background: var(--danger-bg); }
.red-status { padding: 5px 9px; border-radius: 999px; display: inline-block; font-weight: 750; }
.red-status.full { color: var(--danger); background: #fff0f0; }
.red-status.partial { color: #ad6c08; background: #fff3d7; }
.red-status.none { color: var(--success); background: var(--teal-100); }
.red-status.failed { color: var(--danger); background: var(--danger-bg); }
.red-status.pending { color: var(--slate-500); background: var(--slate-100); }
.comparison-exception { max-width: 420px; color: var(--danger); white-space: normal; line-height: 1.6; }
.row-error { max-width: 260px; display: block; color: var(--danger); white-space: normal; }
.result-table details summary { color: var(--blue-600); cursor: pointer; }
.result-table details pre { width: 360px; max-height: 260px; overflow: auto; padding: 12px; border-radius: 8px; color: #dbe7ef; background: var(--navy-950); white-space: pre-wrap; word-break: break-all; }
.button.disabled { opacity: .5; pointer-events: none; }
.file-batch-summary { margin-bottom: 18px; display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; }
.file-batch-summary div { padding: 15px; border-radius: 11px; display: flex; align-items: center; justify-content: space-between; color: var(--slate-700); background: var(--slate-100); }
.file-batch-summary span { font-size: 12px; font-weight: 700; }
.file-batch-summary strong { font-size: 22px; }
.file-batch-summary .running { color: var(--blue-600); background: #edf8fb; }
.file-batch-summary .success { color: var(--success); background: var(--teal-100); }
.file-batch-summary .failed { color: var(--danger); background: var(--danger-bg); }
.file-batch-summary .normal { color: var(--success); background: #e5f7ef; }
.file-batch-summary .abnormal { color: var(--danger); background: var(--danger-bg); }
.file-status { padding: 5px 9px; border-radius: 999px; display: inline-block; color: var(--slate-500); background: var(--slate-100); font-weight: 750; }
.file-status.running { color: var(--blue-600); background: #edf8fb; }
.file-status.succeeded { color: var(--success); background: var(--teal-100); }
.file-status.failed { color: var(--danger); background: var(--danger-bg); }
.comparison-status { min-width: 52px; padding: 5px 10px; border-radius: 999px; display: inline-block; text-align: center; font-weight: 800; }
.comparison-status.normal { color: var(--success); background: var(--teal-100); }
.comparison-status.abnormal { color: var(--danger); background: var(--danger-bg); }
.comparison-status.pending { color: var(--slate-500); background: var(--slate-100); }

.history-card, .history-detail { padding: 30px; }
.history-filters { margin-bottom: 20px; display: grid; grid-template-columns: 150px 150px minmax(0, 1fr); gap: 12px; align-items: end; }
.history-filters select { width: 100%; height: 44px; padding: 0 38px 0 12px; appearance: none; border: 1px solid var(--slate-300); border-radius: 10px; color: var(--navy-950); background-color: #fff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3.5 5.25 7 8.75l3.5-3.5' stroke='%2364758b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; font: inherit; }
.history-filters select,
.history-filters input,
.history-filters .button { font-size: 13px; }
.history-filters .button,
.history-date-filters input { height: 44px; }
.history-date-filters { display: grid; grid-template-columns: 150px 150px max-content; gap: 12px; align-items: end; }
.history-filters .history-filter-submit { width: fit-content; min-width: 0; justify-self: start; box-shadow: none; }
.history-table td:nth-child(3) { min-width: 220px; font-weight: 700; }
.history-pagination { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--slate-500); font-size: 12px; }
.history-detail { margin-top: 22px; }
.history-json { max-height: 620px; margin: 0; overflow: auto; padding: 18px; border-radius: 11px; color: #dbe7ef; background: var(--navy-950); font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.history-status { padding: 5px 9px; border-radius: 999px; display: inline-block; color: var(--slate-500); background: var(--slate-100); font-weight: 750; }
.history-status.succeeded, .history-status.completed { color: var(--success); background: var(--teal-100); }
.history-status.partial_failed { color: #ad6c08; background: #fff3d7; }
.history-status.failed { color: var(--danger); background: var(--danger-bg); }
.history-status.queued, .history-status.running { color: var(--blue-600); background: #edf8fb; }

@media (max-width: 860px) {
  .layout-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .red-flush-card { grid-template-columns: 1fr; }
  .batch-summary { grid-template-columns: repeat(2, 1fr); }
  .file-batch-summary { grid-template-columns: repeat(2, 1fr); }
  .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-date-filters { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)) max-content; }
}

@media (max-width: 600px) {
  .login-card { padding: 32px 24px; }
  .topbar-inner, .workspace { width: min(100% - 24px, 1180px); }
  .network-badge { display: none; }
  .workspace { padding-top: 34px; }
  .tabs { grid-template-columns: 1fr; }
  .tab small { display: none; }
  .form-grid, .party-grid { grid-template-columns: 1fr; }
  .form-card, .progress-card, .file-guide, .result-card, .pdf-card { padding: 22px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .red-flush-card dl { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: center; }
  #pdf-frame { height: 520px; }
  .batch-upload-card, .batch-card { padding: 22px; }
  .invoice-mode-switch { width: 100%; }
  .mode-button { flex: 1; }
  .history-card, .history-detail { padding: 22px; }
  .history-filters { grid-template-columns: 1fr; }
  .history-date-filters { grid-column: auto; grid-template-columns: minmax(0, 1fr) max-content; }
  .history-date-filters .field:first-child { grid-column: 1 / -1; }
}

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