/* ── Variables ───────────────────────────────────────────────── */
:root {
  --blue:        #005aab;
  --blue-dark:   #004080;
  --blue-light:  #e8f0fb;
  --green:       #1a7f4b;
  --green-light: #e6f4ec;
  --red:         #c0392b;
  --red-light:   #fdf0ef;
  --amber:       #b45309;
  --amber-light: #fef3c7;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-500:    #6b7280;
  --gray-700:    #374151;
  --gray-900:    #111827;
  --white:       #ffffff;
  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: .9375rem;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  background: var(--blue);
  color: var(--white);
  padding: .75rem 0;
  box-shadow: var(--shadow);
}
.navbar-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
}
.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; opacity: .9; }
.navbar-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin-left: auto;
}
.navbar-links a {
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  font-weight: 500;
}
.navbar-links a:hover { color: var(--white); text-decoration: none; }

/* ── Main content ────────────────────────────────────────────── */
main.container { padding-top: 2rem; padding-bottom: 3rem; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 1rem;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: .75rem;
}
.hero-sub {
  color: var(--gray-500);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { opacity: .88; }
.btn-sm { padding: .3rem .75rem; font-size: .8125rem; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────── */
.form { max-width: 760px; }
.form-row { margin-bottom: 1.25rem; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
}
label .req { color: var(--red); margin-left: .2rem; }
.hint {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: .25rem;
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="password"],
select,
textarea {
  display: block;
  width: 100%;
  padding: .45rem .75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,90,171,.15);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}
textarea { min-height: 80px; resize: vertical; }
.field-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: .3rem;
}
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--red);
}

/* ── Flash messages ──────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .875rem;
}
.flash-success { background: var(--green-light); color: var(--green); border-left: 4px solid var(--green); }
.flash-error   { background: var(--red-light);   color: var(--red);   border-left: 4px solid var(--red); }
.flash-warning { background: var(--amber-light);  color: var(--amber); border-left: 4px solid var(--amber); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
th {
  text-align: left;
  padding: .6rem .875rem;
  background: var(--gray-100);
  border-bottom: 2px solid var(--gray-200);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  white-space: nowrap;
}
td {
  padding: .6rem .875rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.tr-total td { font-weight: 700; background: var(--gray-100); border-top: 2px solid var(--gray-200); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-gray   { background: var(--gray-200);    color: var(--gray-700); }
.badge-blue   { background: var(--blue-light);  color: var(--blue-dark); }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-amber  { background: var(--amber-light); color: var(--amber); }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.page-header h2 { font-size: 1.15rem; font-weight: 700; }

/* ── Filter bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.filter-bar label { margin-bottom: .2rem; }
.filter-group { display: flex; flex-direction: column; min-width: 150px; }

/* ── Rollup table specifics ──────────────────────────────────── */
.rollup-table th:first-child,
.rollup-table td:first-child {
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
  border-right: 1px solid var(--gray-200);
  min-width: 180px;
}

/* ── Utility ─────────────────────────────────────────────────── */
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-sm  { font-size: .875rem; }
.text-xs  { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .navbar-links { display: none; }
}
