/* Paymetricly — hand-written CSS, no build step, no framework.
   Light and dark are both supported via prefers-color-scheme.

   The table and pill rules come across as the pages that need them land. */

:root {
  --bg:          #f6f7f9;
  --surface:     #ffffff;
  --surface-alt: #f0f2f5;
  --border:      #dfe3e8;
  --text:        #1a1d21;
  --text-muted:  #646d7a;
  --accent:      #2563eb;
  --accent-soft: #e8effe;
  --good:        #0f7b45;
  --good-soft:   #e3f4ea;
  --warn:        #9a6400;
  --warn-soft:   #fdf3e0;
  --bad:         #b32020;
  --bad-soft:    #fceceb;
  --radius:      8px;
  --shadow:      0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #14161a;
    --surface:     #1c1f24;
    --surface-alt: #23272e;
    --border:      #2f343c;
    --text:        #e8eaed;
    --text-muted:  #9aa3af;
    --accent:      #5b8def;
    --accent-soft: #1e2a41;
    --good:        #4ac07f;
    --good-soft:   #16301f;
    --warn:        #e0a53a;
    --warn-soft:   #322612;
    --bad:         #f0736b;
    --bad-soft:    #35191a;
    --shadow:      0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ----------------------------------------------------------------- forms -- */

label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 5px; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], input[type=search], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Django's password validators hand back their help text as a <ul>, so the hint
   has to survive holding a list rather than a single line. */
.hint ul { margin: 4px 0 0; padding-left: 18px; }

.field-error { font-size: 12px; color: var(--bad); margin-top: 4px; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn-block { width: 100%; text-align: center; }

/* -------------------------------------------------------------- messages -- */

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok  { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.flash.err { background: var(--bad-soft);  color: var(--bad);  border-color: var(--bad); }

/* ------------------------------------------------------------- auth card -- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
/* The password forms carry validator help text under each field; 340px turns
   that into a wall of wrapped lines. */
.login-card.wide { max-width: 440px; }

.login-card h1 { margin-bottom: 4px; }
.login-card .intro { margin: 0 0 18px; }

/* Secondary links under the submit button — "Forgot your password?" and friends. */
.card-foot { margin: 16px 0 0; text-align: center; }

/* ---------------------------------------------------------------- topbar -- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 650; letter-spacing: -.02em; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: 18px; flex: 1; }
.nav-links a { color: var(--text-muted); font-size: 14px; font-weight: 550; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-logout { margin: 0; }

/* A button that reads as a link: sign-out has to be a POST. */
.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
}
.linklike:hover { color: var(--text); }

/* ------------------------------------------------------------------ page -- */

.page { max-width: 1080px; margin: 0 auto; padding: 28px 20px 48px; }
.page-head { margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; }

/* --------------------------------------------------------------- filters -- */

/* One row above everything it scopes: presets first, custom range after. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.segmented a {
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 550;
}
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Only shown to holders of payments.view_test_payments. */
.test-toggle { margin: -6px 0 18px; color: var(--text-muted); }
.test-toggle .inline-form, .test-bar .inline-form { display: inline; }
.test-toggle .linklike, .test-bar .linklike { color: var(--accent); font-size: inherit; }

/* While test payments are shown: on every page, under the top bar. */
.test-bar {
  padding: 8px 20px;
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid var(--border);
}

.custom-range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.custom-range input[type=date] { width: auto; min-width: 0; flex: 1 1 130px; padding: 6px 8px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------- stats -- */

.kpis {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .kpis { grid-template-columns: 1fr; }
}

.stat, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 16px 18px; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Big standalone numbers keep proportional figures — tabular-nums gives every
   digit the width of a 0, which looks loose at this size. Tabular is for columns
   that must line up (.num below). */
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.hero-value { font-size: 48px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; }
.stat-note { margin: 6px 0 0; font-size: 13px; }

/* Direction is carried by the arrow and the word, not the colour alone. */
.delta { margin: 8px 0 0; font-size: 13px; font-weight: 550; }
.delta.up   { color: var(--good); }
.delta.down { color: var(--bad); }
.delta .muted { font-weight: 400; }

/* ----------------------------------------------------------------- cards -- */

.card { padding: 16px 18px; margin: 0 0 14px; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.card-head h2 { margin: 0; }
.card .card-foot { text-align: left; margin-top: 12px; }
.empty { margin: 8px 0; font-size: 14px; }

.columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 860px) { .columns { grid-template-columns: minmax(0, 1fr); } }

/* ----------------------------------------------------------------- table -- */

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
table.data tbody th { font-weight: 550; }
table.data tr:last-child > * { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Status is always written out in the pill; colour only reinforces it. */
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad  { background: var(--bad-soft);  color: var(--bad); }

/* ----------------------------------------------------------------- chart -- */

/* The SVG scales its text with its width, so below ~560px the labels would
   shrink past legibility. Hold a minimum width and scroll inside the card
   instead; the page itself never scrolls sideways. */
.chart-frame { overflow-x: auto; }
.chart { display: block; width: 100%; min-width: 560px; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .mark { fill: var(--accent); }
.chart .hit { fill: transparent; }

.chart .tip { visibility: hidden; pointer-events: none; }
.chart .tip-box { fill: var(--text); }
.chart .tip-value { fill: var(--surface); font-size: 13px; font-weight: 650; }
.chart .tip-label { fill: var(--surface); font-size: 11px; opacity: .8; }
.chart .tip-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; }

.chart .bar:hover .tip, .chart .bar:focus .tip { visibility: visible; }
.chart .bar:hover .mark, .chart .bar:focus .mark { filter: brightness(1.12); }
.chart .bar:focus { outline: none; }
.chart .bar:focus-visible .hit { stroke: var(--accent); stroke-width: 1.5; }

.table-view { margin-top: 10px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--text-muted); }
.table-view table { margin-top: 8px; max-width: 360px; }

/* ── Clients ─────────────────────────────────────────────────────────────── */

.search { display: flex; gap: 8px; align-items: center; }
.search input[type=search] { flex: 1 1 260px; max-width: 420px; }

.pager { display: flex; gap: 16px; justify-content: center; margin-top: 14px; }

/* Label-value pairs on a contract card, wrapping into columns. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px 20px;
  margin: 0;
}
.facts dt { font-size: 12px; color: var(--text-muted); }
.facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }

.notes { margin: 0; white-space: normal; }

