/* Redovisning för idioter — see docs/stilguide.md for the reasoning.
   Ink on paper, one warm grey, Inter for reading and Space Mono for
   pointing. Colour only ever means status. */

/* ── Fonts (self-hosted, latin subset, OFL) ───────────────────────── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/spacemono-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/spacemono-700-latin.woff2") format("woff2");
}

/* ── Reset & tokens ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #222;
  --paper: #fff;
  --stone: #ebece8;
  --dim: #666;
  --line: rgba(0, 0, 0, 0.15);
  --line-soft: rgba(0, 0, 0, 0.08);
  --hover: #f3f3f0;
  --ok: #cbe9cb;
  --warn: #f1e5bf;
  --bad: #e9cbcb;
  --bad-ink: #8a2a2a;

  --radius: 8px;
  --radius-lg: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-xs: 11px;
  --text-sm: 13px;
  --text: 14px;
  --text-md: 16px;
  --text-lg: 22px;
  --text-xl: 26px;
  --control: 38px;
  --control-sm: 30px;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

::selection { background: var(--ink); color: #fff; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  transition: text-decoration-color 120ms ease;
}
a:hover { text-decoration-color: var(--ink); }

strong { font-weight: 600; }
em { font-style: italic; }

/* The pointing voice: labels, headers, nav, badges, buttons. */
.label,
.navbar-menu a,
.navbar-menu .btn-link,
.table th,
.form-group label,
.receipt-form label,
.narrow-form label,
.inline-form-label,
.report-period label,
.stat-label,
.eyebrow,
.table-kv td:first-child,
input[type="file"].form-control::file-selector-button {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}

/* Identifiers: voucher refs, account numbers, hashes. */
.mono, code {
  font-family: var(--mono);
  font-size: 12px;
}

code {
  background: var(--stone);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
main.container { padding: 2rem 1rem 4rem; }

/* ── Header ───────────────────────────────────────────────────────── */
.navbar {
  background: var(--stone);
  min-height: 56px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.navbar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

/* The brain-and-mushroom mark (components/logo.templ): strokes in the
   current text colour, sized by whoever places it. */
.logo { width: 26px; height: 26px; flex: none; }

.navbar-menu {
  list-style: none;
  padding-left: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  min-width: 0;
}

.navbar-menu a,
.navbar-menu .btn-link {
  text-decoration: none;
  white-space: nowrap;
  line-height: 56px;
  transition: color 120ms ease;
}
.navbar-menu a:hover,
.navbar-menu .btn-link:hover { color: var(--ink); text-decoration: none; }
.navbar-menu a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--ink);
}
.navbar-menu .navbar-me { margin-left: 0.75rem; }

@media (max-width: 960px) {
  .navbar { flex-wrap: wrap; gap: 0 1rem; padding: 0 1rem; }
  .navbar-brand { line-height: 48px; }
  .navbar-menu {
    flex: 1 0 100%;
    margin-left: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line-soft);
  }
  .navbar-menu::-webkit-scrollbar { display: none; }
  .navbar-menu a, .navbar-menu .btn-link { line-height: 44px; }
}

/* ── Headings & sections ──────────────────────────────────────────── */
.page-title {
  font-size: var(--text-xl);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 1.25rem;
}
.page-title + .text-muted { margin-top: -0.5rem; max-width: 64ch; }

.section { margin-bottom: 2.5rem; }
.section h2 {
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.section h3 {
  font-size: var(--text);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }
.section > p, main > p { max-width: 72ch; }
ul { padding-left: 1.2rem; }

/* ── Stats ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 120ms ease, background 120ms ease;
}
a.stat-card { text-decoration: none; }
a.stat-card:hover { border-color: var(--ink); }
.stat-value {
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-value-text { font-size: var(--text-md); letter-spacing: -0.01em; padding-top: 0.35rem; }
.stat-label { order: -1; }

/* ── Alerts & flash ───────────────────────────────────────────────── */
.alert, .flash {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  max-width: 72ch;
}
.alert-success, .flash-success { background: var(--ok); }
.alert-warning, .flash-warning { background: var(--warn); }
.alert-danger,  .flash-danger  { background: var(--bad); }
.alert strong { font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control);
  padding: 0 1.1rem;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--ink); color: #fff; text-decoration: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-danger { color: var(--bad-ink); border-color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-ink); border-color: var(--bad-ink); color: #fff; }
