:root {
  --navy: #1b2a4a;
  --accent: #c99a3c;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #dcdfe4;
  --text: #202533;
  --muted: #6b7280;
  --danger: #b3261e;
  --good: #1e7a3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header.topbar a { color: #fff; text-decoration: none; }
header.topbar .brand { font-weight: 700; letter-spacing: .03em; }
header.topbar nav a { margin-left: 18px; font-size: 14px; opacity: .9; }
header.topbar nav a:hover { opacity: 1; text-decoration: underline; }
header.topbar .userinfo { font-size: 13px; opacity: .85; margin-left: 18px; margin-right: 12px; }

main { max-width: 1150px; margin: 24px auto; padding: 0 20px 60px; }

h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 17px; margin-top: 28px; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #eef0f4; font-weight: 600; position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sticky-col { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); }
th.sticky-col { background: #eef0f4; z-index: 3; }
td.sticky-col { background: var(--card); }
/* .card already sets overflow-x:auto, which per the CSS overflow spec forces its overflow-y to
   auto too — making the card itself (not the page) the sticky-positioning container. That's
   normally invisible since the card's height isn't bounded, so nothing ever scrolls inside it.
   Adding a max-height here is what actually turns it into a scrolling panel, so the `th` sticky
   rule above has something real to stick to — freezing the header while long tables scroll. */
.card-scroll { max-height: 70vh; overflow: auto; }
@media print {
  th { position: static; box-shadow: none; }
  .sticky-col { position: static; box-shadow: none; }
  .card-scroll { max-height: none; overflow: visible; }
}
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
form p { margin: 8px 0; }
.field-row { display: flex; gap: 10px; margin: 8px 0; }
.field-row > div { flex: 1; }
.field-row p { margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; width: 100%;
}
input[type=checkbox] { width: auto; }

.btn {
  display: inline-block; background: var(--navy); color: #fff; border: none;
  padding: 8px 16px; border-radius: 5px; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { opacity: .92; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.submitted { background: #dbeafe; color: #1e40af; }
.badge.billed { background: #dcfce7; color: #166534; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; }
.messages li.success { background: #dcfce7; color: #166534; }
.messages li.error { background: #fee2e2; color: #991b1b; }
.messages li.warning { background: #fef3c7; color: #92400e; }

.login-wrap { max-width: 360px; margin: 90px auto; }
.login-wrap .card { text-align: left; }

.errorlist { list-style: none; padding: 0; margin: 2px 0 4px; }
.errorlist li { color: var(--danger); font-size: 13px; font-weight: 600; }

@media print {
  header.topbar, .no-print { display: none !important; }
  main { max-width: 100%; margin: 0; padding: 0; }
}
