/*
  Shared by the customer form and the admin panel. The look follows gardskapital.se (R62): DM Sans,
  GK's dark green and mint, 5px / 15px corners, soft shadows. Every colour is a token here, defined
  once; the pages use the tokens only. Fonts are self-hosted (public/fonts/, OFL): the CSP allows
  no third-party requests, and a page that holds a token must make none.

  Contrast (WCAG AA, checked 2026-10-13): text #001a17 on white 18.1:1; muted #4a5d58 on white 7.0:1
  and on --bg 6.6:1; white on --accent #002723 16.0:1 and on --accent-hover 6.0:1; --accent on mint
  14.2:1; pills ok 6.7:1, warn 6.9:1, bad 6.3:1; input border #7d918a on white 3.3:1 (non-text).
  --secondary #689e8d is 3.1:1 on white: decoration only, never text.
  Top bar: white on --bar-bg 16.0:1, --bar-sub on --bar-bg 9.5:1 (dark mode 10.2:1).
*/
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
/* One bold file serves 600 (buttons) and 700 (headings), as on gardskapital.se. */
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Bold.woff2") format("woff2"); font-weight: 600 700; font-style: normal; font-display: swap; }

:root {
  /* GK's palette (gardskapital.se, 2026-10-13) */
  --gk-primary: #002723; --gk-primary-hover: #306e5b; --gk-secondary: #689e8d; --gk-light: #d8f9ea; --gk-dark: #001a17;

  --bg: #F5F8F6; --surface: #FFFFFF; --fg: var(--gk-dark); --muted: #4A5D58; --line: #DDE6E2; --input-line: #7D918A;
  --accent: var(--gk-primary); --accent-hover: var(--gk-primary-hover); --accent-fg: #FFFFFF; --accent-soft: var(--gk-light);
  --focus: var(--gk-primary-hover);
  --ok: #1D5F43; --ok-soft: var(--gk-light); --bad: #A4161A; --bad-soft: #FDE2E1; --bad-solid: #B42318;
  --todo: #7A4300; --todo-soft: #FDECC8;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-body);
  --radius: 5px; --radius-lg: 15px;
  --shadow: 0 6px 40px -3px rgba(0, 0, 0, 0.08); --shadow-small: 0 3px 20px -1px rgba(0, 0, 0, 0.15);
  --space-1: 8px; --space-2: 15px; --space-3: 30px; --space-4: 60px;
  /* One readable column on the customer pages (~70 characters a line). */
  --content-width: 680px;
  /* The top bar is GK's dark green with white text, as on gardskapital.se; shared with the admin. */
  --bar-bg: var(--gk-primary); --bar-fg: #FFFFFF; --bar-sub: #9FD3BF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1715; --surface: #16201D; --fg: #E6EEEB; --muted: #9FB0AA; --line: #2A3833; --input-line: #5E726B;
    --accent: #8FD1B8; --accent-hover: #A9E2CC; --accent-fg: #00201C; --accent-soft: #1C332D; --focus: #8FD1B8;
    --ok: #7BD3A5; --ok-soft: #173027; --bad: #F2857B; --bad-soft: #3A1F1D; --bad-solid: #F2857B;
    --todo: #E6AA45; --todo-soft: #33281A;
    --shadow: 0 6px 40px -3px rgba(0, 0, 0, 0.5); --shadow-small: 0 3px 20px -1px rgba(0, 0, 0, 0.6);
    --bar-bg: #0A1F1C;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* No side padding on body: the top bar runs edge to edge; main and the bar's inner row keep the 16px gutter. */
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.6 var(--font-body); padding-block: 0 48px; }
h1, h2 { font-family: var(--font-display); font-weight: 700; text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; }
h3 { font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.topbar { background: var(--bar-bg); color: var(--bar-fg); }
.topbar-inner { max-width: var(--content-width); margin: 0 auto; padding: 18px 16px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.topbar :focus-visible { outline-color: var(--bar-sub); }
/* Customer pages show the Gårdskapital logo (public/logo.svg, from the site); the admin keeps a text wordmark. */
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.01em; color: var(--bar-fg); text-decoration: none; }
.brand:hover { color: var(--bar-fg); text-decoration: underline; }
.brand img { display: block; height: 40px; width: auto; }
.brand span, .brand-sub { color: var(--bar-sub); font-family: var(--font-body); font-weight: 400; font-size: .95rem; letter-spacing: 0; }
.brand span { margin-left: 8px; }

/* The +32px keeps the text column at --content-width inside the 16px gutters. */
main { max-width: calc(var(--content-width) + 32px); margin: 24px auto 0; padding-inline: 16px; }
.col { display: grid; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; min-width: 0; }

/* Customer pages (body.customer) follow gardskapital.se more closely than the dense admin: large regular-weight
   headings, more white space, 44px touch targets. The admin keeps its own sizes. */
.customer main { margin-top: var(--space-4); }
.customer .col { gap: var(--space-3); }
.customer .panel { padding: var(--space-3); gap: 18px; }
.customer h1 { font-weight: 400; font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.1; }
.customer h2 { font-weight: 400; font-size: 1.5rem; }
.customer .btn:not(.sm) { min-height: 44px; padding-inline: 20px; }
.customer .field { padding-top: 18px; gap: 8px; }
.customer .field input[type=text], .customer .field input[type=date], .customer .field textarea { padding: 10px 12px; }
/* Email code login (client/formEmailCode.ts): a narrow column, a large code input, the main button full width. */
.email-code { display: flex; flex-direction: column; gap: var(--space-2); max-width: 420px; }
.email-code #code-sent:empty, .email-code #code-message:empty { display: none; }
.email-code form { display: flex; flex-direction: column; gap: var(--space-2); }
.email-code .field { padding-top: 0; }
/* The "hidden" attribute must win over the display set on .field and .code-resend. */
.email-code [hidden] { display: none; }
.customer .field input.code-input { font-size: 1.5rem; letter-spacing: .35em; text-align: center; padding: 12px; font-variant-numeric: tabular-nums; }
.btn.block { width: 100%; }
.code-resend { margin: 0; text-align: center; }
.link-btn { border: 0; background: none; padding: 4px 2px; font: inherit; font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover:not(:disabled) { color: var(--accent-hover); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: not-allowed; }
@media (max-width: 520px) {
  .customer main { margin-top: var(--space-3); }
  .customer .panel { padding: 20px; }
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }

/* Buttons: primary dark green, ghost = outline, danger = red. Hover, pressed and focus each look different. */
.btn { border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-fg); padding: 10px 18px; border-radius: var(--radius); font-weight: 600; line-height: 1.3;
  transition: background-color .12s, border-color .12s, color .12s, transform .05s; }
.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-disabled="true"] { opacity: .45; cursor: progress; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn.sm { padding: 4px 12px; font-size: .875rem; }

.field { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.field:first-of-type { border-top: 0; padding-top: 0; }
.q { font-weight: 600; }
.field input[type=text], .field input[type=date], .field textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--input-line); border-radius: var(--radius); background: var(--surface); color: var(--fg); }
.field-error { color: var(--bad); font-size: .875rem; font-weight: 600; }
.field-error:empty { display: none; }
/* A possible typo: shown, never blocking (amber, with the word "Kontrollera" in the text). */
.field-warn { color: var(--todo); font-size: .875rem; font-weight: 600; margin: 4px 0 0; }
.field-warn:empty { display: none; }
.field.invalid input[type=text]:not([readonly]), .field.invalid textarea, .field.invalid .choice label { border-color: var(--bad); }
.confirm { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.confirm input { margin-top: 4px; accent-color: var(--accent); width: 18px; height: 18px; }
.field input[readonly] { background: var(--bg); color: var(--muted); }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice label { display: flex; gap: 6px; align-items: center; border: 1px solid var(--input-line); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; }
.choice label:hover { background: var(--accent-soft); }
.choice input { accent-color: var(--accent); }
details summary { cursor: pointer; color: var(--accent); }
details p { margin-top: 6px; }
.plist { display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
/* Grid items default to their content width; without this the two inputs overflow a 360px screen. */
.prow input { min-width: 0; }
@media (max-width: 520px) { .prow { grid-template-columns: 1fr; } }
.error { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius); padding: 10px 12px; }
/* Status: green = done or received, red = something is wrong. Colour plus icon, so it reads without colour too. */
.status { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius-lg); padding: 14px 16px; }
.status p { margin-top: 2px; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--surface); }
.status.ok .status-icon { background: var(--ok); }
.status.bad .status-icon { background: var(--bad); }
a.btn { display: inline-block; text-decoration: none; }
.footer { margin-top: 32px; text-align: right; }
.footer a { color: var(--muted); }
.status.todo { background: var(--todo-soft); color: var(--todo); }
.status.todo .status-icon { background: var(--todo); }
body.customer .topbar-inner { align-items: center; }
