/* KasseKit — simpelt foreningsregnskab */
@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #18262b;
  --muted: #5b696e;
  --line: #d9dfdc;
  --line-strong: #b9c3bf;
  --brand: #1f4e5a;
  --brand-hover: #173d47;
  --brand-soft: #e3edef;
  --in: #24704a;
  --in-soft: #e4f1e9;
  --out: #a8352a;
  --out-soft: #f7e6e3;
  --flag: #946200;
  --flag-soft: #fbf0d6;
  --radius: 8px;
  --wrap: 1120px;
  --font: "Atkinson Next", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
:focus-visible { outline: 3px solid #4f9fb3; outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { background: var(--brand); color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; }
.brand span { font-weight: 400; opacity: .8; margin-left: 6px; }
.brand:hover { color: #fff; }
.topbar .org-switch { color: #d5e6ea; font-size: .9rem; }
.topbar .spacer { flex: 1; }
.topbar .user a, .topbar .user button { color: #d5e6ea; font-size: .9rem; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; text-decoration: underline; text-underline-offset: 2px; }
.topbar .user { display: flex; gap: 14px; align-items: center; }
.topbar .user form { margin: 0; }

.nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 12px 12px 10px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 700; }

main { padding: 28px 0 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 20px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3-1 { grid-template-columns: 2fr 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: 700 1rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--brand-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--brand-soft); color: var(--brand); }
.btn-danger { background: var(--surface); color: var(--out); border-color: #e2b8b2; }
.btn-danger:hover { background: var(--out-soft); color: var(--out); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }
.link-btn.danger { color: var(--out); }

/* Forms */
label { display: block; font-weight: 700; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.field .hint { font-size: .875rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: 400 1rem var(--font);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #b9d5dc; }
.is-invalid { border-color: var(--out) !important; }
.error { color: var(--out); font-size: .9rem; margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
.form-row { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(2, 1fr); } .form-row.three { grid-template-columns: repeat(3, 1fr); } }
.inline-form { display: inline; margin: 0; }

/* The posting form: direction toggle and big amount */
.direction { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; margin-bottom: 20px; }
.direction input { position: absolute; opacity: 0; pointer-events: none; }
.direction label { margin: 0; text-align: center; padding: 12px 6px; cursor: pointer; font-weight: 700; color: var(--muted); background: #fff; border-right: 1px solid var(--line); }
.direction label:last-of-type { border-right: 0; }
.direction input:focus-visible + label { outline: 3px solid #4f9fb3; outline-offset: -3px; }
.direction input[value=income]:checked + label { background: var(--in); color: #fff; }
.direction input[value=expense]:checked + label { background: var(--out); color: #fff; }
.direction input[value=transfer]:checked + label { background: var(--brand); color: #fff; }
.amount-field { position: relative; }
.amount-field input {
  font-size: 2.25rem; font-weight: 700; min-height: 68px; padding-right: 64px; letter-spacing: -.02em; text-align: right;
}
.amount-field .unit { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.25rem; }
form[data-type=income] .amount-field input { color: var(--in); }
form[data-type=expense] .amount-field input { color: var(--out); }
[data-show-for] { display: none; }
form[data-type=income] [data-show-for~=income],
form[data-type=expense] [data-show-for~=expense],
form[data-type=transfer] [data-show-for~=transfer] { display: block; }
.sticky-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 8px; }

/* Amounts */
.amt { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.amt.in { color: var(--in); }
.amt.out { color: var(--out); }
.amt.neutral { color: var(--muted); }

/* Account balances on the dashboard — the figures are the point */
.balances { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 24px; }
.balance { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--brand); border-radius: 10px; padding: 16px 18px; text-decoration: none; color: inherit; }
.balance:hover { border-color: var(--line-strong); border-left-color: var(--brand-hover); color: inherit; }
.balance .name { font-weight: 700; }
.balance .kind { color: var(--muted); font-size: .875rem; }
.balance .figure { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; line-height: 1.1; }
.balance .figure.neg { color: var(--out); }
.balance.total { border-left-color: var(--ink); background: var(--brand-soft); }

.result-line { display: flex; gap: 24px; flex-wrap: wrap; }
.result-line div { min-width: 140px; }
.result-line .lbl { color: var(--muted); font-size: .9rem; }
.result-line .val { font-size: 1.35rem; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .875rem; color: var(--muted); font-weight: 700; border-bottom-color: var(--line-strong); }
tbody tr:hover { background: #fafbfa; }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--line-strong); }
td.num, th.num { text-align: right; }
.row-link { color: var(--ink); text-decoration: none; font-weight: 500; }
.row-link:hover { text-decoration: underline; }
.voucher { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.meta { color: var(--muted); font-size: .875rem; }

/* Transaction list on small screens becomes stacked rows */
@media (max-width: 720px) {
  .tx-table thead { display: none; }
  .tx-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tx-table td { border: 0; padding: 0; }
  .tx-table td.c-date { grid-column: 1; color: var(--muted); font-size: .875rem; }
  .tx-table td.c-desc { grid-column: 1; }
  .tx-table td.c-amt { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 700; }
  .tx-table td.c-hide { display: none; }
  .tx-table tfoot tr { display: flex; justify-content: space-between; }
}

/* Tags */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.tag.in { background: var(--in-soft); color: var(--in); }
.tag.out { background: var(--out-soft); color: var(--out); }
.tag.flag { background: var(--flag-soft); color: var(--flag); }
.tag.grey { background: #eceeed; color: var(--muted); }

/* Flash and notices */
.flash { border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; border: 1px solid; }
.flash.ok { background: var(--in-soft); border-color: #b9dcc7; color: #17482f; }
.flash.err { background: var(--out-soft); border-color: #e7c1bb; color: #6e2119; }
.flash.warn { background: var(--flag-soft); border-color: #ecd79f; color: #5c3e00; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }

/* Filters */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: 16px; }
.filters label { font-size: .875rem; margin-bottom: 4px; }
.filters .field { margin: 0; }

/* Year switch */
.years { display: flex; gap: 6px; flex-wrap: wrap; }
.years a { padding: 6px 12px; border-radius: 999px; text-decoration: none; border: 1px solid var(--line-strong); color: var(--ink); background: #fff; font-weight: 700; font-size: .9rem; }
.years a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Attachments */
.attachments { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.attachment { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.attachment .thumb { aspect-ratio: 4 / 3; background: #eef1ef; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; overflow: hidden; }
.attachment .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment .info { padding: 8px 10px; font-size: .85rem; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.attachment .info a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 10px; padding: 16px; background: #fbfcfb; }
.dropzone input[type=file] { width: 100%; }

/* Key/value list */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* Auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand-big { font-size: 1.6rem; font-weight: 800; color: var(--brand); letter-spacing: -.03em; margin-bottom: 18px; display: block; text-decoration: none; }
.auth-card .panel { padding: 24px; }
.qr { background: #fff; padding: 12px; border: 1px solid var(--line); border-radius: 10px; display: inline-block; }
.qr svg { display: block; width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, monospace; background: #eef1ef; padding: 6px 10px; border-radius: 6px; word-break: break-all; font-size: .95rem; }
.codes { columns: 2; font-family: ui-monospace, Menlo, monospace; padding: 16px; background: #eef1ef; border-radius: 10px; list-style: none; margin: 0 0 16px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 8px; }

/* Floating new-posting button on phones */
.fab { display: none; }
@media (max-width: 720px) {
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; z-index: 20; box-shadow: 0 6px 18px rgba(24, 38, 43, .25); border-radius: 999px; min-height: 52px; padding: 0 22px; }
  .hide-mobile { display: none; }
  h1 { font-size: 1.5rem; }
  main { padding-top: 20px; }
}

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; list-style: none; padding: 0; }
.pagination a, .pagination span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 6px; text-decoration: none; background: #fff; }
.pagination .active span { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .disabled span { color: var(--line-strong); }

@media print {
  .topbar, .nav, .fab, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media (max-width: 720px) {
  .balances { grid-template-columns: 1fr 1fr; gap: 10px; }
  .balance { padding: 12px 12px 12px 14px; border-left-width: 5px; }
  .balance .kind { display: none; }
  .balance .figure { font-size: 1.3rem; margin-top: 4px; }
  .balance.total { grid-column: 1 / -1; }
}

/* MobilePay import review */
.bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.bulk select { width: auto; min-width: 180px; flex: 1 1 180px; min-height: 38px; padding: 6px 10px; }
.imp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong); }
.imp-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.imp-row.is-disabled { opacity: .6; }
.imp-check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); }
.imp-main { display: flex; flex-direction: column; gap: 2px; font-weight: 400; margin: 0; cursor: pointer; min-width: 0; }
.imp-msg { color: var(--muted); overflow-wrap: anywhere; }
.imp-amt { font-weight: 700; padding-top: 18px; }
.imp-fields { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.imp-fields select { width: auto; flex: 1 1 180px; min-height: 38px; padding: 6px 10px; font-size: .95rem; }
@media (min-width: 900px) {
  .imp-row { grid-template-columns: 32px minmax(220px, 1.2fr) 120px minmax(0, 2fr); }
  .imp-amt { padding-top: 0; order: 0; }
  .imp-fields { grid-column: auto; margin-top: 0; }
}
