:root {
    --ink: #15231d;
    --muted: #66726c;
    --paper: #fffefa;
    --canvas: #f5f3ed;
    --green: #123f30;
    --green-2: #1d6049;
    --green-soft: #e3eee8;
    --orange: #ef6a3a;
    --orange-soft: #fff0e9;
    --line: #dedbd2;
    --danger: #a73d35;
    --shadow: 0 18px 60px rgba(21, 35, 29, .09);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(circle at 85% 2%, #eef3ed 0, transparent 30%), var(--canvas); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 22px; font: 700 clamp(42px, 6vw, 76px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -3.5px; }
h2 { font: 700 25px/1.15 Georgia, "Times New Roman", serif; letter-spacing: -.5px; }

.site-header { position: relative; z-index: 20; min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px max(24px, calc((100vw - 1180px) / 2)); background: rgba(255, 254, 250, .92); border-bottom: 1px solid rgba(222, 219, 210, .85); backdrop-filter: blur(16px); }
.site-header nav { display: flex; align-items: center; gap: 12px; }
.site-header nav > a:not(.button) { padding: 10px 12px; text-decoration: none; color: #34433c; font-weight: 700; }
.site-header nav > a:not(.button):hover { color: var(--green-2); }
.user-name { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.profile-link { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; }
.profile-link img, .profile-link > span { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.profile-link > span { display: grid; place-items: center; background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 850; }
.profile-link b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--green); color: white; font: italic 700 23px Georgia, serif; box-shadow: 0 8px 20px rgba(18, 63, 48, .18); }
.brand-copy { display: grid; line-height: 1; }
.brand strong { font: 800 25px Georgia, serif; letter-spacing: -1px; }
.brand small { margin: 3px 0 0 2px; color: var(--orange); font: 800 10px/1 system-ui, sans-serif; letter-spacing: .2px; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 52px auto 72px; flex: 1; }
footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 20px; padding: 30px 24px; color: var(--muted); border-top: 1px solid var(--line); background: rgba(255, 254, 250, .55); font-size: 13px; }
footer strong { color: var(--ink); }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--orange); font-size: 11px; font-weight: 850; letter-spacing: 1.8px; }
.eyebrow i { width: 22px; height: 2px; background: currentColor; }
.muted, small { color: var(--muted); }
.center { text-align: center; }

