:root {
  --red: #b5102a;
  --red-dark: #8d0b20;
  --red-soft: #f9e9ec;
  --gold: #f0b323;
  --ink: #211d1e;
  --muted: #706a6c;
  --line: #ded8d5;
  --paper: #fffdfb;
  --canvas: #f3f0ec;
  --success: #18754b;
  --success-soft: #e5f4ec;
  --warning: #a25b0b;
  --warning-soft: #fff3d7;
  --danger: #b42335;
  --shadow: 0 16px 45px rgba(47, 34, 36, .08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a, select, input[type="checkbox"] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.visually-hidden-file { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(29px, 4vw, 44px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -.015em; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.eyebrow { margin: 0 0 8px; color: var(--red); font-size: 11px; font-weight: 850; letter-spacing: .16em; }

.button {
  min-height: 43px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.disabled { opacity: .5; pointer-events: none; cursor: not-allowed; transform: none; }
.button.primary { color: #fff; background: var(--red); box-shadow: 0 9px 22px rgba(181, 16, 42, .18); }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { color: var(--red); border-color: #e5bdc5; background: var(--red-soft); }
.button.ghost { border-color: var(--line); background: rgba(255, 255, 255, .68); }
.button.success { color: #fff; background: var(--success); }
.button.danger { color: #fff; background: var(--danger); }
.button.dark { color: #fff; background: #302a2c; }
.button.full { width: 100%; }
.button.compact { min-height: 37px; padding: 0 12px; }
.icon-button { min-height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.danger-text { color: var(--danger); }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow: auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(240, 179, 35, .22), transparent 32%),
    radial-gradient(circle at 86% 88%, rgba(181, 16, 42, .35), transparent 36%),
    #251c1f;
}
.login-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 24px;
  background: rgba(255, 253, 251, .97);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .35);
}
.login-card h1 { margin-bottom: 10px; font-size: 34px; }
.login-card > .muted { margin-bottom: 25px; line-height: 1.55; }
.login-card label, .form-grid label, .admin-review > label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #4a4446;
  font-size: 12px;
  font-weight: 760;
}
.login-card > label { margin-top: 14px; }
.login-card input, .form-grid input, .form-grid select, .form-grid textarea, .filters input, .filters select, .admin-review textarea {
  width: 100%;
  min-height: 45px;
  border: 1px solid #d8d1ce;
  border-radius: 10px;
  outline: none;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-card input:focus, .form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .filters input:focus, .filters select:focus, .admin-review textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(181, 16, 42, .1);
}
.form-grid input[readonly] { color: #4b4547; background: #f1eeeb; cursor: default; }
textarea { resize: vertical; }
.password-row { position: relative; }
.password-row input { padding-right: 72px; }
.password-row .icon-button { position: absolute; top: 4px; right: 4px; }
.login-card .button { margin-top: 22px; }
.form-message { min-height: 21px; margin-top: 10px; color: var(--danger); font-size: 13px; font-weight: 700; }
.login-note { margin: 18px 0 0; color: #8a8284; font-size: 11px; line-height: 1.5; }

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  margin-bottom: 17px;
  color: #fff;
  background: var(--red);
  font-family: Georgia, serif;
  font-size: 33px;
  font-weight: 800;
  box-shadow: inset -5px -6px 0 rgba(0, 0, 0, .12);
}
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 10px; font-size: 25px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px max(22px, calc((100vw - 1420px) / 2));
  border-bottom: 1px solid rgba(91, 70, 74, .13);
  background: rgba(255, 253, 251, .93);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; color: var(--red); font-size: 13px; letter-spacing: .12em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.topbar-actions { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.current-user { max-width: 150px; overflow: hidden; color: #4a4446; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.admin-user { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.admin-user select { height: 37px; max-width: 185px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 0 9px; font-weight: 700; }
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 11px;
  color: #605a5c;
  background: #eeeae7;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #8d8688; }
.sync-pill[data-tone="ok"] { color: #155c3d; background: var(--success-soft); }
.sync-pill[data-tone="ok"] .sync-dot { background: var(--success); }
.sync-pill[data-tone="warn"] { color: #85500f; background: var(--warning-soft); }
.sync-pill[data-tone="warn"] .sync-dot { background: var(--warning); }
.sync-pill[data-tone="error"] { color: #8c1a2b; background: var(--red-soft); }
.sync-pill[data-tone="error"] .sync-dot { background: var(--danger); }
.sync-pill[data-tone="busy"] .sync-dot { background: var(--red); animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.72); } }

.page { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 90px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.hero-row h1 { margin-bottom: 7px; }
.hero-row .muted { margin: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { min-height: 122px; border: 1px solid rgba(104, 83, 87, .13); border-radius: 16px; padding: 19px; background: var(--paper); box-shadow: 0 9px 26px rgba(50, 37, 40, .05); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; margin-top: 16px; font-size: 27px; letter-spacing: -.03em; }
.stat-card em { display: block; margin-top: 4px; color: #8b8586; font-size: 11px; font-style: normal; }

.panel { border: 1px solid rgba(99, 80, 83, .14); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.panel-toolbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid #ebe6e3; }
.panel-toolbar h2, .panel-toolbar p { margin-bottom: 0; }
.filters { display: flex; gap: 9px; }
.filters input { width: min(270px, 33vw); }
.filters select { width: 155px; }
.report-list { min-height: 210px; }
.report-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.5fr) minmax(145px, .8fr) minmax(100px, .55fr) minmax(105px, .58fr) 34px;
  gap: 18px;
  align-items: center;
  min-height: 88px;
  padding: 14px 20px;
  border-bottom: 1px solid #eee9e6;
  cursor: pointer;
  transition: background .13s ease;
}
.report-row:last-child { border-bottom: 0; }
.report-row:hover { background: #fbf7f4; }
.report-row h3 { margin: 0 0 5px; font-size: 15px; }
.report-row p, .report-cell small { margin: 0; color: var(--muted); font-size: 12px; }
.report-cell { min-width: 0; }
.report-cell strong { display: block; margin-bottom: 4px; font-size: 14px; }
.report-total { font-size: 16px !important; }
.report-arrow { color: var(--red); font-size: 24px; text-align: right; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; min-height: 26px; border-radius: 999px; padding: 0 9px; color: #6f4b0e; background: var(--warning-soft); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .05em; }
.status-badge[data-status="approved"], .status-badge[data-status="reimbursed"] { color: #12603e; background: var(--success-soft); }
.status-badge[data-status="rejected"] { color: #912238; background: var(--red-soft); }
.status-badge[data-status="draft"] { color: #605b5d; background: #eeeae7; }
.empty-state { min-height: 280px; display: grid; place-items: center; padding: 35px; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 15px; border-radius: 18px; display: grid; place-items: center; color: var(--red); background: var(--red-soft); font-size: 28px; }
.quick-receipt-button { border: 1px solid #e8bec6; cursor: pointer; box-shadow: 0 7px 18px rgba(181, 16, 42, .1); transition: transform .15s ease, background .15s ease; }
.quick-receipt-button:hover { transform: translateY(-2px); background: #f6dfe4; }
.quick-receipt-button:focus-visible { outline: 3px solid rgba(181, 16, 42, .22); outline-offset: 3px; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { max-width: 410px; margin: 0 auto 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.editor-heading { display: grid; grid-template-columns: auto minmax(230px, 1fr) auto; gap: 18px; align-items: center; margin-bottom: 24px; }
.editor-title-block h1 { margin: 0 0 7px; font-size: clamp(25px, 3vw, 36px); }
.editor-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.editor-main { min-width: 0; display: grid; gap: 18px; }
.form-panel { padding: 23px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; }
.section-heading > p { max-width: 310px; margin: 2px 0 0; color: var(--muted); font-size: 12px; text-align: right; }
.step-number { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: var(--red); background: var(--red-soft); font-size: 12px; font-weight: 850; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.span-2 { grid-column: 1 / -1; }
.check-row { flex-direction: row !important; align-items: center; min-height: 42px; border: 1px solid #e2dcda; border-radius: 10px; padding: 9px 12px; background: #fff; }
.check-row input { width: 18px; min-height: 18px; margin: 0; }

.expense-list { display: grid; gap: 15px; }
.expense-list.drag-over { outline: 3px dashed var(--red); outline-offset: 7px; border-radius: 15px; background: rgba(181, 16, 42, .035); }
.expense-list.drag-over .empty-state { background: var(--red-soft); }
.expense-card { overflow: hidden; border: 1px solid #dfd9d6; border-radius: 15px; background: #fcfaf8; }
.expense-card-head { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 15px; border-bottom: 1px solid #e7e1de; background: #f7f3f0; }
.expense-card-head > div { display: flex; align-items: center; gap: 9px; }
.expense-index { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: var(--red); font-size: 11px; font-weight: 850; }
.expense-title { font-size: 14px; }
.expense-amount-preview { color: var(--red); font-size: 14px; font-weight: 850; }
.expense-grid { padding: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.expense-grid .span-2 { grid-column: span 2; }
.expense-grid .other-description { grid-column: span 2; }
.advanced-details { border-top: 1px solid #e7e1de; background: #fff; }
.advanced-details summary { padding: 13px 16px; color: #6a6264; font-size: 12px; font-weight: 750; cursor: pointer; }
.advanced-grid { padding: 4px 16px 17px; }
.attachments-block { padding: 15px 16px 17px; border-top: 1px solid #e7e1de; background: #fff; }
.attachments-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.attachments-heading strong { font-size: 12px; }
.attachments-heading span { color: var(--muted); font-size: 10px; }
.attachment-list { display: grid; gap: 7px; margin-bottom: 9px; }
.attachment-row { min-height: 44px; display: flex; align-items: center; gap: 10px; border: 1px solid #e6e0dd; border-radius: 9px; padding: 7px 9px; background: #faf8f6; }
.attachment-kind { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--red); background: var(--red-soft); font-size: 9px; font-weight: 850; }
.attachment-name { min-width: 0; flex: 1; }
.attachment-name strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-name small { color: var(--muted); font-size: 9px; }
.attachment-row button { padding: 0 6px; }
.upload-zone { min-height: 62px; display: flex !important; flex-direction: row !important; align-items: center; justify-content: center; gap: 12px !important; border: 1px dashed #d4a8b0; border-radius: 11px; padding: 10px; color: var(--red) !important; background: var(--red-soft); cursor: pointer; text-align: left; }
.upload-zone.drag-over { border-color: var(--red); background: #f6dfe4; box-shadow: 0 0 0 3px rgba(181, 16, 42, .1); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone span { display: flex; flex-direction: column; gap: 2px; }
.upload-zone small { color: #8b5a63; font-size: 10px; font-weight: 600; }
.upload-icon { width: 31px; height: 31px; flex: 0 0 auto; border-radius: 9px; display: grid !important; place-items: center; color: #fff; background: var(--red); font-size: 22px; line-height: 1; }

.summary-card { position: sticky; top: 86px; border: 1px solid rgba(93, 72, 76, .16); border-radius: 18px; padding: 22px; background: #2e2629; color: #fff; box-shadow: 0 19px 50px rgba(43, 31, 35, .18); }
.summary-card .eyebrow { color: #f4c14d; }
.summary-total { padding-bottom: 19px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.summary-total span { color: #cfc5c8; font-size: 12px; }
.summary-total strong { display: block; margin-top: 8px; font-size: 28px; letter-spacing: -.035em; }
.summary-lines { display: grid; gap: 10px; padding: 17px 0; }
.summary-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: #cdc4c6; font-size: 11px; }
.summary-line strong { color: #fff; font-size: 12px; text-align: right; }
.summary-divider { height: 1px; margin: 7px 0 15px; background: rgba(255, 255, 255, .14); }
.summary-card > .summary-line { margin-bottom: 10px; }
.summary-card .button { margin-top: 15px; color: #fff; border-color: rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); }

.admin-review > label { margin-bottom: 14px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.mobile-actionbar { display: none; }

.toast-region { position: fixed; z-index: 1500; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 380px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 12px 15px; color: #fff; background: #2d2729; box-shadow: 0 15px 40px rgba(0, 0, 0, .22); font-size: 12px; font-weight: 700; animation: toast-in .2s ease; }
.toast.error { background: #8e182b; }
.toast.success { background: #176b47; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1060px) {
  .sync-pill span:last-child { display: none; }
  .sync-pill { width: 30px; padding: 0; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-heading { grid-template-columns: auto 1fr; }
  .desktop-actions { grid-column: 1 / -1; }
  .editor-layout { grid-template-columns: minmax(0, 1fr) 275px; }
  .expense-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .topbar { padding-inline: 13px; }
  .brand span:last-child { display: none; }
  .current-user { display: none; }
  .admin-user > span { display: none; }
  .admin-user select { max-width: 130px; }
  .page { width: min(100% - 24px, 760px); padding-top: 25px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-row .button { width: 100%; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .filters input { width: 100%; flex: 1; }
  .report-row { grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px; }
  .report-row .report-cell:nth-child(2), .report-row .report-cell:nth-child(3) { display: none; }
  .report-row .report-cell:nth-child(4) { grid-column: 2; grid-row: 1; text-align: right; }
  .report-arrow { grid-column: 2; grid-row: 2; }
  .editor-layout { display: flex; flex-direction: column-reverse; }
  .summary-card { position: static; width: 100%; }
  .desktop-actions { display: none; }
  .mobile-actionbar {
    position: fixed;
    z-index: 95;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: .7fr 1.3fr;
    gap: 9px;
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid rgba(85, 64, 68, .14);
    background: rgba(255, 253, 251, .96);
    backdrop-filter: blur(15px);
  }
}

@media (max-width: 560px) {
  .login-card { padding: 25px 20px; }
  .topbar { min-height: 60px; }
  .brand-mark.small { width: 34px; height: 34px; }
  .topbar-actions { gap: 6px; }
  .admin-user select { max-width: 108px; padding: 0 5px; }
  .button.compact { padding: 0 9px; }
  .page { width: calc(100% - 20px); padding-bottom: 105px; }
  h1 { font-size: 31px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 105px; padding: 14px; }
  .stat-card strong { margin-top: 12px; font-size: 21px; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .editor-heading { grid-template-columns: 1fr; gap: 11px; }
  .editor-heading > .button { width: fit-content; }
  .form-panel { padding: 16px; border-radius: 14px; }
  .section-heading, .expenses-heading { align-items: stretch; flex-direction: column; }
  .section-heading > p { max-width: none; text-align: left; }
  .expenses-heading .button { width: 100%; }
  .form-grid, .expense-grid, .advanced-grid { grid-template-columns: 1fr; }
  .span-2, .expense-grid .span-2, .expense-grid .other-description { grid-column: 1; }
  .expense-card-head { align-items: flex-start; }
  .expense-head-actions { align-items: flex-end !important; flex-direction: column; gap: 0 !important; }
  .expense-grid { padding: 13px; }
  .attachments-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .attachment-row { flex-wrap: wrap; }
  .attachment-name { flex-basis: calc(100% - 42px); }
  .upload-zone { justify-content: flex-start; }
  .review-actions { display: grid; }
  .toast-region { right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); left: 10px; }
  .toast { max-width: none; }
}

@media print {
  .topbar, .button, .mobile-actionbar, .upload-zone { display: none !important; }
  .page { width: 100%; padding: 0; }
  .panel, .summary-card { box-shadow: none; }
}
