:root {
  color-scheme: light;
  --navy: #102a3d;
  --navy-2: #173e52;
  --teal: #087f79;
  --gold: #d59a32;
  --ink: #172534;
  --muted: #6b7784;
  --line: #dce4e8;
  --wash: #f3f6f7;
  --paper: #fff;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--wash); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { min-height: 40px; padding: 9px 15px; border: 0; border-radius: 8px; background: var(--navy); color: white; font-weight: 750; cursor: pointer; }
button:hover { background: var(--navy-2); }
button:disabled { cursor: wait; opacity: .6; }
.secondary { border: 1px solid var(--line); background: white; color: var(--ink); }
.danger { background: var(--danger); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--teal); font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.form-error { min-height: 18px; margin: 9px 0 0; color: var(--danger); font-size: 13px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0b2637, #17616a); }
.login-card { width: min(420px, 100%); padding: 38px; border-radius: 18px; background: white; box-shadow: 0 24px 80px #00131f66; }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 26px; border-radius: 14px; background: var(--teal); color: white; font-weight: 900; }
.brand-mark.small { width: 40px; height: 40px; margin: 0; border-radius: 10px; }
.login-card h1 { margin: 0; font-size: 32px; letter-spacing: -.03em; }
label { display: grid; gap: 7px; color: #445260; font-size: 13px; font-weight: 700; }
.login-card label { margin-top: 18px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #087f7920; }
.login-card button { width: 100%; margin-top: 20px; }

.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 248px; display: flex; flex-direction: column; padding: 22px 16px; background: var(--navy); color: white; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid #ffffff20; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #b8c8d0; }
.sidebar nav { display: grid; gap: 4px; padding: 20px 0; }
.sidebar nav button { width: 100%; justify-content: start; background: transparent; color: #d9e5ea; text-align: left; }
.sidebar nav button.active, .sidebar nav button:hover { background: #ffffff14; color: white; }
.sidebar-user { display: grid; gap: 4px; margin-top: auto; padding: 18px 8px 0; border-top: 1px solid #ffffff20; }
.sidebar-user small { color: #b8c8d0; text-transform: capitalize; }
.link-button { min-height: 30px; padding: 4px 0; background: transparent; color: #d9e5ea; text-align: left; font-size: 12px; }
.content { margin-left: 248px; padding: 34px; }
.mobile-header { display: none; }
.page { display: none; width: min(1440px, 100%); margin: 0 auto; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 22px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.045em; }
.page-head p:last-child { margin-bottom: 0; }
.filters { display: flex; gap: 8px; }
.panel { margin-bottom: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 7px 24px #1936480a; }
.panel h2 { margin: 0 0 18px; font-size: 20px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.metric { padding: 20px; border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: 14px; background: white; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin: 10px 0 3px; font-size: clamp(22px, 3vw, 32px); }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bars { display: grid; gap: 14px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 13px; }
.bar-track { height: 8px; overflow: hidden; border-radius: 20px; background: #e8eef0; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--teal); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; background: #f6f8f9; color: var(--muted); text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.description { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #e6f4f1; color: #07685f; font-size: 11px; font-weight: 800; }
.pill.Submitted { background: #fff3d6; color: #815900; }
.pill.Returned, .pill.Rejected { background: #feeceb; color: #a3231a; }
.pill.Paid { background: #e8eefb; color: #284c90; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 32px; padding: 6px 9px; font-size: 12px; }
.empty { padding: 36px; color: var(--muted); text-align: center; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; }
.user-form { display: grid; grid-template-columns: repeat(5, 1fr) auto; align-items: end; gap: 12px; }
.user-form .form-error { grid-column: 1 / -1; }
.toast { position: fixed; top: 20px; right: 24px; z-index: 60; max-width: 420px; padding: 13px 18px; border-radius: 9px; background: var(--navy); color: white; box-shadow: 0 12px 35px #0004; }

dialog { width: min(620px, calc(100% - 28px)); max-height: 88vh; overflow: auto; padding: 24px; border: 0; border-radius: 14px; box-shadow: 0 28px 90px #00131f77; }
dialog::backdrop { background: #0a1b27aa; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.icon-button { min-width: 36px; min-height: 36px; padding: 0; border-radius: 50%; background: #edf1f3; color: var(--ink); font-size: 22px; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.details div { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.details dd { margin: 4px 0 0; overflow-wrap: anywhere; }
dialog form { display: grid; gap: 15px; }
dialog code { display: block; margin: 14px 0; padding: 14px; border-radius: 8px; background: #edf3f4; font-size: 17px; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .user-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 18px 14px 30px; }
  .mobile-header { display: flex; align-items: center; gap: 12px; margin: -4px 0 24px; }
  .mobile-header button { min-width: 42px; padding: 7px; }
  .page-head { align-items: start; flex-direction: column; }
  .report-grid, .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .details { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .metrics, .user-form { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
  .filters { width: 100%; }
  .filters select { min-width: 0; }
}
