*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #003D7A;
    --primary-hover:  #004B9B;
    --primary-light:  #E8F0FA;
    --accent:         #E31E24;
    --success:        #16A34A;
    --success-bg:     #DCFCE7;
    --warning:        #D97706;
    --warning-bg:     #FEF3C7;
    --danger:         #DC2626;
    --danger-bg:      #FEE2E2;
    --bg:             #F1F5F9;
    --white:          #FFFFFF;
    --text:           #1E293B;
    --text-light:     #64748B;
    --border:         #CBD5E1;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.08);
    --shadow:         0 4px 16px rgba(0,0,0,0.12);
    --radius:         8px;
    --radius-lg:      12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* ─── HEADER ─────────────────────────────────────────────── */
.app-header {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,30,80,0.35);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 64px;
    gap: 24px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.header-title  { font-size: 17px; font-weight: 700; color: white; }
.header-sub    { font-size: 12px; color: rgba(255,255,255,0.65); }

.header-nav {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.nav-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-btn:hover  { background: rgba(255,255,255,0.14); color: white; }
.nav-btn.active { background: rgba(255,255,255,0.22); color: white; }

/* ─── MAIN ───────────────────────────────────────────────── */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ─── SECTION HEADER ─────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.section-header h1 { font-size: 22px; font-weight: 700; }

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    border-left: 5px solid;
}
.stat-card--total  { border-color: var(--primary); }
.stat-card--aktiv  { border-color: var(--success); }
.stat-card--snart  { border-color: var(--warning); }
.stat-card--utlopt { border-color: var(--danger); }

.stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 700;
}
.stat-value { font-size: 38px; font-weight: 800; margin: 4px 0 2px; }
.stat-card--total  .stat-value { color: var(--primary); }
.stat-card--aktiv  .stat-value { color: var(--success); }
.stat-card--snart  .stat-value { color: var(--warning); }
.stat-card--utlopt .stat-value { color: var(--danger);  }
.stat-sub { font-size: 12px; color: var(--text-light); }

/* ─── TABLE CONTROLS ─────────────────────────────────────── */
.table-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,61,122,0.1);
}

.filter-group {
    display: flex;
    gap: 3px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}
.filter-btn {
    padding: 4px 12px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-light);
    transition: all 0.15s;
}
.filter-btn.active { background: var(--primary); color: white; }

.select-sm {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    background: white;
    cursor: pointer;
}

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrapper {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}
.data-table th {
    background: var(--primary);
    color: white;
    padding: 11px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tbody tr:last-child td { border-bottom: none; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { background: #004a8f; }
.sort-aktiv { background: #004a8f !important; }
.notat-ikon { font-size: 12px; cursor: help; margin-left: 4px; }

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary);
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge--aktiv  { background: var(--success-bg); color: var(--success); }
.badge--snart  { background: var(--warning-bg); color: var(--warning); }
.badge--utlopt { background: var(--danger-bg);  color: var(--danger);  }

.days-text { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-secondary:hover { background: var(--primary-light); }
.btn-ghost     { background: none; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-full      { width: 100%; }
.btn-sm        { padding: 5px 11px; font-size: 12px; }
.btn-link      { background: none; border: none; padding: 0; color: var(--primary); font-size: inherit; cursor: pointer; text-decoration: underline; font-family: inherit; }
.btn:disabled  { opacity: 0.45; cursor: not-allowed; }

/* ─── Org admin under-tabs ─────────────────────────────── */
.org-tab-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-light);
    font-family: inherit;
    transition: background .15s, color .15s;
}
.org-tab-btn:hover:not(.active) { background: rgba(0,0,0,.05); color: var(--text); }
.org-tab-btn.active { background: white; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.org-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.org-stat-kort {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.org-stat-tall { font-size: 30px; font-weight: 800; }
.org-stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.btn-icon:hover { background: var(--bg); }

.action-btns { display: flex; gap: 5px; }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}
.form-card h2 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.form-grid--1 { grid-template-columns: 1fr; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: white;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,61,122,0.1);
}

.optional { color: var(--text-light); font-weight: 400; font-size: 12px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.success-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-top: 16px;
    font-weight: 600;
    border: 1px solid #86EFAC;
}

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay,
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.28);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 0;
}
.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.28);
}
.modal-box--large { max-width: 700px; }
.modal-box--small { max-width: 400px; }

.modal-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.modal-top h2 { font-size: 18px; font-weight: 700; }