.btn-sm { height: var(--control-sm); padding: 0 0.75rem; font-size: var(--text-xs); }
.btn-block { display: flex; width: 100%; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ── Tables ───────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: 0.75rem;
}
.table th, .table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
.table th {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
  vertical-align: bottom;
  font-weight: 400;
}
.table tbody tr:hover td { background: var(--hover); }
.table td a { text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table-sm th, .table-sm td { padding: 0.4rem 0.5rem; }
.table .text-right { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td:first-child, .table th:first-child { padding-left: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; }

/* On a phone a ledger is wider than the screen. The table scrolls sideways
   inside the page rather than the page scrolling sideways under the nav.
   Key/value tables and the reconciliation blocks are two columns of prose
   and keep wrapping instead. */
@media (max-width: 800px) {
  .table:not(.table-kv) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .check .table { display: table; white-space: normal; }
}

/* A two-column key/value table (verifikation, konto) reads better with the
   key in the pointing voice. */
.table-kv td:first-child { width: 11rem; padding-top: 0.55rem; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15em 0.5em 0.1em;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
  color: var(--ink);
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-success   { background: var(--ok); }
.badge-warning   { background: var(--warn); }
.badge-danger    { background: var(--bad); }
.badge-primary   { background: var(--ink); color: #fff; }
.badge-secondary { background: var(--stone); }
a.badge:hover { text-decoration: underline; }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; }
.form-group .text-muted { font-size: var(--text-sm); margin-top: 0.4rem; max-width: 48ch; }

.form-control {
  width: 100%;
  max-width: 420px;
  height: var(--control);
  padding: 0 0.8rem;
  font: inherit;
  font-size: var(--text);
  color: var(--ink);
  background: var(--stone);
  border: none;
  border-radius: var(--radius);
  outline: none;
  transition: box-shadow 120ms ease;
}
.form-control:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.form-control:hover:not(:focus) { box-shadow: inset 0 0 0 1px var(--line); }
.form-control::placeholder { color: #999; }
.form-control[readonly] { color: var(--dim); }
select.form-control {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23222' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
textarea.form-control { height: auto; min-height: 6rem; padding: 0.6rem 0.8rem; line-height: 1.5; resize: vertical; }
input[type="file"].form-control { padding: 0; line-height: var(--control); }
input[type="file"].form-control::file-selector-button {
  height: 100%;
  margin-right: 0.8rem;
  padding: 0 0.9rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  cursor: pointer;
}
input[type="date"].form-control { max-width: 12rem; }

.narrow-form { max-width: 420px; }
.narrow-form label { display: block; margin-bottom: 0.4rem; }
.narrow-form .form-control { max-width: 100%; }

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.inline-form-label { min-width: 7.5rem; }
.inline-form .form-control { flex: 1 1 12rem; max-width: 24rem; }
.inline-form .btn { flex: 0 0 auto; }

/* ── Login ────────────────────────────────────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--stone);
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.login-card .eyebrow { display: block; margin-bottom: 1.5rem; }
.login-card h1 {
  font-size: var(--text-lg);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
}
.login-card .text-muted { font-size: var(--text-sm); margin-bottom: 1rem; }
.login-card .form-control { max-width: 100%; }
.login-card .btn-block { margin-top: 0.5rem; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: var(--text-sm);
}
.pagination a { text-decoration: none; }
.pagination a:hover { text-decoration: underline; }
.pagination-info { color: var(--dim); }

/* ── Utilities ────────────────────────────────────────────────────── */
.text-muted, .muted { color: var(--dim); }
.text-warning { color: var(--bad-ink); }
.text-right { text-align: right; }
.ml-2 { margin-left: 0.4rem; }

/* ── Kvitton ──────────────────────────────────────────────────────── */
/* The original next to the form it filled in. Reading a receipt off a
   screen is the whole verification step, so the image gets real space. */
.receipt-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin-bottom: 2.5rem;
}
@media (max-width: 800px) {
  .receipt-split { grid-template-columns: 1fr; }
}
.receipt-preview { position: sticky; top: 1rem; }
.receipt-preview .text-muted { font-size: var(--text-sm); margin-top: 0.6rem; }
.receipt-image {
  width: 100%;
  height: auto;
  min-height: 320px;
  max-height: 75vh;
  object-fit: contain;
  background: var(--stone);
  border-radius: var(--radius-lg);
  display: block;
}
.receipt-form label { display: block; margin-bottom: 0.4rem; }
.receipt-form .form-control { max-width: 100%; }
.receipt-form form.section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

/* ── Avstämning ───────────────────────────────────────────────────── */
/* One block per check. Green or red at a glance; the amount that is off
   is the only number that matters when it is red. */
.check {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  max-width: 40rem;
}
.check-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.check-head strong { font-weight: 500; }
.check .table { margin-bottom: 0.6rem; }
.check .table td:first-child { color: var(--dim); }
.check .table tbody tr:hover td { background: transparent; }
.check .text-muted { font-size: var(--text-sm); }

/* ── Rapporter ────────────────────────────────────────────────────── */
/* Fortnox's ÅRL layout: headings in caps, accounts indented, sums bold.
   Numbers right-aligned in a tabular font so the öre line up. */
.report-period label { min-width: 0; }
.report-period + .text-muted { font-size: var(--text-sm); }
.report-meta { font-size: var(--text-sm); }
.report tbody tr:hover td { background: transparent; }
.report td { border-bottom: none; }
.report-heading td { font-family: var(--mono); font-size: var(--text-xs); letter-spacing: 0.04em; text-transform: uppercase; padding-top: 1.4rem; }
.report-subheading td { font-weight: 600; padding-top: 0.8rem; }
.report-group td { font-weight: 500; color: var(--dim); padding-top: 0.6rem; }
.report-account td:first-child { padding-left: 1.5rem; }
.report-account td a { font-family: var(--mono); font-size: 12px; }
.report-group-total td { font-weight: 600; border-top: 1px solid var(--line-soft); }
.report-subtotal td { font-weight: 600; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.report-total td { font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; border-top: 2px solid var(--ink); padding-top: 0.6rem; }
.report-list { list-style: none; padding-left: 0; }
.report-list li { margin-bottom: 0.75rem; max-width: 72ch; }
.report-list a { text-decoration: none; }
.report-list a:hover { text-decoration: underline; }

@media print {
  .navbar, .report-period, .report-period + p, .alert, a[href="#"] { display: none !important; }
  body { background: #fff; font-size: 11px; }
  main.container { padding: 0; max-width: none; }
  a { color: inherit; text-decoration: none; }
}

/* ── Årsredovisning ───────────────────────────────────────────────── */
/* The document itself: A4-ish pages, serif, numbers in tabular figures.
   It is a document, not a screen, so it does not follow the app's type.
   Everything else on the page (nav, form, warnings) is .no-print. */
.ar-doc { max-width: 720px; margin: 2rem auto; font-family: Georgia, "Times New Roman", serif; font-size: 13px; color: #000; }
.ar-page { background: #fff; border: 1px solid var(--line); border-radius: 2px; padding: 2.5rem 3rem; margin-bottom: 1.5rem; min-height: 60vh; }
.ar-cover { text-align: center; padding-top: 30vh; }
.ar-cover h1 { font-size: 2rem; font-weight: 400; margin-bottom: 0.5rem; }
.ar-cover h2 { font-size: 1.4rem; font-weight: 400; margin: 1rem 0 0.25rem; }
.ar-head { display: flex; justify-content: space-between; font-size: 0.85em; margin-bottom: 1.5rem; }
.ar-page h2 { font-size: 1.3rem; font-weight: 700; margin: 1rem 0 0.75rem; }
.ar-page h3 { font-size: 1.05rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
.ar-page h4 { font-size: 0.95rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
.ar-page p { margin-bottom: 0.6rem; line-height: 1.45; max-width: none; }
.ar-prose { white-space: pre-line; }
.ar-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; font-size: inherit; }
.ar-table th { text-align: left; font-weight: 400; font-size: 0.85em; padding: 0.25rem 0.4rem; border-bottom: 1px solid #000; vertical-align: bottom; }
.ar-table td { padding: 0.2rem 0.4rem; vertical-align: top; }
.ar-table td.text-right, .ar-table th.text-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ar-table .ar-post { padding-left: 1.2rem; }
.ar-table .ar-note { width: 2.5rem; text-align: center; }
.ar-heading td { font-weight: 700; padding-top: 0.8rem; }
.ar-sum td { font-weight: 700; border-top: 1px solid #000; }
.ar-result td { font-weight: 700; border-top: 1px solid #000; border-bottom: 3px double #000; }
.ar-disposition { max-width: 420px; margin-left: auto; }
.ar-signature { margin-top: 3rem; line-height: 1.8; }
.ar-form summary { cursor: pointer; padding: 0.5rem 0; }
.ar-form summary strong { font-weight: 500; }
.ar-form form { margin-top: 1rem; }
.ar-form textarea.form-control { width: 100%; }

@media print {
  .no-print, .navbar { display: none !important; }
  .ar-doc { max-width: none; margin: 0; font-size: 11pt; }
  .ar-page { border: none; padding: 0; margin: 0; min-height: 0; page-break-after: always; break-after: page; }
  .ar-page:last-child { page-break-after: auto; }
  .ar-cover { padding-top: 35vh; }
}
