:root {
  --bg: #11150d;
  --panel: #1d2218;
  --panel-2: #252b20;
  --line: #4d4a2b;
  --text: #eee8d7;
  --muted: #afa78e;
  --gold: #b99b3d;
  --olive: #556b2f;
  --danger: #b4533d;
  --ok: #6f8c3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
body { display: flex; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 264px; padding: 18px 14px;
  background: linear-gradient(180deg, #171c13, #0e110b);
  border-right: 1px solid rgba(185,155,61,.35);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 8px; }
.brand-crest { width: 56px; height: 72px; object-fit: cover; object-position: top; border: 1px solid rgba(185,155,61,.7); background: #0d120b; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
.brand small, .userbox small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
nav { display: grid; gap: 6px; }
nav a, .logout {
  min-height: 42px; display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  color: var(--muted); border: 1px solid transparent; border-radius: 6px;
}
nav a.active, nav a:hover, .logout:hover { background: rgba(185,155,61,.1); border-color: rgba(185,155,61,.25); color: var(--text); }
svg { width: 18px; height: 18px; }
.logout { margin-top: auto; }

.main { margin-left: 264px; width: calc(100% - 264px); min-height: 100vh; padding: 22px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.top-crest { width: 52px; height: 66px; object-fit: cover; object-position: top; border: 1px solid rgba(185,155,61,.55); background: #0d120b; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: 0; font-size: 12px; font-weight: 700; }
h1 { margin: 4px 0 0; font-size: 30px; }
h2 { font-size: 18px; margin: 0 0 14px; }
.userbox { text-align: right; border: 1px solid var(--line); padding: 10px 12px; border-radius: 6px; background: rgba(255,255,255,.03); }

.hero { position: relative; height: min(34vw, 360px); min-height: 230px; overflow: hidden; border: 1px solid rgba(185,155,61,.34); border-radius: 8px; margin-bottom: 16px; background: #10140d; }
.hero img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,14,8,.84), rgba(10,14,8,.18) 48%, rgba(10,14,8,.25)); pointer-events: none; }
.hero-crest { position: absolute; z-index: 1; left: 22px; bottom: 18px; display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: rgba(12,16,10,.78); border: 1px solid rgba(185,155,61,.45); border-radius: 8px; backdrop-filter: blur(3px); }
.hero-crest img { width: 92px; height: 118px; object-fit: cover; object-position: top; border: 1px solid rgba(185,155,61,.75); }
.hero-crest strong { display: block; color: var(--gold); font-size: 22px; }
.hero-crest span { color: var(--text); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cards article, .panel {
  background: linear-gradient(180deg, rgba(37,43,32,.96), rgba(24,29,20,.96));
  border: 1px solid rgba(185,155,61,.26);
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(0,0,0,.2);
}
.cards article { padding: 16px; }
.cards span { color: var(--muted); font-size: 13px; display: block; }
.cards strong { color: var(--gold); font-size: 28px; margin-top: 6px; display: block; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { padding: 16px; overflow: hidden; }
.muted { color: var(--muted); }
.num { text-align: right; color: var(--gold); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border: 1px solid rgba(185,155,61,.18); text-align: left; vertical-align: top; }
th { color: #f4df8a; font-size: 12px; text-transform: uppercase; letter-spacing: 0; background: linear-gradient(180deg, #30361f, #1a1f14); position: sticky; top: 0; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.025); }
tbody tr:hover { background: rgba(185,155,61,.08); }
.table-wrap { overflow: auto; max-height: 70vh; padding: 0; }
.metric-table th, .metric-table td { border-color: rgba(185,155,61,.22); }
.bar { display: block; width: 100%; height: 12px; background: rgba(0,0,0,.34); border: 1px solid rgba(185,155,61,.28); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--olive), var(--gold)); }

.toolbar { display: flex; gap: 8px; margin: 0 0 12px; }
.report-filter { display: grid; grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(160px, .8fr)) auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-cards { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
.print-report-head { display: none; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 9px 10px; color: var(--text); background: #12170f;
  border: 1px solid rgba(185,155,61,.3); border-radius: 6px;
}
textarea { min-height: 84px; resize: vertical; }
label { color: var(--muted); font-size: 13px; display: grid; gap: 6px; }
.btn { border: 1px solid rgba(185,155,61,.45); background: #222719; color: var(--text); border-radius: 6px; padding: 10px 14px; cursor: pointer; min-height: 40px; }
.btn.primary { background: linear-gradient(180deg, #7d6b2c, #5a4a1d); border-color: var(--gold); color: #fff7d8; font-weight: 700; }
.btn.danger { background: linear-gradient(180deg, #8b2f25, #5d1b16); border-color: rgba(255,120,100,.55); color: #fff; font-weight: 700; }
.btn.mini { min-height: 30px; padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form, .approval-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.approval-form input { min-height: 30px; border: 1px solid rgba(185,155,61,.28); border-radius: 6px; background: #10140d; color: var(--text); padding: 6px 8px; }
.checkline { display: flex; align-items: center; gap: 8px; min-height: 40px; color: var(--text); }
.checkline input { width: auto; min-height: auto; }
.form-panel { margin-bottom: 12px; }
summary { cursor: pointer; color: var(--gold); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.wide { grid-column: 1 / -1; }
.alert, .notice { padding: 12px; border-radius: 6px; margin-bottom: 12px; }
.alert { background: rgba(180,83,61,.18); border: 1px solid rgba(180,83,61,.45); }
.notice { background: rgba(111,140,61,.18); border: 1px solid rgba(111,140,61,.45); }
.profile { display: grid; grid-template-columns: 260px 1fr; gap: 18px; margin-bottom: 16px; }
.profile-photo { aspect-ratio: 4 / 3; background: #0f130b; border: 1px solid rgba(185,155,61,.26); border-radius: 8px; overflow: hidden; }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-body h2 { color: var(--gold); font-size: 24px; }
.profile dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.profile dt { color: var(--muted); font-size: 12px; }
.profile dd { margin: 3px 0 0; min-height: 24px; }
.app-footer {
  margin-top: 22px;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid rgba(185,155,61,.18);
}

.login-page { display: block; min-height: 100vh; background: #0f130b; }
.login-hero { min-height: 100vh; position: relative; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.login-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .62; }
.login-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,13,8,.9), rgba(10,13,8,.4)); }
.login-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 24px; display: grid; gap: 14px; background: rgba(18,23,15,.88); border: 1px solid rgba(185,155,61,.48); border-radius: 8px; }
.login-crest { width: 112px; height: 142px; object-fit: cover; object-position: top; border: 1px solid rgba(185,155,61,.7); justify-self: center; background: #0d120b; }
.login-card h1 { margin: 0; color: var(--gold); }
.login-card p { margin: 0 0 6px; color: var(--muted); }
.login-footer {
  position: absolute;
  z-index: 1;
  left: 16px;
  right: 16px;
  bottom: 12px;
  color: rgba(238,232,215,.76);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 980px) {
  body { display: block; }
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid rgba(185,155,61,.35); }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .brand-crest { width: 46px; height: 58px; }
  .top-crest { display: none; }
  .main { margin-left: 0; width: 100%; padding: 16px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .form-grid, .report-filter, .report-cards, .profile, .profile dl { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .hero-crest { left: 12px; right: 12px; bottom: 12px; }
  .hero-crest img { width: 68px; height: 88px; }
  .login-footer { position: relative; bottom: auto; margin-top: 14px; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .sidebar, .topbar, .report-actions, .hero, summary, .form-panel, .report-filter, .app-footer { display: none !important; }
  .main { margin: 0; width: 100%; padding: 0; }
  body { background: #fff; color: #111; display: block; }
  .print-report-head { display: block; margin-bottom: 8mm; padding-bottom: 4mm; border-bottom: 2px solid #556b2f; }
  .print-report-head span { color: #556b2f; font-weight: 800; font-size: 11pt; }
  .print-report-head h2 { margin: 2mm 0 1mm; color: #11150d; font-size: 18pt; }
  .print-report-head p { margin: 0; color: #555; font-size: 9pt; }
  .cards.report-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; margin-bottom: 6mm; page-break-inside: avoid; }
  .panel, .cards article { box-shadow: none; border: 1px solid #b99b3d; background: #fff; color: #111; }
  .cards article { padding: 4mm; }
  .cards span { color: #556b2f; font-size: 9pt; font-weight: 700; }
  .cards strong { color: #11150d; font-size: 16pt; }
  .table-wrap { max-height: none; overflow: visible; border: 0; }
  table { border-collapse: collapse; width: 100%; font-size: 8pt; page-break-inside: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  th { color: #11150d; background: #d8cfaa !important; border: 1px solid #777; position: static; font-size: 7.5pt; }
  td { border: 1px solid #aaa; color: #111; }
  tbody tr:nth-child(even) { background: #f3f1e8 !important; }
}