.modal-center {
    text-align: center;
    margin-bottom: 28px;
}
.modal-center h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-center p  { color: var(--text-light); font-size: 14px; }

.modal-logo {
    height: 52px;
    margin-bottom: 16px;
    object-fit: contain;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ─── KURSBEVIS PREVIEW ──────────────────────────────────── */
.kursbevis-preview-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin: 20px 0;
    background: var(--bg);
}

.kursbevis-card {
    background: white;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    padding: 28px 32px;
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}
.kursbevis-card .kv-tag    { font-size: 11px; color: var(--text-light); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.kursbevis-card .kv-title  { font-size: 20px; font-weight: 800; color: var(--primary); margin-bottom: 2px; }
.kursbevis-card .kv-org    { font-size: 12px; color: var(--text-light); margin-bottom: 20px; }
.kursbevis-card .kv-sub    { font-size: 13px; color: var(--text-light); }
.kursbevis-card .kv-name   { font-size: 26px; font-weight: 700; color: var(--text); margin: 8px 0; }
.kursbevis-card .kv-co     { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.kursbevis-card .kv-course { font-size: 17px; font-weight: 700; color: var(--primary); margin: 8px 0; }
.kursbevis-card .kv-dates  { font-size: 13px; color: var(--text-light); margin-top: 16px; line-height: 1.8; }
.kursbevis-card .kv-footer {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ─── ÅRSRAPPORT ─────────────────────────────────────────── */
.arsrapport-preview {
    margin: 16px 0;
}
.arsrapport-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}
.arsrapport-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.arsrapport-box .meta { font-size: 13px; color: var(--text-light); margin-bottom: 24px; }

.arsrapport-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.arsrapport-stat {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.arsrapport-stat .value { font-size: 30px; font-weight: 800; color: var(--primary); }
.arsrapport-stat .label { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th {
    background: var(--primary);
    color: white;
    padding: 8px 12px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
}
.mini-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.mini-table tbody tr:nth-child(even) { background: var(--bg); }
.mini-table tbody tr:last-child td { border-bottom: none; }

/* ─── INNSTILLINGER ──────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}
.action-row:last-child { border-bottom: none; }
.action-row h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.action-row p  { font-size: 12px; color: var(--text-light); }

.danger-zone { color: var(--danger); }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 64px 32px;
}
.empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state p { color: var(--text-light); margin-bottom: 16px; font-size: 15px; }

/* ─── TOAST ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s;
    z-index: 1000;
    box-shadow: var(--shadow);
    pointer-events: none;
}
.toast--show    { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); }
.toast--error   { background: var(--danger); }

/* ─── KURSBEVIS-MAL ──────────────────────────────────────── */
.mal-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
    align-items: start;
}

.mal-col { display: flex; flex-direction: column; gap: 20px; }

.mal-preview-sticky {
    position: sticky;
    top: 84px;
}
.mal-preview-sticky > h2 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.mal-preview-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 260px;
}

/* LOGO UPLOAD */
.logo-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    background: var(--bg);
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s;
    margin-bottom: 8px;
}
.logo-upload-area:hover { border-color: var(--primary); }
.logo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-light); font-size: 13px; }
.logo-placeholder span:first-child { font-size: 22px; }
.logo-preview-img { max-height: 56px; max-width: 220px; object-fit: contain; }

/* GOALS */
.hint-text { font-size: 13px; color: var(--text-light); margin-bottom: 12px; }
.goals-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; min-height: 4px; }

.goal-item { display: flex; flex-direction: column; gap: 0; }
.goal-item-row { display: flex; gap: 8px; align-items: center; }
.goal-number { font-size: 12px; color: var(--text-light); font-weight: 600; min-width: 18px; flex-shrink: 0; }

.goal-item input, .goal-title-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: inherit;
}
.goal-item input:focus, .goal-title-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,61,122,0.1); }

.goal-desc-toggle {
    padding: 5px 9px; font-size: 11px; font-family: inherit;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text-light);
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: all 0.15s;
}
.goal-desc-toggle:hover { border-color: var(--primary); color: var(--primary); }
.goal-desc-toggle.has-desc { color: var(--primary); border-color: var(--primary); background: rgba(0,61,122,0.06); }

.goal-desc-area { padding: 6px 0 2px 26px; }
.goal-desc-area textarea {
    width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 10px; font-size: 12.5px; font-family: inherit;
    color: var(--text); background: white;
    resize: vertical; min-height: 64px; line-height: 1.5;
}
.goal-desc-area textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,61,122,0.1); }

