:root {
    --primary: #2563eb;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
}
.container { max-width: 1200px; margin: 0 auto; }
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: var(--card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
h1 { margin: 0; font-size: 22px; color: #1e293b; }
.status-badge { font-size: 13px; color: #64748b; }
.status-badge.ok { color: #15803d; }
.status-badge.error { color: #b91c1c; }
.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
/* min-width: 0 låter kolumnerna krympa; breda tabeller rullar då i sidled i sin egen ruta. */
.grid > div { min-width: 0; }
@media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
}
.card {
    background: var(--card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}
h2 { margin-top: 0; font-size: 16px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; }
.form-group { margin-bottom: 12px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    background: white;
    font-size: 14px;
}
button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
}
button:hover { background: #1d4ed8; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-gray { background: #475569; }
.btn-gray:hover { background: #334155; }
.btn-green { background: #059669; }
.btn-green:hover { background: #047857; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #e2e8f0; font-size: 14px; }
th { background: #f1f5f9; color: #475569; font-weight: 600; }
/* Aktiva utbildningar: egen rullning med rubrikraden kvar överst. */
.table-scroll { max-height: 65vh; overflow-y: auto; margin-top: 10px; border: 1px solid #e2e8f0; border-radius: 8px; }
.table-scroll table { margin-top: 0; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 #e2e8f0; }
.badge { padding: 4px 8px; border-radius: 12px; font-size: 11px; font-weight: bold; display: inline-block; white-space: nowrap; }
.badge-OK { background: #dcfce7; color: #15803d; }
.badge-DUE { background: #fef3c7; color: #92400e; }
.badge-EXPIRED { background: #fee2e2; color: #b91c1c; }
.badge-BOOKED { background: #e0f2fe; color: #0369a1; }
.badge-COMPLETED { background: #e2e8f0; color: #475569; }
.btn-sm { padding: 4px 8px; font-size: 12px; width: auto; margin-right: 4px; }
.btn-notify { background: #8b5cf6; }
.btn-notify:hover { background: #7c3aed; }
.btn-delete { background: #ef4444; }
.btn-delete:hover { background: #dc2626; }
.btn-status { background: #10b981; }
.btn-status:hover { background: #059669; }
.log-item { font-size: 12px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; color: #64748b; }
.empty-hint { font-size: 12px; color: #94a3b8; }
.error-banner {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.success-banner {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.hidden { display: none !important; }
.expiry-warn { color: #dc2626; font-weight: 600; }
.expiry-soon { color: #d97706; }

/* ---------- Toppmeny ---------- */
.top-nav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-btn {
    width: auto;
    background: #f1f5f9;
    color: #334155;
    font-size: 13px;
    padding: 8px 14px;
}
.nav-btn:hover { background: #e2e8f0; }
.dropdown-menu {
    position: absolute;
    top: 110%;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 220px;
    z-index: 50;
    overflow: hidden;
}
.dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    color: #1e293b;
    font-weight: 500;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 14px;
}
.dropdown-menu button:hover { background: #f8fafc; }

/* ---------- Collapsible kort (details/summary) ---------- */
.card > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary .chevron { transition: transform 0.15s ease; color: #94a3b8; }
.card[open] > summary .chevron { transform: rotate(90deg); }

/* ---------- Dialoger (inställningar) ---------- */
dialog {
    border: none;
    border-radius: 14px;
    padding: 0;
    max-width: 480px;
    width: 92%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.5); }
.dialog-content { padding: 24px; }
.dialog-content h2 { margin-top: 0; }
.dialog-close {
    width: auto;
    background: #f1f5f9;
    color: #334155;
    margin-top: 10px;
}
.dialog-close:hover { background: #e2e8f0; }
.settings-list { list-style: none; padding: 0; margin: 0 0 16px 0; }
.settings-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
.toggle-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.toggle-row label { margin: 0; font-weight: 500; }
.qr-box { text-align: center; margin: 16px 0; }
.qr-box img { max-width: 200px; border: 1px solid #e2e8f0; border-radius: 8px; }
.secret-code { font-family: monospace; background: #f1f5f9; padding: 8px; border-radius: 6px; word-break: break-all; font-size: 13px; }
.temp-password-box {
    background: #fefce8;
    border: 1px solid #fde68a;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 10px;
}
.temp-password-box code { font-size: 14px; font-weight: bold; }
.backup-item { flex-wrap: wrap; gap: 8px; }
.backup-actions { display: flex; gap: 6px; flex-shrink: 0; }
.backup-actions button { width: auto; }
@media (max-width: 480px) {
    header { flex-wrap: wrap; gap: 10px; padding: 16px; }
    h1 { font-size: 18px; }
    th, td { padding: 8px; }
    .backup-item { flex-direction: column; align-items: flex-start; }
    .backup-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- Login-sida ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-card {
    background: var(--card);
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 24px; }

/* ---- v5 ---- */
.hint { font-size: 12px; color: #64748b; margin: 6px 0 10px; }
.table-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.table-tools input[type="search"] { flex: 1; min-width: 180px; }
.inline-check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; margin: 0; }
.inline-check input { width: auto; margin: 0; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-link {
    display: inline-block; padding: 8px 12px; border-radius: 6px; background: #475569;
    color: #fff; text-decoration: none; font-size: 13px; font-weight: 600;
}
.btn-link:hover { background: #334155; }
.btn-edit { background: #64748b; }
.btn-edit:hover { background: #475569; }
#dialog-audit { max-width: 900px; width: 95vw; }
.audit-table-wrap { max-height: 55vh; overflow: auto; margin-bottom: 12px; }
.audit-table-wrap td { font-size: 12px; vertical-align: top; }
.audit-table-wrap td:last-child { word-break: break-word; color: #475569; }
.row-completed td { opacity: 0.55; }
.renew-note { display: block; font-size: 11px; color: #64748b; }
.import-errors { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }

.login-links { margin-top: 14px; font-size: 13px; text-align: center; }
.login-links a { color: var(--primary); text-decoration: none; }
.login-links a:hover { text-decoration: underline; }

/* ---- v6: ersätter inline-stilar (strikt CSP tillåter inga style-attribut) ---- */
.summary-title { display: inline; border: none; padding: 0; margin: 0; }
.auto-width { width: auto; }
.muted { font-size: 13px; color: #64748b; }
.subhead { font-size: 14px; }
.divider { margin: 20px 0; border: none; border-top: 1px solid #f1f5f9; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.nas-box { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; background: #f8fafc; }
.nas-box p { margin: 0 0 6px; }
.nas-box .nas-error { color: #b91c1c; }
.nas-box button { width: auto; }
.nas-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.nas-form { margin-top: 12px; border-top: 1px solid #e2e8f0; padding-top: 12px; }
.nas-form button[type="submit"], .nas-form #nas-cancel-btn { width: 100%; }
.nas-key { margin-top: 10px; padding: 10px; border: 1px solid #f59e0b; background: #fffbeb; border-radius: 8px; }
.nas-output { margin-top: 10px; white-space: pre-wrap; font-size: 12px; background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 6px; max-height: 240px; overflow: auto; }
.nas-advanced { margin-bottom: 12px; font-size: 13px; }
.nas-advanced summary { cursor: pointer; color: #475569; margin-bottom: 8px; }
.nas-row { display: flex; gap: 10px; }
.nas-grow { flex: 1; }
.nas-port { width: 90px; }
.nas-pubkey { width: 100%; font-family: monospace; font-size: 12px; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; background: #f1f5f9; resize: none; word-break: break-all; box-sizing: border-box; }
.nas-host-key { font-family: monospace; font-size: 11px; color: #475569; word-break: break-all; }
.strong-13 { font-size: 13px; font-weight: 600; }
.small-text { font-size: 12px; }
.passkey-list { list-style: none; padding: 0; margin: 8px 0 12px; }
.passkey-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.passkey-list .meta { color: #64748b; font-size: 12px; display: block; }
.passkey-list li { flex-wrap: wrap; }
.passkey-confirm { display: flex; gap: 6px; align-items: center; width: 100%; margin-top: 6px; }
.passkey-confirm input { flex: 1; min-width: 140px; padding: 6px 10px; font-size: 13px; }
.passkey-confirm.hidden { display: none; }
.restore-progress { font-size: 13px; color: #64748b; margin-top: 8px; }
