/* Blanketten efterliknar överförmyndarens A4-formulär: svart på vitt, raka rutor. */
:root {
    --ink: #111;
    --line: #222;
    --soft: #6b7780;
    --fill: #f4f7f9;
    --brand: #007596;
    --brand-dark: #005f7a;
    --ok: #1f7a36;
    --ok-bg: #dcf3e2;
    --off: #b42318;
    --off-bg: #fde4e1;
}
* { box-sizing: border-box; }
html { background: #dfe6ea; }
body {
    margin: 0;
    font: 13px/1.35 Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: #dfe6ea;
}
input, textarea, button { font: inherit; color: inherit; }

/* ---------- Verktygsrad (bara på skärm) ---------- */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding: 10px 20px;
    background: linear-gradient(100deg, #2f8aa5 0%, #005f7a 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.toolbar .logo img { display: block; width: 170px; }
.totals { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; flex: 1 1 auto; justify-content: center; }
.totals > div { display: flex; align-items: baseline; gap: 6px; padding: 5px 10px; background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
.totals dt { font-weight: bold; font-size: 0.85em; opacity: 0.85; }
.totals dd { margin: 0; font-weight: bold; font-variant-numeric: tabular-nums; min-width: 6ch; text-align: right; }
.totals .balance { background: rgba(255, 255, 255, 0.22); }
.totals .balance.ok { background: var(--ok-bg); color: var(--ok); }
.totals .balance.off { background: var(--off-bg); color: var(--off); }
.actions { display: flex; gap: 8px; }
.actions button {
    padding: 7px 14px;
    border: 0;
    border-radius: 8px;
    background: white;
    color: var(--brand-dark);
    font-weight: bold;
    cursor: pointer;
}
.actions button.secondary { background: transparent; color: white; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6); }
.actions button:hover { filter: brightness(0.95); }

/* ---------- A4-sidor ---------- */
.sheet {
    position: relative;
    width: 210mm;
    max-width: calc(100% - 24px);
    min-height: 297mm;
    margin: 24px auto;
    padding: 14mm 16mm 16mm;
    background: white;
    box-shadow: 0 2px 12px rgba(16, 42, 52, 0.18);
}
.sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 6px;
    margin-bottom: 14px;
    border-bottom: 3px solid var(--brand);
    font-size: 0.85em;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--soft);
}
.sheet-head .brand { font-weight: bold; color: var(--ink); }
h1 { font-size: 24px; margin: 18px 0 12px; }
h2 { font-size: 15px; margin: 18px 0 4px; }
h2.page-title { font-size: 20px; margin: 22px 0 6px; }
h3 { font-size: 14px; margin: 16px 0 4px; }
.sub { margin: -4px 0 8px; font-size: 0.85em; font-weight: bold; }
.small { font-size: 0.82em; }
p { margin: 6px 0; }
em { color: #333; }

/* Diarieruta uppe till höger */
.diarium { float: right; width: auto; margin: 0 0 8px 16px; border-collapse: collapse; font-size: 0.8em; }
.diarium th, .diarium td { border: 1.5px solid var(--off); height: 22px; padding: 0 8px; }
.diarium th { color: var(--soft); font-weight: normal; text-align: right; width: 100px; }
.diarium td { width: 100px; }

/* ---------- Tabeller och rutor ---------- */
table { width: 100%; border-collapse: collapse; }
.boxes td, .grid td, .grid th, .office td { border: 1px solid var(--line); }
.boxes td { width: 50%; padding: 0; vertical-align: top; }
.cell { display: block; padding: 3px 6px 2px; min-height: 40px; cursor: text; }
.cell span { display: block; font-size: 0.72em; color: #333; }
.cell input { display: block; width: 100%; border: 0; padding: 2px 0; background: transparent; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--fill); }

.kind { clear: both; margin: 6px 0 10px; }
.kind th, .kind td { padding: 4px 6px; text-align: left; vertical-align: middle; }
.kind th { font-family: Georgia, 'Times New Roman', serif; font-size: 17px; font-weight: normal; width: 120px; }
.kind .check { width: 44px; }
.kind .check input { width: 30px; height: 30px; margin: 0; }
.kind .cell { border-bottom: 1px solid var(--line); min-height: 36px; }
.kind .deadline { width: 34%; font-size: 0.95em; }

.roles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; margin: 8px 0; }
.roles label { display: inline-flex; align-items: center; gap: 8px; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); }
.ink { border-left: 2px solid var(--ink); padding-left: 8px; }