.mal-lengde-advarsel {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.advarsel-gul {
    background: #fefce8;
    border: 1px solid #fde047;
    color: #854d0e;
}
.advarsel-rod {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.goal-remove {
    background: none; border: none; cursor: pointer;
    color: var(--text-light); font-size: 20px; padding: 2px 6px;
    border-radius: 4px; line-height: 1; flex-shrink: 0;
}
.goal-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* MAL-LISTE */
.mal-liste { display: flex; flex-direction: column; gap: 6px; }
.mal-liste-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    transition: border-color 0.15s;
}
.mal-liste-item.active { border-color: var(--primary); background: rgba(0,61,122,0.04); }
.mal-liste-item.archived { opacity: 0.6; background: var(--bg); }
.mal-item-info { flex: 1; min-width: 0; }
.mal-item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mal-item-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.mal-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* MAL EDITOR HEADER */
.mal-editor-header {
    font-size: 13px; font-weight: 700; color: var(--primary);
    padding-bottom: 12px; margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}

/* SIGNATUR-TABS */
.signatur-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.signatur-tab {
    background: none; border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 18px; cursor: pointer;
    font-size: 13.5px; font-weight: 500;
    color: var(--text-light);
    margin-bottom: -1px;
    transition: all 0.15s;
}
.signatur-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.signatur-tab:hover  { color: var(--text); }

/* SIGNATURE CANVAS */
.signatur-canvas-wrap {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}
.signatur-canvas-wrap:hover { border-color: var(--primary); }
.signatur-canvas {
    display: block;
    width: 100%;
    /* Egendefinert crosshair: hvit glød + mørk kjerne → synlig på hvit og mørk bakgrunn */
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cline x1='12' y1='0' x2='12' y2='24' stroke='white' stroke-width='3.5'/%3E%3Cline x1='0' y1='12' x2='24' y2='12' stroke='white' stroke-width='3.5'/%3E%3Cline x1='12' y1='0' x2='12' y2='24' stroke='%23111827' stroke-width='1.5'/%3E%3Cline x1='0' y1='12' x2='24' y2='12' stroke='%23111827' stroke-width='1.5'/%3E%3C/svg%3E") 12 12, crosshair;
    touch-action: none;
    height: 140px;
}
.signatur-actions { display: flex; gap: 8px; margin-bottom: 4px; }

/* SIGNATURE UPLOAD */
.signatur-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: var(--bg);
    min-height: 100px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s;
    margin-bottom: 10px;
}
.signatur-upload-area:hover { border-color: var(--primary); }
.signatur-upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-light); }
.signatur-upload-placeholder span { font-size: 24px; }
.signatur-upload-placeholder p  { font-size: 12px; max-width: 260px; }
.signatur-preview-img { max-height: 80px; max-width: 100%; object-fit: contain; }

.signatur-lagret {
    display: flex; align-items: center; gap: 10px;
    margin: 8px 0 14px; font-size: 13px;
}

/* STED-FELT i kursbevis-tab */
.sted-wrap {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* FORMAT-VELGER */
.format-choices { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.format-choice { flex: 1; min-width: 110px; cursor: pointer; display: block; }
.format-choice input[type=radio] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.format-choice-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    background: white;
}
.format-choice-card:hover { border-color: var(--primary); }
.format-choice:has(input:checked) .format-choice-card { border-color: var(--primary); background: rgba(0,61,122,0.05); }
.format-shape-demo {
    background: var(--border);
    border: 1.5px solid var(--text-light);
    border-radius: 2px;
    transition: background 0.15s, border-color 0.15s;
}
.format-choice:has(input:checked) .format-shape-demo { background: rgba(0,61,122,0.18); border-color: var(--primary); }
.format-choice-title { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1.2; }
.format-choice-sub { font-size: 10px; color: var(--text-light); margin-top: -2px; }

/* FORHÅNDSVISNING: formatspesifikke bredder */
.kursbevis-preview-wrap.preview-a5      { max-width: 360px; margin-left: auto; margin-right: auto; }
.kursbevis-preview-wrap.preview-a4-land { max-width: 480px; margin-left: auto; margin-right: auto; }
.kursbevis-preview-wrap.preview-portrait { max-width: 360px; margin-left: auto; margin-right: auto; }

/* KURSBEVIS ENHANCED PREVIEW */
.kv-preview-header {
    padding: 10px 16px;
    display: flex; align-items: center; gap: 10px;
}
.kv-preview-header .kv-title-col { flex: 1; }
.kv-preview-header .kv-org-text { font-size: 10px; opacity: 0.75; }
.kv-preview-body { padding: 14px 20px; text-align: center; }
.kv-preview-goals {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.kv-preview-goals .goals-label {
    font-size: 9px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.7px; color: var(--text-light); margin-bottom: 6px;
    text-align: center;
}
.kv-preview-goal { font-size: 11.5px; display: flex; gap: 6px; padding: 2px 0; justify-content: center; align-items: flex-start; }
.kv-preview-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    display: flex; align-items: flex-end; gap: 16px;
}
.kv-preview-sig { flex-shrink: 0; }
.kv-preview-sig img { max-height: 36px; max-width: 100px; object-fit: contain; display: block; }
.kv-preview-sig .sig-line { border-top: 1px solid var(--border); padding-top: 3px; margin-top: 2px; font-size: 10px; color: var(--text-light); }
.kv-preview-meta { margin-left: auto; text-align: right; font-size: 10px; color: var(--text-light); line-height: 1.8; }

/* ─── EGNE KURSTYPER ─────────────────────────────────────── */
.egne-kurstype-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    overflow: hidden;
}
.egne-kurstype-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
}
.egne-kurstype-actions { display: flex; gap: 6px; flex-shrink: 0; }
.egne-kurstype-navn { font-weight: 600; font-size: 14px; }
.egne-kurstype-meta { font-size: 12px; color: var(--text-light); margin-top: 1px; }

