:root {
  --ink: #18233a;
  --muted: #637083;
  --line: #dfe4eb;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --primary: #253c73;
  --primary-dark: #192b58;
  --accent: #c89548;
  --success: #18794e;
  --success-bg: #e8f6ef;
  --warning: #9a5b08;
  --warning-bg: #fff5dd;
  --danger: #b42318;
  --danger-dark: #8e1c13;
  --shadow: 0 12px 34px rgba(24, 35, 58, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: var(--canvas); color: var(--ink); }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: #fff;
  background: linear-gradient(115deg, #17254b, #293f76);
  box-shadow: 0 5px 22px rgba(18, 31, 64, 0.2);
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand img { border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.brand span { display: grid; line-height: 1.05; letter-spacing: .04em; }
.brand small { margin-top: 5px; color: #cbd4e6; font-size: .72rem; letter-spacing: .02em; }
.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a, .nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 0;
  border-radius: 9px;
  color: #f5f7fb;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}
.main-nav a:hover, .nav-link:hover { color: #fff; background: rgba(255,255,255,.11); }
.main-nav form { margin: 0; }
.nav-toggle { display: none; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 8px 11px; background: transparent; color: #fff; }

.page { width: min(1480px, calc(100% - 36px)); min-height: calc(100vh - 138px); margin: 0 auto; padding: 42px 0 64px; }
.page-auth { width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: radial-gradient(circle at 15% 15%, #eef0e5 0, transparent 28%), linear-gradient(145deg, #eef1f6, #f9f7f2); }
.footer { min-height: 66px; padding: 18px clamp(18px, 4vw, 56px); display: flex; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .88rem; }
.version-easter-egg-trigger { margin: 0; padding: 0; border: 0; color: inherit; background: transparent; cursor: default; user-select: none; }
.version-easter-egg-trigger:focus-visible { border-radius: 3px; outline: 2px solid var(--primary); outline-offset: 4px; }

.author-dialog { width: min(500px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 1px solid rgba(130, 143, 165, .55); border-radius: 22px; color: var(--ink); background: #fff; box-shadow: 0 28px 80px rgba(10, 20, 45, .3); overflow-x: hidden; overflow-y: auto; }
.author-dialog::backdrop { background: rgba(16, 25, 45, .62); backdrop-filter: blur(3px); }
.author-dialog[open] { animation: author-dialog-enter .24s cubic-bezier(.2, .8, .2, 1); }
.author-dialog[open]::backdrop { animation: author-backdrop-enter .2s ease-out; }
.author-dialog-shell { position: relative; padding: 38px 42px 34px; display: flex; flex-direction: column; align-items: center; text-align: center; background: radial-gradient(circle at 50% 0, #edf1fa 0, #fff 48%); }
.author-dialog-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: #536074; background: rgba(255,255,255,.88); font-size: 1.55rem; line-height: 1; cursor: pointer; }
.author-dialog-close:hover, .author-dialog-close:focus-visible { color: var(--primary); border-color: #9daabd; background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(37,60,115,.12); }
.author-dialog-illustration { width: min(100%, 340px); height: auto; margin: 0 0 22px; border-radius: 16px; box-shadow: 0 10px 25px rgba(37,60,115,.12); }
.author-dialog .eyebrow { margin-bottom: 7px; }
.author-dialog h2 { margin: 0; font-size: 1.65rem; letter-spacing: -.025em; }
.author-dialog-credit { margin: 16px 0 7px; color: #46536a; font-size: 1.02rem; line-height: 1.55; }
.author-dialog-name { display: block; margin-top: 3px; color: var(--ink); white-space: nowrap; }
.author-dialog-email { margin-bottom: 25px; font-weight: 750; overflow-wrap: anywhere; }

@keyframes author-dialog-enter {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes author-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-heading { margin-bottom: 28px; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.page-heading h1 { margin: 2px 0 0; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.08; letter-spacing: -.035em; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.lead { max-width: 760px; margin: 10px 0 0; color: var(--muted); font-size: 1.02rem; }
.muted { color: var(--muted); }

.panel { margin-bottom: 22px; padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.panel.narrow { width: min(720px, 100%); }
.panel h2 { margin: 0 0 18px; font-size: 1.18rem; }
.panel-heading { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading h2, .panel-heading p { margin: 0; }
.panel-heading p { margin-top: 5px; color: var(--muted); }
.step { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 50%; color: var(--primary); background: #edf1fa; font-weight: 800; }

.stats-grid { margin-bottom: 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat-card { min-height: 142px; padding: 25px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-weight: 650; }
.stat-card strong { font-size: 2.2rem; letter-spacing: -.04em; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-large { display: flex; flex-direction: column; gap: 0; }
.form-grid { display: grid; gap: 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid + .form-grid { margin-top: 18px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field > label, .upload-field > label { font-size: .9rem; font-weight: 750; }
.field small, .upload-field small { color: var(--muted); line-height: 1.45; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="search"], select, .upload-field input[type="file"] {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #bbc3cf; border-radius: 9px; color: var(--ink); background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,60,115,.13); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.upload-field { min-height: 190px; padding: 26px; display: flex; flex-direction: column; justify-content: center; gap: 10px; border: 2px dashed #b9c2d1; border-radius: 14px; background: #f8f9fc; }
.upload-field input[type="file"] { height: auto; padding: 12px; background: #fff; }
.inline-control { display: flex; align-items: center; gap: 9px; }
.inline-control > input, .inline-control > select, .inline-control > label { flex: 1; }
.filter-action > span { font-size: .9rem; font-weight: 750; }
.filter-action .button { align-self: flex-start; }
.filter-action .button-group { align-items: stretch; }
.inline-form { display: inline-block; margin: 10px 0 0 8px; }
.checkbox-line { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 650; }
.checkbox-field { padding: 10px 0; }
.optional-fields { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.optional-fields summary, .danger-zone summary { color: var(--primary); font-weight: 750; cursor: pointer; }
.optional-fields summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.optional-fields[open] summary { margin-bottom: 18px; }
.optional-fields + .optional-fields { margin-top: 16px; }
.filter-actions { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.filter-actions p { margin: 0; color: var(--muted); font-size: .86rem; }
.field-help { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.discount-replacements { display: grid; gap: 15px; }
.discount-replacement-list { display: grid; gap: 11px; }
.discount-replacement-row { padding: 14px; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; align-items: end; gap: 12px; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fc; }
.discount-replacement-row .field > span { font-size: .9rem; font-weight: 750; }
.discount-replacement-remove { margin-bottom: 3px; }
.discount-replacement-actions { display: flex; align-items: center; gap: 14px; }
.discount-replacement-actions small { color: var(--muted); line-height: 1.45; }
.discount-replacement-actions .button:disabled { opacity: .55; cursor: not-allowed; }

.button { min-height: 44px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; }
.button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { color: #fff; background: var(--primary-dark); border-color: var(--primary-dark); }
.button.secondary { color: var(--primary); background: #fff; border-color: #adb8ca; }
.button.secondary:hover { color: var(--primary-dark); background: #f1f4fa; border-color: var(--primary); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.danger:hover { color: #fff; background: var(--danger-dark); }
.button.compact { min-height: 40px; padding: 8px 13px; font-size: .88rem; white-space: nowrap; }
.button.full { width: 100%; }
.button[hidden] { display: none !important; }
.button-group { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }

.selection-toolbar { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.search-field { width: min(430px, 100%); }
.table-hint { margin: -4px 0 10px; color: var(--muted); font-size: .82rem; }
.filter-result { margin: -4px 0 18px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--line); border-radius: 10px; background: #f7f8fb; }
.filter-result.active { border-color: #a7d9c2; background: var(--success-bg); }
.filter-result div { display: grid; gap: 3px; }
.filter-result span { color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.filter-result p { margin: 0; color: var(--muted); text-align: right; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th { padding: 12px 14px; color: #4c5a70; background: #f5f7fa; font-size: .76rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.sort-button { margin: -8px -10px; padding: 8px 10px; border: 0; color: inherit; background: transparent; font: inherit; font-weight: 800; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sort-button:hover, .sort-button:focus-visible { color: var(--primary); background: #e9edf5; outline: none; }
.sort-button [data-sort-indicator] { display: inline-block; min-width: 1em; }
.date-column { min-width: 170px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
td.table-empty { padding: 34px 18px; color: var(--muted); text-align: center; white-space: normal; }
tbody tr:hover { background: #fafbfc; }
tr[hidden] { display: none; }
.order-table { max-height: 660px; }
.order-table thead { position: sticky; top: 0; z-index: 1; }
.check-column { width: 48px; }
.compact-table { max-height: 520px; }
.pagination { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 14px; }

.csv-order-grid { max-height: 620px; overflow: auto; scrollbar-gutter: stable; }
.csv-order-grid table { width: max-content; min-width: 100%; }
.csv-order-grid th { position: sticky; top: 0; z-index: 2; }
.csv-order-grid th, .csv-order-grid td { padding: 8px 10px; }
.csv-order-grid td { white-space: nowrap; }
.csv-order-grid th:first-child, .csv-order-grid td:first-child { left: 0; width: 48px; min-width: 48px; max-width: 48px; box-sizing: border-box; position: sticky; background: #fff; }
.csv-order-grid th:nth-child(2), .csv-order-grid td:nth-child(2) { left: 48px; min-width: 112px; position: sticky; background: #fff; box-shadow: 5px 0 8px -8px #34425a; }
.csv-order-grid th:first-child, .csv-order-grid th:nth-child(2) { z-index: 4; background: #f5f7fa; }
.csv-order-grid td:first-child, .csv-order-grid td:nth-child(2) { z-index: 1; }
.csv-order-grid tr:hover td:first-child, .csv-order-grid tr:hover td:nth-child(2) { background: #fafbfc; }
.csv-aggregate-value { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-detail-trigger { margin: -4px -6px; padding: 4px 6px; display: grid; gap: 1px; border: 0; border-radius: 6px; color: var(--primary); background: transparent; text-align: left; cursor: pointer; }
.order-detail-trigger:hover, .order-detail-trigger:focus-visible { color: var(--primary-dark); background: #eaf0fb; outline: none; }
.order-detail-trigger small { color: var(--muted); font-size: .67rem; font-weight: 600; }

.csv-order-dialog { width: min(1600px, calc(100vw - 40px)); height: min(850px, calc(100vh - 40px)); max-width: none; max-height: none; padding: 0; border: 1px solid #b8c1ce; border-radius: 15px; color: var(--ink); background: #fff; box-shadow: 0 28px 80px rgba(10,20,45,.28); overflow: hidden; }
.csv-order-dialog::backdrop { background: rgba(16, 25, 45, .62); backdrop-filter: blur(2px); }
.csv-order-dialog-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.csv-order-dialog header, .csv-order-dialog footer { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; }
.csv-order-dialog header { border-bottom: 1px solid var(--line); }
.csv-order-dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.csv-order-dialog h2, .csv-order-dialog .eyebrow { margin: 0; }
.csv-order-dialog h2 { margin-top: 3px; font-size: 1.35rem; }
.dialog-close { width: 40px; height: 40px; display: grid; place-items: center; flex: none; border: 1px solid var(--line); border-radius: 50%; color: #4f5c6b; background: #fff; font-size: 1.7rem; line-height: 1; cursor: pointer; }
.dialog-close:hover, .dialog-close:focus-visible { color: var(--primary); border-color: #9daabd; background: #f2f5fa; outline: none; }
.csv-order-dialog-body { min-height: 0; padding: 18px 22px; overflow: hidden; }
.dialog-status { margin: 30px 0; color: var(--muted); text-align: center; }
.dialog-status.error { padding: 14px 16px; border: 1px solid #e7aaa5; border-radius: 9px; color: var(--danger); background: #fff0ef; }
.order-detail-summary { margin: 0 0 16px; display: grid; grid-template-columns: repeat(8, minmax(110px, 1fr)); gap: 10px; }
.order-detail-summary div { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8f9fb; }
.order-detail-summary dt { margin: 0 0 3px; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.order-detail-summary dd { margin: 0; overflow-wrap: anywhere; font-size: .8rem; font-weight: 700; }
.csv-detail-table { max-height: calc(100vh - 300px); border-radius: 9px; }
.csv-detail-table table { width: max-content; min-width: 100%; }
.csv-detail-table thead { position: sticky; top: 0; z-index: 2; }
.csv-detail-table th, .csv-detail-table td { padding: 9px 11px; }
.csv-detail-table td { max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
.csv-detail-table th:first-child, .csv-detail-table td:first-child { position: sticky; left: 0; z-index: 1; background: #f5f7fa; }

.excel-column-legend { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .76rem; }
.excel-column-legend span { white-space: nowrap; }
.excel-column-legend strong { color: var(--primary); }
.excel-preview-table { max-height: 720px; background: #fff; }
.excel-preview-table table { width: max-content; min-width: 100%; table-layout: fixed; font-family: Calibri, "Segoe UI", sans-serif; font-size: .82rem; }
.excel-preview-table th, .excel-preview-table td { min-width: 92px; height: 33px; padding: 7px 9px; border: 1px solid #cfd5dd; background: #fff; }
.excel-preview-table thead { position: sticky; top: 0; z-index: 4; }
.excel-preview-table thead th { height: 28px; padding: 4px 8px; color: #4f5c6b; background: #e9edf2; text-align: center; }
.excel-preview-table .excel-row-number { min-width: 46px; width: 46px; color: #596674; background: #edf0f4; font-weight: 650; text-align: center; }
.excel-preview-table .excel-column-letters .excel-row-number { min-width: 46px; }
.excel-preview-table .excel-metadata td { height: 34px; font-weight: 650; }
.excel-preview-table .excel-metadata tr:hover td { background: #fff; }
.excel-preview-table .excel-spacer td, .excel-preview-table .excel-spacer th { height: 12px; padding: 0; background: #fff; }
.excel-preview-table .excel-spacer .excel-row-number { background: #edf0f4; }
.excel-preview-table .excel-header-row th { color: #24324a; background: #eef1f5; font-size: .72rem; line-height: 1.15; white-space: normal; text-align: center; }
.excel-preview-table .excel-header-row .excel-row-number { color: #596674; }
.excel-preview-table tbody[data-excel-order] tr:hover td { background: #f9fbfd; }
.excel-preview-table .excel-col-a { min-width: 92px; width: 92px; text-align: center; }
.excel-preview-table .excel-col-b { min-width: 120px; width: 120px; }
.excel-preview-table .excel-col-c { min-width: 72px; width: 72px; text-align: center; }
.excel-preview-table .excel-col-d { min-width: 150px; width: 150px; }
.excel-preview-table .excel-col-e { min-width: 390px; width: 390px; }
.excel-preview-table .excel-col-f, .excel-preview-table .excel-col-g, .excel-preview-table .excel-col-h, .excel-preview-table .excel-col-i { min-width: 135px; width: 135px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.excel-preview-table .excel-discount-cell { min-width: 235px; width: 235px; vertical-align: middle; font-weight: 700; white-space: pre-wrap; }
.excel-preview-table tbody[hidden], .excel-preview-table [hidden] { display: none !important; }

.badge { padding: 4px 9px; display: inline-flex; border-radius: 999px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.badge.success { color: var(--success); background: var(--success-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.neutral { color: #566274; background: #edf0f4; }
.current-user { margin-left: 7px; padding: 2px 6px; border-radius: 5px; color: var(--primary); background: #edf1fa; }

.generate-panel { display: flex; align-items: center; justify-content: space-between; gap: 30px; border-left: 5px solid var(--accent); }
.generate-panel h2, .generate-panel p { margin: 0; }
.generate-panel p { margin-top: 6px; color: var(--muted); }
.generate-actions { display: flex; align-items: center; gap: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.details { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.details div { min-width: 0; }
.details dt { margin-bottom: 5px; color: var(--muted); font-size: .78rem; font-weight: 750; text-transform: uppercase; }
.details dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.danger-zone { border-color: #e7aaa5; box-shadow: none; }
.danger-zone[open] summary { margin-bottom: 14px; color: var(--danger); }

.messages { margin: 0 0 20px; display: grid; gap: 9px; }
.message { padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.message.success { color: var(--success); border-color: #a7d9c2; background: var(--success-bg); }
.message.error { color: var(--danger); border-color: #e7aaa5; background: #fff0ef; }
.message.warning { color: var(--warning); border-color: #efd08e; background: var(--warning-bg); }
.form-errors, .errorlist { color: var(--danger); }
.form-errors { padding: 13px 15px; border: 1px solid #e7aaa5; border-radius: 9px; background: #fff0ef; }
.errorlist { margin: 0; padding-left: 20px; font-size: .85rem; }
.info-box { padding: 14px 16px; border-left: 4px solid var(--primary); border-radius: 7px; color: #3f4e66; background: #eef2f9; line-height: 1.5; }

.live-test-plan-field { grid-column: 1 / -1; }
.live-test-plan { display: grid; gap: 10px; margin: 12px 0; }
.live-test-plan-row { display: grid; grid-template-columns: minmax(120px, 0.8fr) minmax(170px, 1fr) auto; gap: 12px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.live-test-plan-row label { display: grid; gap: 6px; font-weight: 700; }
.live-test-plan-row input { width: 100%; }

@media (max-width: 680px) {
  .live-test-plan-row { grid-template-columns: 1fr; align-items: stretch; }
}
.brt-safety-note { margin-bottom: 22px; }
.brt-batch-progress { min-height: 1.5em; margin: 0 0 12px; color: var(--success); font-weight: 700; }
.brt-batch-progress.error { color: var(--danger); }
.brt-message { min-width: 220px; max-width: 360px; white-space: normal; }
.brt-code { margin-top: 4px; display: block; color: var(--muted); }
.brt-search-form { align-items: end; }
.brt-list-actions { margin: 20px 0 10px; }
.brt-list-actions + .table-hint { margin: 0 0 12px; }
.brt-whole-batch-action { margin: 20px 0; padding: 14px 16px; display: flex; align-items: center; gap: 14px; border: 1px solid #a7d9c2; border-radius: 10px; background: var(--success-bg); }
.brt-whole-batch-action small { color: var(--muted); line-height: 1.4; }
.brt-preview-note { margin: 12px 0 0; }
.empty { padding: 42px 18px; text-align: center; color: var(--muted); }
.empty h3 { margin: 0 0 7px; color: var(--ink); }
.empty p { margin: 0; }

.auth-card { width: min(440px, 100%); padding: 38px; border: 1px solid rgba(140,151,171,.35); border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: 0 22px 60px rgba(30,42,67,.13); }
.auth-logo { display: block; margin: 0 auto 18px; border-radius: 20px; box-shadow: 0 10px 25px rgba(24,35,58,.16); }
.auth-card h1 { margin: 0; text-align: center; font-size: 1.8rem; }
.auth-card > p { text-align: center; }
.auth-action { margin: 18px 0 0; font-weight: 700; }
.security-note { margin: 22px 0 0; color: var(--muted); font-size: .78rem; }
.audit-list { display: grid; }
.audit-list > div { padding: 12px 0; display: grid; grid-template-columns: minmax(140px, .8fr) minmax(160px, 1fr) minmax(220px, 1.2fr); gap: 15px; border-top: 1px solid var(--line); }
.audit-list > div:first-child { border-top: 0; }
.audit-list small { color: var(--muted); }
.error-page { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.error-page > span { color: #c9d0dc; font-size: 5rem; font-weight: 900; line-height: 1; }
.error-page h1 { margin: 12px 0 5px; }
.error-page p { margin: 0 0 22px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .nav-toggle { display: inline-flex; }
  .topbar { position: relative; }
  .main-nav { position: absolute; z-index: 20; top: 67px; right: 18px; width: min(310px, calc(100vw - 36px)); padding: 10px; display: none; flex-direction: column; align-items: stretch; border: 1px solid #435783; border-radius: 12px; background: #1d2f5d; box-shadow: 0 14px 34px rgba(10,20,45,.3); }
  .main-nav.open { display: flex; }
  .main-nav a, .nav-link { width: 100%; }
  .form-grid.three, .form-grid.four { grid-template-columns: 1fr 1fr; }
  .vendor-field { grid-column: 1 / -1; }
  .generate-panel, .generate-actions, .filter-actions { align-items: stretch; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .order-detail-summary { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
}

@media (max-width: 680px) {
  .page { width: min(100% - 24px, 1480px); padding-top: 26px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading > .button { align-self: flex-start; }
  .stats-grid, .form-grid.three, .form-grid.four, .form-grid.two, .details { grid-template-columns: 1fr; }
  .discount-replacement-row { grid-template-columns: 1fr; align-items: stretch; }
  .discount-replacement-remove { justify-self: start; margin-bottom: 0; }
  .discount-replacement-actions { align-items: stretch; flex-direction: column; }
  .stat-card { min-height: 112px; }
  .selection-toolbar, .filter-result, .footer { align-items: stretch; flex-direction: column; }
  .brt-whole-batch-action { align-items: stretch; flex-direction: column; }
  .brt-whole-batch-action .button { width: 100%; }
  .filter-result p { text-align: left; }
  .search-field { width: 100%; }
  .button-group .button { flex: 1; }
  .inline-control { align-items: stretch; flex-direction: column; }
  .pagination { flex-wrap: wrap; }
  .csv-order-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .csv-order-dialog header, .csv-order-dialog footer, .csv-order-dialog-body { padding: 14px; }
  .order-detail-summary { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .csv-detail-table { max-height: calc(100vh - 390px); }
  .author-dialog-shell { padding: 34px 24px 28px; }
  .auth-card { padding: 28px 22px; }
  .audit-list > div { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .author-dialog[open], .author-dialog[open]::backdrop { animation: none; }
}

@media print {
  .topbar, .footer, .author-dialog, .button, .selection-toolbar, .danger-zone { display: none !important; }
  .page { width: 100%; padding: 0; }
  .panel { box-shadow: none; break-inside: avoid; }
}
