@font-face { font-family: "Schibsted Grotesk"; font-weight: 400; font-display: swap; src: url("/static/fonts/schibsted-400.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-weight: 500; font-display: swap; src: url("/static/fonts/schibsted-500.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-weight: 700; font-display: swap; src: url("/static/fonts/schibsted-700.woff2") format("woff2"); }

:root {
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #10211f;
  --muted: #5b6965;
  --rule: #d5dcd9;
  --rule-strong: #b7c2be;
  --signal: #2546d8;
  --signal-ink: #ffffff;
  --due: #8a5a00;
  --due-bg: #fff3d6;
  --overdue: #a3261b;
  --overdue-bg: #fde6e3;
  --ok-bg: #e3f1ea;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(1rem, 3vw, 2rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 0.9375rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, dl, dd, ul { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
h2 { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }
a { color: var(--signal); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 0.8125rem; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding: 0.75rem var(--gutter);
  background: var(--ink);
  color: #e9eeec;
}
.brand { color: inherit; text-decoration: none; font-weight: 700; letter-spacing: -0.02em; font-size: 1.0625rem; }
.brand span { font-weight: 400; color: #9fb0ab; }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #cdd7d4; text-decoration: none; padding: 0.375rem 0.75rem; border-radius: 6px; }
.nav a:hover { color: #fff; background: #1e3330; }
.nav a[aria-current="page"] { color: #fff; background: #2a4440; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 0.4em; margin-left: 0.15rem; border-radius: 999px; background: #f2c14e; color: var(--ink); font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.5; }
.logout .link-button { color: #cdd7d4; }
.topbar :focus-visible { outline-color: #fff; }

/* Page */
.page { max-width: 72rem; margin: 0 auto; padding: 2rem var(--gutter) 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.lead { color: var(--muted); max-width: 62ch; margin-top: 0.35rem; }
.crumb { margin-bottom: 0.75rem; font-size: 0.875rem; }
.crumb a { text-decoration: none; }
.section { margin-top: 2.5rem; }
.section > h2, .section-head { margin-bottom: 0.75rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.flash { background: var(--ok-bg); border-left: 4px solid #2f7d5b; padding: 0.625rem 0.875rem; margin-bottom: 1rem; border-radius: 4px; }
.errors { background: var(--overdue-bg); border-left: 4px solid var(--overdue); padding: 0.625rem 0.875rem; margin-bottom: 1rem; border-radius: 4px; }
.errors p + p { margin-top: 0.25rem; }
.notice { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--due-bg); padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.empty { padding: 2rem 0; color: var(--muted); }
.summary { margin-bottom: 1rem; font-weight: 500; }
.tag { display: inline-block; font-size: 0.75rem; padding: 0 0.4rem; border-radius: 4px; background: var(--paper); border: 1px solid var(--rule); color: var(--muted); }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 0.9375rem/1 var(--font);
  padding: 0.6875rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--signal);
  background: var(--signal);
  color: var(--signal-ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { background: #1d39b5; border-color: #1d39b5; text-decoration: none; }
.button.secondary { background: var(--surface); color: var(--signal); border-color: var(--rule-strong); }
.button.secondary:hover { border-color: var(--signal); background: #f4f6ff; }
.button.small { font-size: 0.8125rem; padding: 0.4375rem 0.75rem; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--signal); cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em; }
.link-button.danger { color: var(--overdue); }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tabs a { padding: 0.4375rem 0.75rem; border-radius: 6px; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.tabs a:hover { border-color: var(--rule); }
.tabs a[aria-current="page"] { background: var(--surface); border-color: var(--rule-strong); font-weight: 500; }
.count { color: var(--muted); font-size: 0.8125rem; }
.search { display: flex; gap: 0.5rem; flex: 1; max-width: 28rem; min-width: min(100%, 18rem); }
.search input { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 0.8125rem; color: var(--muted); padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.table td { padding: 0.75rem 0.875rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8faf9; }
.table tfoot td { border-top: 1px solid var(--rule-strong); border-bottom: 0; font-weight: 500; padding: 0.75rem 0.875rem; }
.table.compact td { padding: 0.5625rem 0.875rem; }
.num { text-align: right !important; white-space: nowrap; }
.row-link { font-weight: 500; color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--signal); text-decoration: underline; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { display: inline-block; vertical-align: middle; margin-left: 0.75rem; }
.due, .overdue { display: inline-block; padding: 0 0.375rem; border-radius: 4px; }
.due { background: var(--due-bg); color: var(--due); }
.overdue { background: var(--overdue-bg); color: var(--overdue); font-weight: 500; }
.types input { width: 100%; }
.types .price-input { max-width: 9rem; }

/* Client facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.facts > div { background: var(--surface); padding: 0.875rem 1rem; }
.facts dt { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.25rem; }
.facts dd { overflow-wrap: anywhere; }
.notes { margin-top: 1rem; white-space: pre-line; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 0.875rem 1rem; }
.stopped { margin-top: 1rem; }
.stopped summary { cursor: pointer; color: var(--muted); }
.plain { list-style: none; padding: 0.5rem 0 0; }
.plain li { padding: 0.25rem 0; }

/* Due list */
.due-group { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 1rem; }
.due-group .table-wrap { border: 0; border-top: 1px solid var(--rule); border-radius: 0 0 8px 8px; }
.due-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.875rem; }
.due-head h2 a { color: var(--ink); text-decoration: none; }
.due-head h2 a:hover { color: var(--signal); text-decoration: underline; }
.due-total { display: flex; align-items: center; gap: 1rem; font-weight: 500; }

/* Forms */
.form fieldset { border: 0; padding: 0; margin: 0 0 1.75rem; display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.form legend { font-weight: 500; font-size: 1.0625rem; margin-bottom: 0.75rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; grid-column: span 2; }
.field.wide { grid-column: span 4; }
.field.narrow { grid-column: span 1; min-width: 7rem; }
.field.check { flex-direction: row; align-items: center; gap: 0.5rem; grid-column: span 2; align-self: end; padding-bottom: 0.6rem; }
.field label { font-size: 0.875rem; font-weight: 500; }
.hint { font-size: 0.8125rem; color: var(--muted); }
.inline-form { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 1.25rem; }
.inline-form .field { grid-column: span 2; }
.inline-form .field.wide { grid-column: span 4; }
.inline-form .field.narrow { grid-column: span 2; }
.narrow-form { max-width: 28rem; display: grid; gap: 1rem; }
.actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 1.25rem; }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 0.5625rem 0.6875rem;
  min-width: 0;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--signal); }
input:focus, select:focus, textarea:focus { border-color: var(--signal); }
textarea { resize: vertical; }
.danger-zone { display: flex; gap: 2rem; flex-wrap: wrap; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: 0.875rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 22rem); display: grid; gap: 0.75rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 2rem; }
.login-card h1 { font-size: 1.375rem; margin-bottom: 0.75rem; }
.login-card h1 span { font-weight: 400; color: var(--muted); }
.login-card label { font-weight: 500; font-size: 0.875rem; }
.login-card .button { margin-top: 0.5rem; }
.error { color: var(--overdue); font-size: 0.875rem; }

@media (max-width: 48rem) {
  .form fieldset, .inline-form { grid-template-columns: 1fr; }
  .field, .field.wide, .field.narrow, .field.check,
  .inline-form .field, .inline-form .field.wide, .inline-form .field.narrow { grid-column: 1 / -1; }
  .table th, .table td { padding-left: 0.625rem; padding-right: 0.625rem; }
  .page { padding-top: 1.25rem; }
}

/* Same column grid for every client group on the due list. */
.due-group .table { table-layout: fixed; min-width: 40rem; }
.due-group td:nth-child(1) { width: 30%; overflow-wrap: anywhere; }
.due-group td:nth-child(2) { width: 24%; }
.due-group td:nth-child(3) { width: 20%; }
.due-group td:nth-child(4) { width: 11%; }
.due-group td:nth-child(5) { width: 15%; }

@media (max-width: 48rem) {
  .topbar { gap: 0.5rem 1rem; padding-top: 0.625rem; padding-bottom: 0.375rem; }
  .logout { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 0.25rem; }
  .nav a { white-space: nowrap; }

  .due-group .table, .due-group tbody { display: block; min-width: 0; }
  .due-group tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name amount" "type action" "date action";
    gap: 0.125rem 0.75rem;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--rule);
  }
  .due-group tbody tr:last-child { border-bottom: 0; }
  .due-group td { display: block; width: auto !important; padding: 0 !important; border: 0 !important; }
  .due-group td:nth-child(1) { grid-area: name; }
  .due-group td:nth-child(2) { grid-area: type; color: var(--muted); }
  .due-group td:nth-child(3) { grid-area: date; }
  .due-group td:nth-child(4) { grid-area: amount; }
  .due-group td:nth-child(5) { grid-area: action; align-self: center; }
  .due-group .row-actions > * { margin-left: 0; }
}