/* ─── EKSTRA FELTER (per kurstype) ──────────────────────── */
.ekstra-felter-liste {
    padding: 0 14px 8px;
    display: flex; flex-wrap: wrap; gap: 6px;
}
.ekstra-felt-item {
    display: flex; align-items: center; gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 8px 3px 12px;
    font-size: 12px;
}
.ekstra-felt-navn { color: var(--text); }
.ekstra-felt-enhet { color: var(--text-light); }
.ekstra-felt-badge {
    display: inline-block;
    font-size: 10px; font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--text-light);
    text-transform: lowercase;
}
.ekstra-felt-badge--pakrevd {
    background: #fef3c7; border-color: #fbbf24; color: #92400e;
}
.ekstra-felt-item .btn-icon {
    font-size: 10px; color: var(--text-light);
    padding: 1px 3px; line-height: 1;
}
.ekstra-felt-item .btn-icon:hover { color: var(--danger); }

/* ─── HURTIGMALER ────────────────────────────────────────── */
.hurtigmaler-seksjon {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.hurtigmaler-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-light);
    margin-bottom: 8px;
}
.hurtigmaler-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.hurtigmal-chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 13px; font-weight: 500;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 20px;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.hurtigmal-chip:hover {
    background: #e8f0fb;
    border-color: var(--primary);
    border-style: solid;
}
.hurtigmal-felt-hint {
    font-size: 11px; font-weight: 400; color: var(--text-light);
}

/* ─── NY-FELT-FORM (inline under kurstype) ───────────────── */
.ny-felt-form {
    border-top: 1px dashed var(--border);
    padding: 10px 14px 12px;
    background: var(--surface);
}
.ny-felt-form-innhold {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px;
}
.ny-felt-gruppe { margin-bottom: 0; flex: 1; min-width: 120px; }
.ny-felt-pakrevd-wrap {
    display: flex; align-items: center; gap: 5px;
    padding-bottom: 4px;
    white-space: nowrap;
}

/* ─── MAL-KURSTYPE KOBLING ───────────────────────────────── */
.mal-kurstype-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
}
.mal-kurstype-gruppe-label {
    grid-column: 1 / -1;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-light);
    margin-bottom: 4px; margin-top: 2px;
}
.mal-kurstype-check {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer; padding: 3px 0;
}
.mal-kurstype-check input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }

