:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #182026;
  --muted: #65717b;
  --line: #dce2e7;
  --brand: #b42318;
  --brand-dark: #861d16;
  --warning: #9a6700;
  --warning-bg: #fff3c4;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --success: #067647;
  --success-bg: #dcfae6;
  --shadow: 0 18px 50px rgba(24, 32, 38, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 32px; line-height: 1.1; }
h2 { margin-bottom: 8px; font-size: 25px; }

.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 780; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 6px; font-size: 13px; }
.eyebrow { margin-bottom: 10px; color: var(--brand); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.muted { color: var(--muted); }

.button { min-height: 42px; padding: 0 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 720; }
.button:hover { border-color: #b8c1c9; }
.button.primary { width: 100%; border-color: var(--brand); background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); }
.button:disabled { cursor: not-allowed; opacity: 0.52; }
.button.ghost { min-height: 38px; padding: 0 14px; background: transparent; }

.auth-page { min-height: 100vh; background: var(--surface); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr); }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(30px, 5vw, 76px); background: #20282d; color: #fff; }
.auth-brand .brand-mark { background: #fff; color: var(--brand); }
.auth-copy { max-width: 520px; }
.auth-copy h1 { max-width: 500px; font-size: clamp(40px, 4.2vw, 58px); }
.auth-copy p:last-child { max-width: 500px; color: #b8c2c9; font-size: 18px; line-height: 1.6; }
.auth-foot { margin-bottom: 0; color: #8f9ca5; font-size: 13px; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px; }
.auth-form { width: min(420px, 100%); display: grid; gap: 20px; }
.auth-shell.single { grid-template-columns: 1fr; background: var(--bg); }
.auth-shell.single .auth-form-wrap { min-height: 100vh; }
.auth-shell.single .auth-form { padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.field { display: grid; gap: 8px; font-size: 13px; font-weight: 750; }
.field input, .search-field input, .filter-field select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 0 13px; color: var(--text); outline: none; }
.field input:focus, .search-field input:focus, .filter-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1); }
.field small { color: var(--muted); font-weight: 500; line-height: 1.5; }
.alert { padding: 12px 14px; border: 1px solid #f0a8a1; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }

.topbar { position: sticky; top: 0; z-index: 10; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.96); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.user-name { color: var(--muted); font-size: 14px; }
.app-main { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 64px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { min-height: 108px; display: flex; flex-direction: column; justify-content: center; padding: 20px 22px; border: 1px solid var(--line); border-left: 4px solid #7d8992; border-radius: 7px; background: var(--surface); }
.metric strong { font-size: 30px; }
.metric span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.metric.warning { border-left-color: #d69e00; }
.metric.danger { border-left-color: var(--danger); }

.rpa-panel { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.rpa-panel h2 { font-size: 20px; }
.rpa-panel p { margin-bottom: 0; }
.rpa-panel form { flex: 0 0 auto; }
.rpa-panel .button.primary { width: auto; }
.run-note { margin-top: 9px !important; color: var(--muted); font-size: 12px; }

.records-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; align-items: end; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.search-field, .filter-field { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; }
.result-count { align-self: center; justify-self: end; color: var(--muted); font-size: 13px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.records-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.records-table th { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fbfcfd; font-size: 11px; text-align: left; text-transform: uppercase; }
.records-table td { padding: 16px; border-bottom: 1px solid #edf0f2; vertical-align: middle; font-size: 13px; line-height: 1.45; }
.records-table tr:last-child td { border-bottom: 0; }
.records-table tr:hover td { background: #fbfcfd; }
.records-table th:nth-child(1) { width: 25%; }
.records-table th:nth-child(2) { width: 9%; }
.records-table th:nth-child(3) { width: 15%; }
.records-table th:nth-child(4) { width: 12%; }
.records-table th:nth-child(5) { width: 13%; }
.records-table th:nth-child(6) { width: 26%; }
.plate { display: inline-flex; min-width: 78px; justify-content: center; padding: 5px 8px; border: 1px solid #aeb8bf; border-radius: 4px; background: #f7f9fa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: 0; }
.due-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; background: #edf1f3; color: #53616b; font-size: 11px; font-weight: 800; }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.success { background: var(--success-bg); color: var(--success); }
.contact-link { color: var(--brand); font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.empty { padding: 44px; color: var(--muted); text-align: center; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 290px; padding: 28px; }
  .auth-copy h1 { font-size: 40px; }
  .auth-copy p:last-child { font-size: 16px; }
  .auth-foot { display: none; }
  .auth-form-wrap { min-height: calc(100vh - 290px); padding: 32px 22px; }
  .user-name { display: none; }
  .app-main { width: min(100% - 28px, 720px); padding-top: 24px; }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 82px; }
  .toolbar { grid-template-columns: 1fr; }
  .result-count { justify-self: start; }
  .records-table, .records-table tbody, .records-table tr, .records-table td { display: block; width: 100%; }
  .records-table thead { display: none; }
  .records-table tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .records-table tr:last-child { border-bottom: 0; }
  .records-table td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 7px 0; border: 0; overflow-wrap: anywhere; }
  .records-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
  .records-table tr:hover td { background: transparent; }
  .plate { justify-self: start; }
  .rpa-panel { align-items: stretch; flex-direction: column; }
  .rpa-panel form, .rpa-panel .button.primary { width: 100%; }
}

@media (max-width: 520px) {
  .topbar { min-height: 62px; padding: 0 14px; }
  .topbar .brand > span:last-child { display: none; }
  .auth-brand { min-height: 250px; }
  .auth-copy h1 { font-size: 34px; }
  .auth-copy p:last-child { display: none; }
  .auth-form-wrap { min-height: calc(100vh - 250px); }
  .page-heading h1 { font-size: 28px; }
  .records-table td { grid-template-columns: 96px minmax(0, 1fr); }
}
