:root {
  --navy: #0b2f4f;
  --navy-2: #164e73;
  --blue: #1677b8;
  --sky: #e9f4fb;
  --ink: #17212b;
  --muted: #637381;
  --line: #dbe4ea;
  --surface: #ffffff;
  --bg: #f3f6f8;
  --success: #147a4b;
  --success-bg: #e8f6ef;
  --warning: #9a6100;
  --warning-bg: #fff5d9;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --shadow: 0 12px 34px rgba(11,47,79,.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, #eef4f7 0, var(--bg) 220px); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; min-height: 72px; padding: 10px max(24px, calc((100vw - 1380px)/2));
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark, .login-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--navy), var(--blue)); color: white; font-weight: 900; letter-spacing: -.5px;
  box-shadow: 0 8px 20px rgba(11,47,79,.22);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); margin-top: 1px; }
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav > a, .link-button { color: #405260; padding: 10px 12px; border-radius: 8px; border: 0; background: transparent; font-weight: 650; }
.topnav > a:hover, .link-button:hover { background: var(--sky); color: var(--navy); text-decoration: none; }
.topnav .nav-primary { background: var(--navy); color: white; }
.topnav .nav-primary:hover { background: var(--navy-2); color: white; }
.logout-form { margin: 0; }

.page-shell { width: min(1380px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 70px; }
.page-heading { margin-bottom: 25px; }
.page-heading h1 { margin: 5px 0 6px; font-size: clamp(28px, 3vw, 42px); line-height: 1.08; letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 16px; }
.eyebrow { color: var(--blue); text-transform: uppercase; font-size: 12px; font-weight: 850; letter-spacing: .12em; }
.heading-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.narrow-heading { max-width: 780px; margin-left: auto; margin-right: auto; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-weight: 650; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 10px 16px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 750; line-height: 1.1; text-decoration: none; transition: .16s ease;
}
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { background: var(--navy); color: white; box-shadow: 0 7px 18px rgba(11,47,79,.18); }
.button-primary:hover { background: var(--navy-2); color: white; }
.button-secondary { background: var(--blue); color: white; }
.button-secondary:hover { background: #0f669f; color: white; }
.button-ghost { border-color: #c9d8e2; color: var(--navy); background: white; }
.button-ghost:hover { border-color: var(--blue); background: var(--sky); }
.button-success { background: var(--success); color: white; }
.button-danger { background: var(--danger); color: white; }
.button-large { min-height: 52px; padding: 14px 22px; font-size: 16px; }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.panel, .upload-card, .login-card, .error-card {
  background: var(--surface); border: 1px solid rgba(198,214,223,.85); border-radius: 16px; box-shadow: var(--shadow);
}
.panel { padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-heading h2, .panel h2 { margin: 0; font-size: 19px; }
.panel-heading > span { color: var(--muted); font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 20px 0; }
.metric-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-card { min-height: 112px; padding: 19px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 7px 20px rgba(11,47,79,.05); }
.metric-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-card strong { display: block; margin-top: 13px; color: var(--navy); font-size: clamp(23px, 2.4vw, 31px); line-height: 1; letter-spacing: -.03em; }
.metric-success { border-top: 4px solid var(--success); }
.metric-warning { border-top: 4px solid #d79000; }
.metric-danger { border-top: 4px solid var(--danger); }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 16px; background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 13px; }
.filter-bar.compact { margin-bottom: 4px; }
.filter-bar label { min-width: 125px; }
.filter-bar input, .filter-bar select { min-width: 125px; }
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; }
.pending-badge { padding: 10px 14px; background: var(--warning-bg); color: var(--warning); border: 1px solid #f2d488; border-radius: 999px; font-weight: 800; }

label { display: block; color: #334552; font-size: 13px; font-weight: 720; }
input, select, textarea {
  width: 100%; margin-top: 7px; padding: 11px 12px; color: var(--ink); background: white;
  border: 1px solid #c9d6de; border-radius: 9px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,119,184,.13); }
textarea { resize: vertical; }
.stack-form { display: grid; gap: 15px; }
.form-grid { display: grid; gap: 15px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.four-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-panel { padding: 26px; }
.form-panel > h2 { margin-bottom: 18px; }
.expense-form { display: grid; gap: 22px; }
.amount-fieldset { border: 1px solid #cddde6; border-radius: 13px; padding: 18px; background: #f7fbfd; }
.amount-fieldset legend { padding: 0 8px; color: var(--navy); font-weight: 850; }
.money-input { position: relative; }
.money-input input { padding-right: 36px; }
.money-input span { position: absolute; right: 13px; top: 50%; transform: translateY(-34%); color: var(--muted); font-weight: 750; }
.calculation-status { min-height: 20px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.calculation-status.ok { color: var(--success); }
.calculation-status.error { color: var(--danger); }
.confirmation-check { display: flex; align-items: flex-start; gap: 10px; padding: 14px; background: var(--sky); border-radius: 10px; }
.confirmation-check input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 11px 12px; color: #60717d; background: #f7f9fa; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #e7edf1; vertical-align: top; }
tbody tr:hover { background: #f8fbfd; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 3px; }
.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount.strong { font-weight: 850; color: var(--navy); }
.table-link { font-weight: 800; white-space: nowrap; }
.inline-form { display: flex; gap: 7px; min-width: 260px; }
.inline-form input { margin: 0; min-width: 150px; padding: 8px 10px; }

.status { display: inline-flex; align-items: center; justify-content: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 850; white-space: nowrap; }
.status-submitted { background: var(--warning-bg); color: var(--warning); }
.status-approved { background: var(--success-bg); color: var(--success); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }
.status-large { padding: 9px 15px; font-size: 14px; }

.upload-card { max-width: 780px; margin: 0 auto; padding: 26px; }
.upload-form { display: grid; gap: 20px; }
.upload-zone { display: grid; place-items: center; min-height: 280px; padding: 30px; text-align: center; background: linear-gradient(180deg, #f7fbfd, #eef7fb); border: 2px dashed #8bbbd8; border-radius: 16px; cursor: pointer; }
.upload-zone:hover { border-color: var(--blue); background: var(--sky); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone strong { margin: 12px 0 5px; font-size: 20px; color: var(--navy); }
.upload-zone > span:last-of-type { color: var(--muted); font-weight: 500; }
.camera-icon { font-size: 52px; line-height: 1; }
.selected-file { padding: 12px 14px; border-radius: 10px; background: var(--success-bg); color: var(--success); font-weight: 720; }
.photo-tips { padding: 17px; background: #f8fafb; border: 1px solid var(--line); border-radius: 12px; }
.photo-tips h2 { margin: 0 0 12px; font-size: 15px; }
.tip-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; color: #4e626f; font-size: 13px; }

.review-layout { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(620px, 1.22fr); gap: 20px; align-items: start; }
.document-panel { position: sticky; top: 92px; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 15px; }
.document-panel .panel-heading { margin: 0 0 12px; }
.document-panel img, .document-panel iframe { width: 100%; min-height: 580px; max-height: 76vh; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #eef1f3; }
.document-panel iframe { height: 680px; }
.ocr-note { margin: -8px 0 18px; color: var(--muted); font-size: 13px; }

.alert { margin: 0 0 18px; padding: 14px 16px; border-radius: 11px; border: 1px solid; }
.alert-error { color: var(--danger); background: var(--danger-bg); border-color: #efb8b3; }
.alert-warning { color: var(--warning); background: var(--warning-bg); border-color: #efd58d; }
.alert-success { color: var(--success); background: var(--success-bg); border-color: #a8ddc2; }

.detail-layout { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(300px,.65fr); gap: 20px; align-items: start; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; margin: 0; }
.detail-grid > div { padding: 15px 8px; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.detail-grid dd { margin: 5px 0 0; font-weight: 650; }
.detail-grid .detail-total dd { color: var(--navy); font-size: 24px; font-weight: 900; }
.note-box { margin-top: 18px; padding: 15px; background: #f7fafb; border-left: 4px solid var(--blue); border-radius: 8px; }
.note-box p { margin: 6px 0 0; white-space: pre-wrap; }
.note-rejected { background: var(--danger-bg); border-left-color: var(--danger); }
.action-panel { position: sticky; top: 92px; }
.action-panel > p { color: var(--muted); }
.split-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-grid { display: grid; grid-template-columns: minmax(280px,.42fr) minmax(620px,1.58fr); gap: 20px; align-items: start; }

.empty-state { padding: 46px 20px; text-align: center; }
.empty-icon { font-size: 42px; }
.empty-state h3 { margin: 12px 0 6px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 30px 16px; }
.login-card { width: min(460px, 100%); padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 34px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand span { color: var(--muted); margin-top: 2px; }
.login-card h1 { margin: 0 0 8px; font-size: 29px; }
.login-card > p { color: var(--muted); margin: 0 0 24px; line-height: 1.55; }
.security-note { display: block; margin-top: 20px; color: #7a8993; text-align: center; }
.error-card { max-width: 620px; margin: 70px auto; padding: 45px; text-align: center; }
.error-code { display: block; font-size: 58px; font-weight: 950; color: var(--blue); }
.error-card p { color: var(--muted); margin-bottom: 24px; }

@media (max-width: 1120px) {
  .metric-grid.five { grid-template-columns: repeat(3, 1fr); }
  .review-layout { grid-template-columns: 1fr; }
  .document-panel { position: static; }
  .document-panel img, .document-panel iframe { min-height: 420px; max-height: 620px; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .topbar { align-items: flex-start; padding: 10px 16px; }
  .brand small { display: none; }
  .topnav { gap: 2px; overflow-x: auto; }
  .topnav > a, .link-button { padding: 9px 8px; font-size: 13px; white-space: nowrap; }
  .page-shell { width: min(100% - 22px, 1380px); padding-top: 24px; }
  .heading-actions { align-items: flex-start; flex-direction: column; }
  .metric-grid, .metric-grid.five { grid-template-columns: repeat(2, 1fr); }
  .four-cols, .two-cols { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .action-panel { position: static; }
  .filter-bar { align-items: stretch; }
  .filter-bar label { min-width: calc(50% - 8px); flex: 1; }
  .filter-bar .button { flex: 1 1 180px; }
  .panel { padding: 16px; }
}
@media (max-width: 640px) {
  body { background: var(--bg); }
  .topbar { min-height: 62px; }
  .brand strong { font-size: 13px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 9px; }
  .topnav > a:not(.nav-primary) { display: none; }
  .page-heading h1 { font-size: 30px; }
  .metric-grid, .metric-grid.five { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 95px; padding: 14px; }
  .metric-card strong { font-size: 21px; }
  .upload-card { padding: 16px; }
  .upload-zone { min-height: 240px; padding: 22px 14px; }
  .tip-grid { grid-template-columns: 1fr; }
  .document-panel img, .document-panel iframe { min-height: 360px; height: 440px; }
  .detail-grid { grid-template-columns: 1fr; }
  .split-buttons { grid-template-columns: 1fr; }
  .login-card { padding: 26px 22px; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr { margin: 0 0 12px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: white; }
  td { display: flex; justify-content: space-between; gap: 14px; padding: 8px 3px; border-bottom: 1px solid #edf1f3; text-align: right; }
  td:last-child { border-bottom: 0; }
  td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 750; text-align: left; }
  td strong, td small { text-align: right; }
  .amount { text-align: right; }
  .inline-form { min-width: 0; width: 100%; }
  .filter-bar label { min-width: 100%; }
}