/* ─── KLIKKBART DELTAKERNAVN I TABELL ───────────────────── */
.deltaker-navn-link {
    font-weight: 700;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px dashed transparent;
    transition: color 0.15s, border-color 0.15s;
}
.deltaker-navn-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ─── APP-LOADING OVERLAY ────────────────────────────────── */
.app-loading {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.9);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px;
    z-index: 9999;
    font-size: 14px; color: var(--text-light);
}
.app-loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ─── Faktura-tooltip ───────────────────────────────────── */
.faktura-celle {
    position: relative;
    cursor: pointer;
    white-space: nowrap;
}
.faktura-kortvisning {
    text-decoration: underline dotted var(--text-light);
    text-underline-offset: 2px;
}
.faktura-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 14px 10px;
    border-radius: 10px;
    white-space: pre-wrap;
    max-width: 340px;
    min-width: 200px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    border: 1px solid var(--border);
    z-index: 300;
    pointer-events: auto;
}
.faktura-popover.open { display: block; }
.faktura-popover-tekst {
    user-select: text;
    word-break: break-word;
    margin-bottom: 10px;
}
.faktura-kopier-knapp {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* ─── BULK DELTAKERLISTE ─────────────────────────────────── */
.bulk-liste-ruter {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px 12px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.bulk-deltaker-rad {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 0;
}
.bulk-deltaker-rad input[type="checkbox"] { flex-shrink: 0; cursor: pointer; }
.bulk-epost { color: var(--text-light); font-size: 11px; }

/* ─── HJELP / TUTORIAL ──────────────────────────────────── */
.hjelp-fane {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.hjelp-fane.aktiv {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.hjelp-seksjon {
    margin-bottom: 36px;
}
.hjelp-seksjon-tittel {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.hjelp-steg {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}
.hjelp-steg-nr {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.hjelp-steg-innhold {
    flex: 1;
}
.hjelp-steg-innhold strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}
.hjelp-steg-innhold p {
    font-size: 13px;
    color: var(--text-light);
    margin: 0 0 10px;
    line-height: 1.6;
}
.hjelp-bilde {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 8px;
    display: block;
}
/* FAQ */
.faq-gruppe-tittel {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.faq-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.faq-item summary {
    padding: 13px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    font-size: 18px;
    color: var(--text-light);
    margin-left: 12px;
    transition: transform .2s;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item p {
    padding: 12px 16px 14px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-light);
    margin: 0;
    border-top: 1px solid var(--border);
}

/* ─── MODAL XL (påmeldte-modal) ─────────────────────────── */
.modal-box--xl {
    max-width: min(95vw, 1160px);
    width: min(95vw, 1160px);
}

/* ─── HURTIGMALER ────────────────────────────────────────── */
.hurtigmaler-seksjon {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.hurtigmaler-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-light); margin-bottom: 8px;
}
.hurtigmaler-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hurtigmal-chip {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #BFDBFE;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.hurtigmal-chip:hover { background: #DBEAFE; }
.hurtigmal-felt-hint { font-weight: 400; opacity: 0.75; }

/* ─── EKSTRA FELTER (kurstype-innstillinger) ─────────────── */
.egne-kurstype-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}
.egne-kurstype-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 14px;
}
.egne-kurstype-info { flex: 1; min-width: 0; }
.egne-kurstype-navn { font-weight: 700; font-size: 14px; }
.egne-kurstype-meta { font-size: 12px; color: var(--text-light); margin-top: 1px; }
.egne-kurstype-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ekstra-felter-liste {
    padding: 0 14px 10px;
    display: flex; flex-direction: column; gap: 4px;
}
.ekstra-felt-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; font-size: 13px;
    background: white; border-radius: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
}
.ekstra-felt-navn { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ekstra-felt-enhet { color: var(--text-light); font-size: 11px; }
.ekstra-felt-badge {
    font-size: 10px; background: var(--bg); color: var(--text-light);
    border: 1px solid var(--border); border-radius: 10px;
    padding: 1px 7px; font-weight: 600;
}
.ekstra-felt-badge--pakrevd {
    background: #FEF3C7; color: #92400E; border-color: #FDE68A;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVT DESIGN — MOBIL OG NETTBRETT
   ═══════════════════════════════════════════════════════════ */

/* ── Nettbrett (≤ 900px) ── */
@media (max-width: 900px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .app-main {
        padding: 20px 16px 48px;
    }
    .header-inner {
        padding: 0 16px;
        gap: 12px;
    }
    .header-nav {
        gap: 1px;
    }
    .nav-btn {
        padding: 7px 10px;
        font-size: 12.5px;
    }
}

/* ── Mobil (≤ 640px) ── */
@media (max-width: 640px) {

    /* Header */
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 10px 12px 0;
        gap: 8px;
        align-items: stretch;
    }
    .header-brand {
        justify-content: center;
        padding-bottom: 2px;
    }
    .header-logo { height: 30px; }
    .header-title { font-size: 15px; }
    .header-sub   { display: none; }

    /* Navigasjon — horisontal scroll */
    .header-nav {
        margin-left: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 6px;
        gap: 2px;
    }
    .header-nav::-webkit-scrollbar { display: none; }
    .nav-btn {
        padding: 7px 12px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Logg-ut knapp */
    #loggut-btn { font-size: 12px; padding: 6px 10px; }

    /* Hovedinnhold */
    .app-main { padding: 16px 12px 40px; }

    /* Seksjonstittel */
    .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .section-header h1 { font-size: 18px; }

    /* Statuskort: 2 kolonner på mobil */
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }
    .stat-value { font-size: 28px; }
    .stat-card  { padding: 14px 16px; }

    /* Tabellkontroller */
    .table-controls { gap: 8px; }
    .search-input   { min-width: 0; font-size: 13px; }

    /* Tabell — horisontal scroll */
    .table-wrapper  { border-radius: var(--radius); }
    .data-table     { min-width: 700px; }
    .data-table th,
    .data-table td  { padding: 9px 10px; font-size: 12.5px; }

    /* Modaler — full bredde (fiks: dekker både modal-overlay og modal-backdrop) */
    .modal-overlay,
    .modal,
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal-box {
        max-width: 100% !important;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        overflow-y: auto;
    }
    .modal-header { padding: 16px 16px 12px; }
    .modal-body   { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .modal-actions { flex-wrap: wrap; gap: 8px; }
    .modal-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* Skjemakort */
    .form-card { padding: 16px; }
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }
    .form-actions {
        flex-direction: column;
        gap: 8px;
    }
    .form-actions .btn { width: 100%; justify-content: center; }

    /* Knapper i seksjon-header */
    .section-header .btn { width: 100%; justify-content: center; }
    .section-header > div[style*="flex"] {
        flex-direction: column;
        width: 100%;
    }

    /* Handlingsknapper i tabeller */
    .action-btns { flex-wrap: wrap; gap: 4px; }
    .action-btns .btn { font-size: 11.5px; padding: 4px 8px; }

    /* Tabellkontroller — wrap på mobil */
    .table-controls { flex-wrap: wrap; }
    .filter-group   { flex-wrap: wrap; }

    /* Import-mapping grid */
    .import-mapping-rad {
        grid-template-columns: 1fr !important;
    }

    /* Kursbevis-forhåndsvisning */
    .kursbevis-preview-wrap.preview-a5,
    .kursbevis-preview-wrap.preview-a4-land,
    .kursbevis-preview-wrap.preview-portrait { max-width: 100%; }

    /* Format-valg */
    .format-choices { gap: 8px; }
    .format-choice  { min-width: 80px; }
    .format-choice-title { font-size: 12px; }
    .format-choice-sub   { font-size: 10px; }

    /* Påmeldt-tabell i kommende kurs */
    .pameldt-table th,
    .pameldt-table td { padding: 8px 10px; font-size: 12px; }

    /* Maler-liste */
    .mal-liste-item { flex-direction: column; align-items: flex-start; gap: 8px; }
    .mal-item-actions { align-self: flex-end; }

    /* Kompetansemål-editor */
    .goal-item-row { flex-wrap: wrap; }
    .goal-title-input { min-width: 0; flex: 1 1 140px; }

    /* Signatur-tabs */
    .signatur-tabs { flex-wrap: wrap; }

    /* Deltaker-historikk modal */
    .historikk-modal .modal-box { max-height: 85vh; }

    /* Mal-grid (mal-editor): collapse til én kolonne */
    .mal-grid {
        grid-template-columns: 1fr;
    }
    .mal-preview-sticky {
        position: static;
        order: -1;
    }

    /* Modal XL og large: fix width (max-width alene er ikke nok) */
    .modal-box--xl,
    .modal-box--large {
        width: 100%;
        max-width: 100% !important;
    }

    /* Årsrapport-statistikk: 2 kolonner */
    .arsrapport-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Innstillinger action-row: stack knapper under tekst */
    .action-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .action-row > div:last-child { width: 100%; }
    .action-row .btn { width: 100%; justify-content: center; }

    /* Bulk-kursbevis deltakerliste */
    .bulk-liste-ruter {
        grid-template-columns: 1fr;
    }

    /* Pameldt-tabell i modal: scroll */
    .pameldt-table { min-width: 560px; }
}

/* ── Veldig liten mobil (≤ 380px) ── */
@media (max-width: 380px) {
    .stat-value { font-size: 24px; }
    .nav-btn    { padding: 6px 9px; font-size: 11.5px; }
    .data-table { min-width: 600px; }
    .arsrapport-stats { grid-template-columns: 1fr; }
}
