:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212f;
  background: #f4f7fb;
  --blue: #155eef;
  --blue-dark: #0b4cc4;
  --blue-soft: #eaf1ff;
  --border: #dfe6ef;
  --muted: #65758b;
  --warning: #b54708;
  --danger: #c4320a;
  --shadow: 0 12px 35px rgba(24, 39, 75, .08);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: linear-gradient(135deg, #0b4cc4, #155eef 48%, #5d8cff); }
.login-hero { padding: 72px clamp(36px, 7vw, 110px); color: white; display: flex; flex-direction: column; justify-content: center; }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 22px; font-weight: 800; border: 1px solid rgba(255,255,255,.32); }
.login-hero h1 { font-size: clamp(38px, 5vw, 68px); line-height: 1; margin: 28px 0 18px; letter-spacing: -.04em; }
.login-hero p { max-width: 540px; color: #e6edff; font-size: 18px; line-height: 1.7; }
.login-panel { background: white; display: grid; place-items: center; padding: 32px; border-radius: 32px 0 0 32px; }
.login-card { width: min(400px, 100%); }
.login-card h2 { margin: 0 0 8px; font-size: 28px; }
.login-card > p { color: var(--muted); margin: 0 0 32px; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 700; color: #344054; }
.field input, .field select, .company-select, .grid-input, .bulk-select { width: 100%; border: 1px solid #cdd7e5; border-radius: 9px; background: white; color: #17212f; outline: none; transition: border .15s, box-shadow .15s; }
.field input, .field select { height: 44px; padding: 0 12px; }
.field input:focus, .grid-input:focus, .bulk-select:focus, .company-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,94,239,.12); }
.primary, .secondary { min-height: 42px; border: 0; border-radius: 9px; padding: 0 17px; font-weight: 700; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.secondary { color: #344054; background: white; border: 1px solid #cdd7e5; }
.wide { width: 100%; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 0 0 10px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { background: #0d1b2f; color: white; padding: 24px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 17px; }
.sidebar-brand strong { display: block; font-size: 17px; }
.sidebar-brand small { color: #9eacc1; }
.nav { display: grid; gap: 7px; }
.nav button { border: 0; color: #b9c4d4; background: transparent; text-align: left; border-radius: 9px; padding: 12px 13px; font-weight: 650; }
.nav button:hover, .nav button.active { color: white; background: #203451; }
.nav-icon { display: inline-block; width: 25px; }
.sidebar-footer { position: absolute; bottom: 22px; left: 16px; right: 16px; }
.logout { width: 100%; border: 1px solid #344866; color: #d6deea; background: transparent; border-radius: 9px; padding: 10px; }
.main { min-width: 0; }
.topbar { min-height: 76px; padding: 0 30px; background: white; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 20px; position: sticky; top: 0; z-index: 5; }
.company-select { height: 40px; padding: 0 12px; min-width: 245px; font-weight: 650; }
.user-info { text-align: right; }
.user-info strong { display: block; font-size: 14px; }
.user-info small { color: var(--muted); text-transform: capitalize; }
.content { padding: 28px 30px 50px; max-width: 1500px; margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.page-head h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin: 0; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.card, .panel { background: white; border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow); }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.metric strong { display: block; margin-top: 8px; font-size: 27px; }
.metric small { color: var(--muted); }
.panel { padding: 22px; margin-bottom: 20px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-title h2 { margin: 0; font-size: 17px; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.dropzone { border: 2px dashed #aebbd0; border-radius: 13px; padding: 38px 24px; text-align: center; background: #f9fbfe; transition: .15s; }
.dropzone.dragging { border-color: var(--blue); background: var(--blue-soft); }
.dropzone-icon { font-size: 32px; }
.dropzone h3 { margin: 10px 0 6px; font-size: 16px; }
.dropzone p { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.file-summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; background: #f5f8fc; border-radius: 9px; padding: 12px 14px; margin-top: 14px; text-align: left; }
.file-summary span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th { background: #f7f9fc; color: #536277; font-size: 12px; text-align: left; padding: 11px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 12px; font-size: 13px; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
td small { color: var(--muted); line-height: 1.6; }
tr:last-child td { border-bottom: 0; }
.click-row { cursor: pointer; }
.click-row:hover td { background: #f7faff; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 750; white-space: nowrap; background: #eef2f7; color: #475467; }
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.green { background: #e7f8f1; color: #087a50; }
.badge.orange { background: #fff1e7; color: var(--warning); }
.badge.red { background: #ffebe7; color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 34px; }
.review-toolbar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.review-toolbar .bulk-select { height: 40px; padding: 0 10px; min-width: 220px; }
.grid-table { min-width: 1250px; }
.grid-table th:first-child, .grid-table td:first-child { position: sticky; left: 0; z-index: 2; background: white; }
.grid-table th:first-child { background: #f7f9fc; }
.grid-input { min-width: 120px; height: 36px; padding: 0 8px; border-radius: 7px; font-size: 13px; }
.grid-input.merchant { min-width: 180px; }
.grid-input.category { min-width: 170px; }
.row-error td { background: #fff7f5; }
.review-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.print-panel { max-width: 780px; }
.print-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.back-link { border: 0; padding: 0; color: var(--blue); background: transparent; font-weight: 700; margin-bottom: 12px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8,18,34,.58); display: grid; place-items: center; padding: 20px; }
.modal { width: min(500px, 100%); background: white; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.25); padding: 25px; }
.modal h2 { margin: 0 0 9px; font-size: 20px; }
.modal > p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal-summary { margin: 20px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.modal-row { display: flex; justify-content: space-between; gap: 20px; padding: 11px 13px; border-bottom: 1px solid var(--border); font-size: 13px; }
.modal-row:last-child { border-bottom: 0; }
.modal-row span { color: var(--muted); }
.duplicate-warning { color: var(--warning); background: #fff8eb; border-radius: 9px; padding: 11px; font-size: 13px; margin-bottom: 18px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#toast-region { position: fixed; right: 22px; top: 90px; z-index: 80; display: grid; gap: 9px; }
.toast { width: min(360px, calc(100vw - 44px)); background: #17212f; color: white; border-radius: 10px; padding: 13px 15px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.error { background: #a82b0c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-7px); } }
.spinner { width: 18px; height: 18px; display: inline-block; vertical-align: middle; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { border-radius: 0; min-height: 100vh; }
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 20px 10px; }
  .sidebar-brand { padding: 0 8px 25px; }
  .sidebar-brand div:last-child, .nav-label { display: none; }
  .nav button { text-align: center; }
  .nav-icon { width: auto; font-size: 19px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
  .shell { display: block; }
  .sidebar { position: fixed; bottom: 0; top: auto; width: 100%; height: 66px; z-index: 20; padding: 7px 12px; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
  .nav button { padding: 7px; }
  .nav-label { display: block; font-size: 10px; margin-top: 2px; }
  .nav-icon { display: block; }
  .topbar { padding: 12px 16px; align-items: stretch; flex-direction: column-reverse; gap: 7px; }
  .company-select { min-width: 0; }
  .user-info { text-align: left; }
  .content { padding: 20px 14px 90px; }
  .page-head { display: block; }
  .cards { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 22px; }
  .panel { padding: 15px; }
  .print-fields { grid-template-columns: 1fr; }
}
