* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; background: var(--bg); color: var(--text); }
.theme-dark { --bg: #0a0a0a; --card: #151515; --text: #e6e6e6; --muted: #a3a3a3; --line: #2e2e2e; --field: #000; }
.theme-light { --bg: #f4f4f2; --card: #fff; --text: #1c1c1c; --muted: #5f5f5f; --line: #dcdcd8; --field: #fff; }
.embed { background: transparent; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; color: var(--brand); }
h3 { font-size: 1rem; margin-top: 20px; }
a { color: var(--brand); }
p { margin: 0 0 12px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }
.embed .wrap { padding: 0; }
.narrow-wrap { max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 20px; margin-bottom: 20px; }
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.narrow-left { max-width: 680px; }
.center { text-align: center; }
.small { font-size: 0.85rem; color: var(--muted); }
.strong-link { font-weight: 700; }
.hidden { display: none !important; }
.pre-line { white-space: pre-line; }
.hp-field { position: absolute; left: -9999px; }

label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 14px 0 4px; }
input, select, textarea { width: 100%; padding: 10px; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
input[type=color] { height: 44px; padding: 4px; }
input[type=checkbox], input[type=radio] { width: auto; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--text); font-size: 1rem; }
.check-row input { margin-top: 5px; }

button, .button-link, .button-inline { display: inline-block; padding: 11px 20px; font: inherit; font-weight: 600; color: var(--brand-text); background: var(--brand); border: 1px solid var(--brand); border-radius: 4px; cursor: pointer; text-decoration: none; }
form > button[type=submit] { margin-top: 16px; }
button:hover, .button-link:hover { filter: brightness(1.1); }
.button-link { background: transparent; color: var(--brand); }
.button-secondary { background: transparent; color: var(--text); border-color: var(--line); margin-top: 12px; }
.button-small { display: inline-block; padding: 5px 10px; font-size: 0.82rem; font-weight: 600; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 4px; text-decoration: none; margin: 0 !important; }
.button-danger { color: #e05a5a; border-color: #e05a5a; }
.link-button { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 400; cursor: pointer; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.inline-form { display: inline; }
.inline-row { display: flex; gap: 6px; align-items: center; }
.inline-row input { padding: 5px 8px; font-size: 0.85rem; min-width: 120px; }
.stack-form { display: flex; flex-direction: column; gap: 4px; }
.stack-form select, .stack-form input { padding: 4px; font-size: 0.8rem; }
.sticky-save { position: sticky; bottom: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.35); }

.alert { padding: 12px 14px; margin-bottom: 16px; border: 1px solid #3f7a4c; background: rgba(63,122,76,.18); border-radius: 4px; }
.alert-error { border-color: #a84444; background: rgba(168,68,68,.18); }
.demo-bar { background: var(--brand); color: var(--brand-text); text-align: center; padding: 6px 12px; font-size: 0.88rem; font-weight: 600; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-ok { color: #57ad6a; } .check-warn { color: #d39b3a; } .check-fail { color: #e05a5a; font-weight: 700; }

.topnav { background: var(--card); border-bottom: 1px solid var(--line); }
.topnav-inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.topnav-links { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.topnav-links a { color: var(--text); text-decoration: none; font-size: 0.92rem; }
.topnav-links a:hover { color: var(--brand); }
.topnav-brand { text-decoration: none; }
.logo { max-width: 320px; max-height: 110px; height: auto; }
.logo-small { max-height: 38px; max-width: 170px; display: block; }
.logo-text { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.logo-preview { background: #fff; padding: 10px; display: inline-block; border-radius: 4px; margin-bottom: 8px; }
.title-row, .public-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.title-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lang-switch a { margin-left: 8px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.85rem; }
.lang-switch a.active { color: var(--brand); }
.sub-nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 18px; font-size: 0.92rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filter-bar input { flex: 1 1 240px; width: auto; }
.filter-bar select { width: auto; }

.public-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.public-embed { grid-template-columns: 1fr; }
.public-foot { margin-top: 32px; display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; color: var(--muted); }
.contact-box > div { margin-bottom: 10px; }
.label-text { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.78rem; color: var(--muted); }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cell-wide { min-width: 200px; max-width: 320px; }
.actions { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.muted-row { opacity: .55; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; color: #fff; vertical-align: middle; }
.badge-new { background: #566072; } .badge-work { background: #a8701b; } .badge-ready { background: #2f7d44; } .badge-done { background: #444; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 20px; }
.info { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.info dt { font-size: 0.82rem; color: var(--muted); } .info dd { margin: 0; }
.notify-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.file-button { display: inline-block; padding: 10px 14px; border: 1px dashed var(--brand); border-radius: 4px; color: var(--brand); cursor: pointer; margin: 0 0 12px; }
.file-button input { display: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.thumb img, .doc-thumb { display: flex; align-items: center; justify-content: center; width: 100%; height: 110px; object-fit: cover; border-radius: 4px; cursor: pointer; }
.doc-thumb { background: var(--bg); color: var(--text); border: 1px solid var(--line); text-decoration: none; }
.thumb-actions { display: flex; gap: 4px; margin-top: 4px; }
.log-item { padding: 10px 0; border-top: 1px solid var(--line); }
.log-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; color: var(--muted); }
.check-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.check-item .check-row { margin: 0; }
.check-detail { padding: 8px 0 4px 26px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.radio-row label { display: flex; gap: 6px; margin: 0 0 6px; font-weight: 400; color: var(--text); }
.status-row, .protocol-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.protocol-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.code-box { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 10px; font-size: 0.82rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 56px 16px 16px; }
.lightbox-tools { position: fixed; top: 10px; right: 16px; display: flex; gap: 8px; z-index: 51; }
.lightbox-tools button { padding: 6px 12px; }
#lightbox-content img, #lightbox-content video { max-width: 100%; max-height: 85vh; }
#lightbox-content img.zoomable { max-height: none; }
#lightbox-content iframe { width: 90vw; height: 84vh; border: 0; background: #fff; }
.text-box { background: #fff; color: #000; padding: 20px; max-width: 800px; white-space: pre-wrap; }

/* Kvitto och faktura */
.print-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-bottom: 18px; }
.sheet { background: #fff; color: #000; max-width: 800px; margin: 0 auto; padding: 44px; border-radius: 4px; font-size: 14px; }
.sheet h1, .sheet h2, .sheet h3, .sheet h4, .sheet p { color: #000; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #000; padding-bottom: 14px; margin-bottom: 16px; }
.sheet-logo { max-width: 280px; max-height: 96px; display: block; margin-bottom: 6px; }
.sheet .logo-text { color: #000; font-size: 1.5rem; }
.sheet-contact { font-size: 12px; font-weight: 700; margin: 0; }
.sheet-meta { text-align: right; flex: none; }
.sheet-meta p { margin: 4px 0 0; }
.sheet-meta h1 { margin: 0 0 6px; font-size: 1.5rem; }
.sheet-id { display: inline-block; font-size: 18px; font-weight: 700; border: 2px solid #000; border-radius: 3px; padding: 4px 12px; }
.sheet-title { font-size: 19px; letter-spacing: 1px; text-transform: uppercase; border-bottom: 2px solid #000; padding-bottom: 5px; margin-bottom: 14px; }
.sheet-box { background: #f5f5f5; border: 1px solid #000; padding: 10px 14px; margin-bottom: 14px; }
.sheet-box p { margin: 2px 0; }
.sheet-code { font-size: 17px; letter-spacing: 1px; border-bottom: 2px solid #000; }
.sheet-grid { display: grid; gap: 14px; border-bottom: 1px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.sheet-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.sheet-grid.two { grid-template-columns: 1fr 1fr; }
.sheet h4 { font-size: 11px; text-transform: uppercase; margin: 0 0 3px; }
.sheet-grid p, .sheet-pay p { font-size: 15px; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.sheet-grid p.sheet-small, .sheet-small { font-size: 12px; font-weight: 400; }
.sheet-grid p.normal { font-weight: 400; }
.sheet-section { border-bottom: 1px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.sheet-section p { margin: 0; font-size: 14px; }
.sheet-pay { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 8px; }
.swish-block { display: flex; align-items: center; gap: 10px; text-align: right; font-size: 11px; }
.swish-block strong { font-size: 12px; }
.swish-block img { width: 85px; height: 85px; display: block; }
.sheet-notes { font-size: 12px; }
.sheet-notes p { margin: 0; }
.workshop-tag { margin-top: 18px; border-top: 2px dashed #000; padding-top: 10px; break-inside: avoid; page-break-inside: avoid; }
.tag-title { font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.tag-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid #000; border-radius: 4px; padding: 10px 14px; }
.tag-box h2 { font-size: 18px; text-transform: uppercase; margin: 0; overflow-wrap: anywhere; }
.tag-box p { margin: 3px 0 0; }
.tag-box img { width: 95px; height: 95px; flex: none; }
.edit-field { border: 1px dashed transparent; background: transparent; color: #000; padding: 3px; font-size: 14px; }
.edit-field:hover, .edit-field:focus { border-color: #999; background: #fffbe8; }
.edit-field.strong { font-weight: 700; }
.invoice .button-secondary { color: #000; border-color: #999; }
.edit-field.sheet .button-secondary, .print-page .sheet ~ .button-secondary { color: #000; border-color: #999; background: #fff; }
.invoice-items { table-layout: fixed; }
.invoice-items th:last-child { width: 26px; }
.item-desc { display: block; resize: none; overflow: hidden; font-family: inherit; line-height: 1.35; }
.num { text-align: right; } .edit-field.center { text-align: center; }
.invoice-parties { border: 0; margin: 12px 0 18px; }
.invoice-items th { color: #000; border-bottom: 2px solid #000; font-size: 12px; }
.invoice-items td { border-bottom: 1px solid #ccc; padding: 3px 4px; color: #000; }
.num { text-align: right; } .center { text-align: center; }
.invoice-items th:nth-child(2), .invoice-items th:nth-child(4) { width: 90px; }
.invoice-items th:nth-child(3) { width: 60px; }
.invoice-items th:nth-child(5) { width: 105px; }
.invoice-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 20px; }
.invoice-swish { flex-direction: column; text-align: center; }
.invoice-swish img { width: 110px; height: 110px; }
.totals { width: 300px; margin-left: auto; }
.totals td { border: 0; padding: 3px 4px; color: #000; }
.totals .grand td { border-top: 2px solid #000; font-weight: 700; font-size: 17px; }
.invoice-foot { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 28px; padding-top: 10px; border-top: 1px solid #000; font-size: 12px; }

@media (max-width: 900px) {
    .columns, .public-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .sheet { padding: 20px; }
    .sheet-grid.three, .sheet-grid.two, .invoice-foot { grid-template-columns: 1fr; }
}
@media print {
    @page { size: A4 portrait; margin: 0; }
    body { background: #fff !important; }
    .no-print, .alert { display: none !important; }
    .wrap { padding: 0; max-width: none; }
    .sheet { max-width: none; border-radius: 0; padding: 12mm 13mm; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .edit-field { border: 0; }
    .edit-field::placeholder { color: transparent; }
}

/* 1.2.0: ändringslogg och bokföring */
tr.row-warning td { background: rgba(200, 60, 60, 0.14); }
.nowrap { white-space: nowrap; }
td.num, th.num { text-align: right; }

/* 1.3.0: Funktioner */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 24px; }
.feature-grid h3 { margin: 6px 0 4px; font-size: 0.95rem; }