.signature { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 40px 0 6px; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; }
.signature .line { display: block; width: 100%; height: 28px; border: 0; border-bottom: 1px dashed #777; background: transparent; margin-bottom: 4px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; }

.office-heading { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 18px; }
.office td { height: 40px; padding: 3px 6px; vertical-align: top; font-size: 0.85em; }
.office .box { width: 34px; }
.office .tall { height: 70px; }
.label { font-size: 0.85em; }

.grid th, .grid td { padding: 0 5px; height: 21px; text-align: left; vertical-align: middle; }
.grid thead th { font-size: 0.8em; font-weight: bold; background: white; }
.grid thead th small { font-weight: normal; font-size: 0.85em; color: #333; }
.grid td input { width: 100%; height: 20px; border: 0; padding: 0; background: transparent; }
.grid .num { width: 110px; text-align: right; }
.grid .num input { text-align: right; font-variant-numeric: tabular-nums; }
.grid .note { width: 110px; }
.grid .att { width: 76px; }
.grid .shares { width: 64px; }
.grid .lock { width: 92px; white-space: nowrap; font-size: 0.95em; }
.grid .lock label { display: inline-flex; align-items: center; gap: 3px; }
.grid .lock input { width: 13px; height: 13px; }
.grid tfoot th, .grid .sum th { border: 0; text-align: right; font-weight: bold; padding-right: 8px; height: 26px; }
.grid .total { border: 2px solid var(--line); font-variant-numeric: tabular-nums; }
.grid input.invalid { color: var(--off); background: var(--off-bg); }
.grand { margin-top: 14px; }
.grand .sum th { border: 2px solid var(--line); text-align: left; padding-left: 8px; }
.check-row { margin-top: 10px; }
.check-row th, .check-row td { border: 2px solid var(--line); height: 26px; font-weight: bold; }
.check-row th { text-align: right; padding: 0 12px; width: 120px; }
.check-row th:last-child { text-align: left; }
.check-row .equals { width: 30px; text-align: center; font-size: 1.2em; }
.balance-note { margin-top: 8px; font-weight: bold; }

.other-info { display: block; width: 100%; min-height: 115mm; padding: 8px; border: 1px solid var(--line); resize: vertical; }
.continue { text-align: right; font-size: 0.8em; font-weight: bold; margin-top: 2px; }

button.add {
    margin: 6px 6px 0 0;
    padding: 4px 10px;
    border: 1px dashed var(--brand);
    border-radius: 6px;
    background: white;
    color: var(--brand-dark);
    font-size: 0.85em;
    cursor: pointer;
}
button.add:hover { background: var(--fill); }
.row-tools { display: flex; flex-wrap: wrap; }

/* ---------- Smala skärmar ---------- */
@media (max-width: 820px) {
    .sheet { width: auto; min-height: 0; padding: 16px; }
    .diarium { float: none; margin: 0 0 8px; }
    .kind tr { display: grid; grid-template-columns: 44px 1fr; }
    .kind td, .kind th { width: auto !important; }
    .kind td:nth-child(n+3) { grid-column: 2; }
    .signature { grid-template-columns: 1fr; gap: 12px; }
    .grid { display: block; overflow-x: auto; }
    .toolbar .logo img { width: 130px; }
    .toolbar { position: static; }
}

/* ---------- Utskrift ---------- */
@page { size: A4; margin: 10mm 12mm; }
@media print {
    html, body { background: white; font-size: 11.5px; }
    .noprint { display: none !important; }
    .sheet { width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; box-shadow: none; break-after: page; }
    .sheet:last-child { break-after: auto; }
    input, textarea { background: transparent !important; outline: none !important; }
    input::placeholder { color: transparent; }
    input[type="date"]::-webkit-calendar-picker-indicator { display: none; }
    .grid input.invalid { color: inherit; }
    .other-info { resize: none; }
}
