:root {
  --navy-950: #0b1220;
  --navy-900: #0f1b30;
  --navy-800: #16273f;
  --navy-700: #1e3454;
  --navy-600: #29456e;
  --gold-500: #c99a3f;
  --gold-400: #dcb668;
  --paper: #f6f7f9;
  --paper-card: #ffffff;
  --ink-900: #101826;
  --ink-600: #4a5568;
  --ink-400: #8895a7;
  --line: #e4e8ee;
  --green: #1c7d4f;
  --green-bg: #e6f5ec;
  --red: #b3372c;
  --red-bg: #fbeae8;
  --amber: #93650a;
  --amber-bg: #fbf1dc;
  --orange: #a15117;
  --orange-bg: #fbecdd;
  --blue: #1f5fa8;
  --blue-bg: #e8f1fb;
  --gray-bg: #eef0f3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,38,.06), 0 1px 12px rgba(16,24,38,.05);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-700); text-decoration: none; }
h1, h2, h3, h4 { font-family: Georgia, 'Times New Roman', serif; color: var(--navy-950); margin: 0 0 4px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { line-height: 1.55; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 250px; flex-shrink: 0; background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #dbe3ee; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: var(--navy-950); font-weight: 700; display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-size: 0.95rem; }
.brand-logo-img { max-width: 40px; max-height: 40px; border-radius: 6px; object-fit: contain; background: #fff; padding: 2px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 0.92rem; }
.brand-text span { font-size: 0.68rem; color: #9fb0c7; text-transform: uppercase; letter-spacing: .06em; }
.nav-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .08em; color: #6f83a0; margin: 18px 10px 6px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; color: #c4d0e2; font-size: 0.88rem; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(220,182,104,.14); color: var(--gold-400); font-weight: 600; }
.nav-icon { width: 18px; display: inline-block; text-align: center; opacity: .8; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 0.85rem; color: #fff; }
.user-meta span { font-size: 0.72rem; color: #92a4bd; }
.link-button { background: none; border: none; cursor: pointer; text-align: left; width: 100%; font: inherit; }
.app-main { flex: 1; padding: 28px 36px 60px; max-width: 1200px; }

.auth-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top, var(--navy-800), var(--navy-950)); padding: 20px; }

/* ---------- Cards / layout primitives ---------- */
.card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header p { margin: 4px 0 0; color: var(--ink-600); font-size: 0.92rem; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }

.stat-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .stat-value { font-family: Georgia, serif; font-size: 1.7rem; color: var(--navy-950); }
.stat-card .stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-400); margin-top: 2px; }
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: var(--gray-bg, #f3f4f6); }
a.stat-card-link { display: block; text-decoration: none; transition: transform .12s ease, border-color .12s ease; cursor: pointer; }
a.stat-card-link:hover { transform: translateY(-2px); border-color: var(--gold-500); }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-600); margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.field-hint { font-size: 0.76rem; color: var(--ink-400); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cdd5e0; border-radius: 6px; font-size: 0.92rem; font-family: inherit; background: #fff; color: var(--ink-900);
}
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(41,69,110,.13); }
.form-row { display: flex; gap: 16px; }
.form-row > .field { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 0.8rem; font-weight: 700; color: var(--navy-800); padding: 0 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink-900); margin-bottom: 6px; }
.checkbox-row input { width: auto; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent; font-size: 0.86rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-gold { background: var(--gold-500); color: var(--navy-950); }
.btn-gold:hover { background: var(--gold-400); }
.btn-outline { background: #fff; border-color: #cdd5e0; color: var(--ink-900); }
.btn-outline:hover { border-color: var(--navy-600); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f0c9c4; }
.btn-danger:hover { background: #f6d9d5; }
.btn-success { background: var(--green-bg); color: var(--green); border-color: #bfe3cd; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-400); padding: 8px 12px; border-bottom: 2px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Pills / badges ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.pill-gray { background: var(--gray-bg); color: var(--ink-600); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-orange { background: var(--orange-bg); color: var(--orange); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-gold { background: #f6ecd9; color: #8a6a1f; }
.role-pill { background: var(--navy-800); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; }

/* ---------- Flash messages ---------- */
.flash { padding: 11px 16px; border-radius: 7px; margin-bottom: 18px; font-size: 0.88rem; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid #bfe3cd; }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid #f0c9c4; }

/* ---------- Login ---------- */
.auth-card { width: 380px; background: #fff; border-radius: 12px; padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .brand { border: none; padding-bottom: 22px; margin-bottom: 4px; justify-content: center; }
.auth-card .brand-text strong { color: var(--navy-950); font-size: 1rem; }
.auth-card .brand-text span { color: var(--ink-400); }
.auth-card h1 { text-align: center; font-size: 1.25rem; margin-bottom: 20px; }
.auth-hint { text-align: center; font-size: 0.76rem; color: var(--ink-400); margin-top: 18px; line-height: 1.5; }

/* ---------- Approval timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 0 0 20px; position: relative; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 8px; top: 20px; bottom: -2px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline-dot { width: 17px; height: 17px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.dot-approved { background: var(--green); }
.dot-rejected { background: var(--red); }
.dot-returned { background: var(--orange); }
.dot-pending { background: var(--ink-400); }
.dot-created { background: var(--navy-700); }
.dot-paid { background: var(--blue); }
.timeline-body strong { display: block; font-size: 0.88rem; }
.timeline-body .ts { font-size: 0.74rem; color: var(--ink-400); }
.timeline-body .comment { margin-top: 4px; font-size: 0.85rem; color: var(--ink-600); background: var(--gray-bg); padding: 8px 10px; border-radius: 6px; }
.sig-img-timeline { display: block; max-height: 34px; max-width: 140px; object-fit: contain; margin-top: 6px; }

/* ---------- Voucher print sheet ---------- */
.voucher-sheet { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 30px 34px; }
.voucher-sheet .v-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--navy-900); padding-bottom: 14px; margin-bottom: 18px; }
.voucher-sheet .v-head h1 { margin: 0; }
.voucher-sheet .v-num { font-family: Georgia, serif; font-size: 1.1rem; color: var(--gold-500); text-align: right; }
.v-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 30px; margin-bottom: 20px; }
.v-item .v-label { font-size: 0.7rem; text-transform: uppercase; color: var(--ink-400); letter-spacing: .04em; }
.v-item .v-value { font-size: 0.95rem; margin-top: 2px; }
.v-amount-box { background: var(--navy-950); color: #fff; border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; }
.v-amount-box .v-label { color: var(--gold-400); }
.v-amount-box .amt { font-family: Georgia, serif; font-size: 1.7rem; }
.v-amount-box .words { font-size: 0.85rem; color: #cdd8e8; margin-top: 4px; }
.sign-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 26px; }
.sign-box { border-top: 1px solid var(--ink-400); padding-top: 6px; font-size: 0.72rem; color: var(--ink-600); text-align: center; }
.sig-img-print { display: block; max-height: 36px; max-width: 90%; object-fit: contain; margin: 0 auto 4px; }
.sign-blank { height: 40px; }
.sign-box strong { display: block; font-size: 0.78rem; color: var(--ink-900); margin-bottom: 2px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .app-sidebar { display: none; }
  .app-main { padding: 0; max-width: none; }
  .voucher-sheet { border: none; box-shadow: none; }
}

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-400); }
.empty-state .icon { font-size: 2rem; margin-bottom: 10px; }
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters-bar .field { margin-bottom: 0; min-width: 160px; }
.small-note { font-size: 0.78rem; color: var(--ink-400); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
