:root {
  --navy: #013e5d;
  --cyan: #12c8de;
  --gold: #e2b327;
  --ink: #16181a;
  --paper: #f6f7f8;
  --card: #ffffff;
  --line: #e3e6e8;
  --muted: #6b7378;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --display: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--serif); color: var(--ink); background: var(--paper); font-size: 16px; line-height: 1.55; }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--display); font-weight: 500; color: var(--navy); }
h1 { font-size: 30px; margin: 24px 0 8px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 18px; margin: 0 0 4px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }
.wrap.narrow { max-width: 640px; }
.lede { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.opt { color: var(--muted); font-weight: normal; font-size: 13px; }

/* Top bar */
.topbar { background: var(--navy); }
.topbar .bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.brand { color: #fff; text-decoration: none; font-family: var(--display); font-size: 20px; letter-spacing: 0.5px; }
.brand span { color: var(--cyan); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: #cfe3ec; text-decoration: none; font-size: 15px; padding-bottom: 2px; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; border-bottom: 2px solid var(--gold); }
.topbar .who { color: var(--cyan); font-size: 14px; }
.topbar.team { border-bottom: 3px solid var(--gold); }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card.empty { text-align: center; padding: 40px; }
.entity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.entity-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card.entity .meta { margin: 4px 0; color: var(--muted); font-size: 14px; }
.card.entity .actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.card.entity.add { border-style: dashed; background: transparent; }
.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }

/* Buttons & forms */
.btn { display: inline-block; padding: 10px 20px; border-radius: 5px; border: 1px solid transparent; font-family: var(--serif); font-size: 15px; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: #02537c; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn.ghost:hover { background: #eef4f7; }
.btn.danger { background: #fff; color: #a33; border-color: #c88; }
.btn.block { display: block; width: 100%; margin-top: 16px; }
button.link { background: none; border: none; color: var(--navy); cursor: pointer; font-family: var(--serif); font-size: 14px; text-decoration: underline; padding: 0; }
button.link.danger { color: #a33; }
form.inline { display: inline; }

label { display: block; margin: 14px 0 4px; font-weight: 600; font-size: 14px; color: var(--navy); }
label.check { font-weight: normal; display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; font-family: var(--serif); font-size: 15px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.align-end { display: flex; align-items: flex-end; }
.form-section { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Line items */
.line-item { border: 1px solid var(--line); border-radius: 6px; padding: 0 14px 14px; margin-top: 14px; background: #fcfdfd; }
.line-item-head { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.line-no { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.line-items-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.btn.small-btn { padding: 7px 14px; font-size: 14px; }
.line-total { font-size: 15px; color: var(--navy); }
.line-total strong { font-size: 18px; }
.table.items { margin-top: 6px; }
.table.items tfoot td { padding: 8px 10px; border-top: 2px solid var(--line); font-size: 14px; }

.summary-box { background: #f2f9fb; border-left: 3px solid var(--cyan); padding: 12px 16px; border-radius: 0 5px 5px 0; margin-top: 18px; font-size: 14px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); background: #fbfcfc; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.table .ellipsis { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table.compact td { padding: 6px 10px; font-size: 14px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f2f7fa; }

/* Status & badges */
.status { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 13px; white-space: nowrap; }
.status.new { background: #fdf3d7; color: #8a6d0a; }
.status.in_review { background: #e0f6fa; color: #0a6b7a; }
.status.issued { background: #e3f2e6; color: #1e6b2e; }
.status.cancelled { background: #eee; color: #777; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; white-space: nowrap; }
.badge.approved { background: var(--navy); color: var(--gold); }
.badge.pending { background: #fdf3d7; color: #8a6d0a; }
.badge.kind.new_entity { background: var(--gold); color: #3d2f00; }
.badge.kind.repeat { background: #e0f6fa; color: #0a6b7a; }
.badge.kind.existing { background: #eef1f2; color: #555; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 16px 0; border-bottom: 2px solid var(--line); }
.tab { padding: 8px 16px; text-decoration: none; color: var(--muted); border-radius: 6px 6px 0 0; }
.tab.active { background: var(--navy); color: #fff; }
.tab .count { background: rgba(255,255,255,0.25); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.tab:not(.active) .count { background: var(--line); color: var(--muted); }

/* Auth pages */
.auth-page { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 8px; padding: 40px; max-width: 420px; width: 100%; }
.auth-brand { font-family: var(--display); font-size: 22px; color: var(--navy); margin-bottom: 20px; }
.auth-brand span { color: var(--cyan); }
.auth-card h1 { margin-top: 0; }

/* Confirmation */
.card.confirm { text-align: center; padding: 48px 32px; margin-top: 40px; }
.checkmark { width: 56px; height: 56px; border-radius: 50%; background: var(--navy); color: var(--gold); font-size: 28px; line-height: 56px; margin: 0 auto 16px; }

/* Flash + errors */
.flash { padding: 12px 20px; text-align: center; font-size: 15px; }
.flash.ok { background: #e3f2e6; color: #1e6b2e; }
.flash.error { background: #fbe5e5; color: #8a1f1f; }
.flash.static { border-radius: 6px; margin: 12px 0; text-align: left; }
.errors { background: #fbe5e5; color: #8a1f1f; border-radius: 6px; padding: 4px 16px; margin: 12px 0; }
.errors p { margin: 8px 0; }

/* Misc */
.back { display: inline-block; margin-top: 18px; font-size: 14px; text-decoration: none; }
dl { margin: 0; }
dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-top: 12px; }
dd { margin: 2px 0 0; }
dd.highlight { background: #fdf8e7; border-left: 3px solid var(--gold); padding: 8px 12px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: none; }
.timeline .when { color: var(--muted); font-size: 13px; margin-right: 6px; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; margin-top: 40px; }