.card { background: rgba(255, 254, 250, .96); border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 12px 40px rgba(21, 35, 29, .045); }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 12px; min-height: 48px; padding: 0 22px; border: 1px solid var(--green); border-radius: 12px; background: var(--green); color: white; font: inherit; font-weight: 780; text-decoration: none; cursor: pointer; box-shadow: 0 7px 16px rgba(18, 63, 48, .14); transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.button:hover { transform: translateY(-1px); background: var(--green-2); box-shadow: 0 10px 22px rgba(18, 63, 48, .18); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .link-button:focus-visible { outline: 3px solid rgba(239, 106, 58, .28); outline-offset: 2px; }
.button.secondary { background: transparent; border-color: #aab8b1; color: var(--green); box-shadow: none; }
.button.secondary:hover { border-color: var(--green); background: var(--green-soft); }
.button.small { min-height: 38px; padding: 0 15px; border-radius: 10px; }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; box-shadow: none; }
.inline-form { display: inline; }
.link-button { padding: 4px 0; border: 0; background: transparent; color: var(--green); font: inherit; font-weight: 750; cursor: pointer; text-decoration: underline; text-decoration-color: #9ab2a7; text-underline-offset: 4px; }
.danger { color: var(--danger); }
.flash { margin: 0 0 20px; padding: 15px 18px; border: 1px solid #b8d2c2; border-radius: 12px; background: var(--green-soft); color: var(--green); font-weight: 650; }
.flash.error { color: var(--danger); background: #fbe7e4; border-color: #edbbb5; }
.flash.warning { color: #6e5419; background: #fff0c9; border-color: #e7ce8c; }

/* Forside */
.hero { min-height: 610px; display: grid; grid-template-columns: 1.04fr .96fr; gap: clamp(42px, 7vw, 90px); align-items: center; padding: 30px 0 62px; }
.hero-copy { position: relative; z-index: 2; }
.hero h1 em { color: var(--green-2); font-style: italic; font-weight: 500; }
.hero p { max-width: 590px; color: #4d5b55; font-size: clamp(18px, 2vw, 21px); line-height: 1.6; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-proof { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 28px; color: var(--muted); font-size: 12px; font-weight: 650; }
.product-preview { position: relative; min-height: 480px; overflow: hidden; border: 1px solid #d5ded8; border-radius: 28px; background: #eaf0ec; box-shadow: var(--shadow); transform: rotate(1deg); }
.preview-top { height: 58px; display: flex; align-items: center; gap: 9px; padding: 0 20px; background: var(--paper); border-bottom: 1px solid var(--line); color: #425049; font-size: 13px; font-weight: 700; }
.preview-top b { margin-left: auto; padding: 6px 10px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 11px; }
.preview-dot { width: 9px; height: 9px; margin-right: 30px; border-radius: 50%; background: var(--orange); box-shadow: 15px 0 #ebc264, 30px 0 #66aa83; }
.preview-body { min-height: 422px; display: grid; place-items: center; padding: 28px; background: linear-gradient(145deg, #dce6df, #eef2ef); }
.paper { position: relative; width: min(270px, 67%); aspect-ratio: .74; padding: 34px; background: var(--paper); border-radius: 3px; box-shadow: 0 24px 52px rgba(21, 35, 29, .18); transform: rotate(-4deg); }
.paper > span { font: 700 24px Georgia, serif; }
.paper i { display: block; height: 6px; margin-top: 23px; background: #e1ded6; border-radius: 4px; }
.paper i.short { width: 64%; }
.signature { position: absolute; right: 25px; bottom: 48px; color: var(--green); font: italic 33px cursive; border-bottom: 2px solid var(--green); }
.paper > small { position: absolute; left: 27px; bottom: 22px; color: var(--orange); font-size: 8px; font-weight: 900; letter-spacing: 1.4px; }
.preview-panel { position: absolute; left: 20px; top: 82px; display: grid; gap: 8px; }
.preview-panel span { display: grid; place-items: center; width: 36px; height: 42px; border: 1px solid #cad4ce; border-radius: 5px; background: var(--paper); color: var(--muted); font-size: 9px; }
.preview-panel span:first-child { border: 2px solid var(--green-2); }
.preview-toast { position: absolute; right: 22px; bottom: 22px; display: flex; align-items: center; gap: 12px; width: 250px; padding: 15px; border: 1px solid #d7e2db; border-radius: 15px; background: var(--paper); box-shadow: 0 16px 36px rgba(21, 35, 29, .15); transform: rotate(-1deg); }
.preview-toast > b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: white; }
.preview-toast > span { display: grid; gap: 3px; }
.preview-toast strong { font-size: 12px; }
.preview-toast small { font-size: 10px; }
.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.feature-row article { display: grid; grid-template-columns: auto 1fr; gap: 18px; padding: 34px 28px; }
.feature-row article + article { border-left: 1px solid var(--line); }
.feature-row b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--orange-soft); color: var(--orange); font-size: 11px; }
.feature-row h2 { margin-bottom: 8px; font-size: 21px; }
.feature-row p { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.offline-callout { display: flex; align-items: center; justify-content: space-between; gap: 36px; margin-top: 78px; padding: 44px 48px; border-radius: 24px; background: var(--green); color: white; box-shadow: 0 20px 50px rgba(18, 63, 48, .16); }
.offline-callout .eyebrow { margin-bottom: 10px; }
.offline-callout h2 { margin-bottom: 8px; font-size: 32px; }
.offline-callout p { margin-bottom: 0; color: #cbdad3; }
.offline-callout .button.secondary { flex: 0 0 auto; border-color: #9fbaad; color: white; }
.offline-callout .button.secondary:hover { background: rgba(255,255,255,.1); }

/* Login og formularer */
.auth-card { width: min(470px, 100%); margin: 72px auto; padding: 36px; }
.auth-card h1 { margin-bottom: 28px; font-size: 50px; }
.auth-card > .muted { margin: 22px 0 0; text-align: center; font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 20px; font-size: 13px; font-weight: 700; }
.auth-links a { color: var(--green); text-underline-offset: 3px; }
.stack-form { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: #34433c; font-size: 14px; font-weight: 750; }
input, textarea, select { width: 100%; min-height: 48px; padding: 10px 13px; border: 1px solid #bbbfb9; border-radius: 10px; background: white; color: var(--ink); }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
select { appearance: auto; }
input:hover, textarea:hover, select:hover { border-color: #8e9b94; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(29, 96, 73, .09); outline: none; }
input[readonly] { background: #f2f1ec; color: var(--muted); }

/* Profil og tenantadministration */
.profile-grid { display: grid; grid-template-columns: 300px minmax(0, 650px); gap: 18px; align-items: start; }
.profile-avatar-card { display: grid; justify-items: center; gap: 16px; text-align: center; }
.profile-avatar-card .file-picker { width: 100%; }
.profile-avatar-card .file-picker span { justify-content: center; }
.avatar-large { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; border: 5px solid var(--paper); box-shadow: 0 0 0 1px var(--line), 0 14px 30px rgba(21, 35, 29, .12); }
.avatar-placeholder { display: grid; place-items: center; background: var(--green-soft); color: var(--green); font: 700 58px Georgia, serif; }
.profile-fields { align-content: start; }
.profile-fields .button { justify-self: start; }
.tenant-admin-grid { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(420px, 1.28fr); gap: 18px; align-items: start; }
.tenant-member-card { min-width: 0; }
.member-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; white-space: nowrap; }
.pending-invitations { margin-top: 18px; }
.pending-invitations > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pending-invitations > div:last-child { border-bottom: 0; }
.pending-invitations > div > span:first-child { display: grid; gap: 4px; }

/* Arkiv og dokumenter */
.page-heading, .document-header, .sign-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 28px; }
.page-heading h1, .document-header h1, .sign-heading h1 { margin-bottom: 0; font-size: clamp(40px, 5vw, 56px); }
.document-header p { margin: 7px 0 0; }
.upload-card { display: flex; justify-content: space-between; align-items: center; gap: 28px; margin-bottom: 24px; padding: 22px 24px; }
.upload-card h2 { margin-bottom: 5px; }
.upload-card p { margin-bottom: 0; font-size: 14px; }
.upload-form { display: flex; align-items: center; gap: 10px; }
.upload-form input[type=text] { width: 220px; }
.file-picker { display: block; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker span { display: flex; align-items: center; min-height: 48px; padding: 0 16px; border: 1px dashed #7e9e8e; border-radius: 10px; color: var(--green); cursor: pointer; }
.file-picker span:hover { background: var(--green-soft); }
.document-list { display: grid; gap: 10px; }
.document-row { display: grid; grid-template-columns: 50px minmax(180px, 1fr) auto auto 20px; align-items: center; gap: 16px; padding: 15px 20px; border-radius: 15px; text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.document-row:hover { transform: translateY(-2px); border-color: #9fb5a9; box-shadow: 0 12px 34px rgba(21, 35, 29, .08); }
.file-icon { display: grid; place-items: center; width: 42px; height: 50px; background: var(--orange-soft); color: #a64b2a; border: 1px solid #f3cbbb; border-radius: 7px; font-size: 10px; font-weight: 900; }
.document-main { display: grid; gap: 5px; min-width: 0; }
.document-main strong, .document-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest { color: var(--muted); font-size: 13px; }
.status { display: inline-flex; padding: 7px 11px; border-radius: 99px; background: #e8e7e2; color: #4e5752; font-size: 11px; font-weight: 850; white-space: nowrap; }
.status-sent, .status-viewed { background: #fff0c9; color: #775815; }
.status-signed { background: var(--green-soft); color: var(--green); }
.status-archived { color: var(--muted); }
.chevron { color: #9ba39e; font-size: 26px; }
.empty { padding: 70px 30px; text-align: center; }
.back-link { display: inline-flex; margin-bottom: 28px; color: var(--green); font-weight: 750; text-decoration: none; }
.back-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.detail-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; }
.document-actions { display: grid; align-content: start; gap: 14px; }
.document-actions h2 { margin-bottom: 2px; }
.document-actions hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
.facts { margin: 0; }
.facts div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
code { color: #425049; word-break: break-all; font-size: 11px; }
.timeline-card { grid-column: 1 / -1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 15px; padding: 10px 0; }
.timeline li > span { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 5px; border: 2px solid var(--paper); border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 2px #f3c0ad; }
.timeline li div { display: grid; gap: 4px; }
.invite-link { margin-bottom: 18px; border-color: #ead493; background: #fff9e8; }
.copy-row { display: flex; gap: 8px; margin-top: 12px; }

/* Platformadministration */
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.admin-stats .card { display: grid; gap: 5px; padding: 22px 24px; }
.admin-stats strong { color: var(--green); font: 700 34px Georgia, serif; }
.admin-stats span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .7px; }
.admin-table { padding: 0; overflow: auto; }
.admin-table table { width: 100%; border-collapse: collapse; min-width: 820px; }
.admin-table th, .admin-table td { padding: 16px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); background: #f6f4ee; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.admin-table td { font-size: 14px; }
.admin-table td:first-child { display: grid; gap: 4px; }
.admin-table tr:last-child td { border-bottom: 0; }
.platform-grid { grid-template-columns: 1.2fr .8fr; }
.member-list { display: grid; }
.member-list > div { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.member-list > div:last-child { border-bottom: 0; }
.member-list > div > span:first-child { display: grid; gap: 4px; }

/* Underskrift */
.sign-page { width: min(1420px, calc(100vw - 40px)); margin-left: 50%; transform: translateX(-50%); }
.page-nav { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.page-nav button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--green); cursor: pointer; }
.page-nav button:hover:not(:disabled) { border-color: var(--green); background: var(--green-soft); }
.page-nav button:disabled { opacity: .4; }
.sign-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.document-stage { position: relative; min-height: 640px; padding: 30px; display: grid; place-items: start center; background: #dfe3df; border: 1px solid #cdd3ce; border-radius: 20px; overflow: auto; }
.stage-loader { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(223, 227, 223, .94); color: var(--green); }
.stage-loader[hidden] { display: none; }
.stage-loader span { width: 34px; height: 34px; border: 3px solid #b7c8bf; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.canvas-wrap { position: relative; width: fit-content; max-width: 100%; box-shadow: 0 14px 36px rgba(0, 0, 0, .18); }
#document-canvas { display: block; max-width: 100%; height: auto; background: white; cursor: crosshair; }
#signature-overlay { position: absolute; display: none; width: 28%; aspect-ratio: 3 / 1; transform: translate(-50%, -50%); border: 2px dashed var(--orange); color: var(--orange); background: #fff8 center/contain no-repeat; pointer-events: none; text-align: center; padding-top: 5%; font-size: 12px; }
.text-overlay { position: absolute; transform: translateY(-50%); max-width: 45%; padding: 3px 5px; border: 1px dashed var(--green); color: var(--ink); background: #fffdf8dd; pointer-events: none; font-size: clamp(10px, 1.4vw, 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { width: 100%; margin: 15px 0 0; color: #505b55; text-align: center; font-size: 13px; }
.sign-panel { position: sticky; top: 18px; display: grid; gap: 14px; }
.sign-panel > h2 { margin-bottom: 0; }
.owner-tools { display: grid; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.owner-tools h2 { margin: 0; font-size: 20px; }
#signature-pad { width: 100%; height: 126px; border: 1px solid #aeb8b2; border-radius: 10px; background: white; touch-action: none; cursor: crosshair; }
.consent { grid-template-columns: auto 1fr; align-items: start; font-size: 12px; font-weight: 600; line-height: 1.5; }
.consent input { width: 18px; min-height: 18px; margin-top: 1px; accent-color: var(--green); }
.fine-print { margin-bottom: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.error-text { margin: 0; color: var(--danger); font-weight: 750; }

@media (max-width: 940px) {
    .hero { grid-template-columns: 1fr; padding-top: 20px; }
    .hero-copy { max-width: 720px; }
    .product-preview { min-height: 450px; }
    .feature-row { grid-template-columns: 1fr; }
    .feature-row article + article { border-top: 1px solid var(--line); border-left: 0; }
    .sign-layout, .detail-grid, .profile-grid, .tenant-admin-grid { grid-template-columns: 1fr; }
    .admin-stats { grid-template-columns: 1fr; }
    .sign-panel { position: static; }
}

@media (max-width: 720px) {
    .site-header { min-height: 72px; padding: 12px 16px; }
    .site-header nav { gap: 3px; }
    .site-header nav > a:not(.button) { padding: 9px 8px; }
    .profile-link b { display: none; }
    .brand-copy small { display: none; }
    .page-shell { width: min(100% - 28px, 1180px); margin-top: 32px; }
    .hero { min-height: 0; gap: 38px; padding-bottom: 48px; }
    .hero h1 { font-size: clamp(45px, 13vw, 66px); letter-spacing: -2.5px; }
    .product-preview { min-height: 400px; }
    .preview-body { min-height: 342px; }
    .offline-callout { align-items: flex-start; flex-direction: column; padding: 34px 28px; }
    .upload-card, .upload-form { align-items: stretch; flex-direction: column; }
    .upload-form input[type=text] { width: 100%; }
    .document-row { grid-template-columns: 46px 1fr auto; }
    .document-row .guest, .document-row .chevron { display: none; }
    .document-stage { min-height: 320px; padding: 10px; }
    .page-heading, .document-header, .sign-heading { align-items: flex-start; flex-direction: column; }
    .copy-row { flex-direction: column; }
    .member-list > div { align-items: flex-start; }
    .member-actions { align-items: flex-end; flex-direction: column; gap: 8px; }
}

@media (max-width: 470px) {
    .site-header .button.small { min-height: 38px; padding: 0 11px; }
    .brand-mark { width: 37px; height: 37px; }
    .brand strong { font-size: 21px; }
    .hero-proof { display: grid; }
    .product-preview { min-height: 350px; border-radius: 20px; }
    .preview-body { min-height: 292px; padding: 18px; }
    .preview-panel { display: none; }
    .preview-toast { right: 12px; bottom: 12px; width: 225px; }
    .feature-row article { padding: 28px 18px; }
    .auth-card { margin-top: 28px; padding: 25px 20px; }
    .facts div { grid-template-columns: 1fr; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
