/* Projektets stilar. Färgerna styrs av variablerna i :root. Mobil: brytpunkt 760px. */

:root {
    --brand: #16395c;
    --brand-dark: #0a1c2e;
    --accent: #f5a524;
    --accent-text: #1a1a1a;
    --header-text: #ffffff;
    --link: #1d5c96;
    --text: #1c2733;
    --muted: #64748b;
    --bg: #f3f6f9;
    --surface: #ffffff;
    --border: #e5e7eb;
    --radius: 8px;
    --max-width: 1100px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    overflow-wrap: break-word;
}

a { color: var(--link); }

h1, h2, h3 { line-height: 1.25; }

img { max-width: 100%; height: auto; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Formulär */
form p { margin: 0 0 1rem; }

label { display: block; font-weight: 600; margin-bottom: 0.3rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], input[type="tel"], select, textarea {
    width: 100%;
    max-width: 420px;
    padding: 0.6rem 0.75rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button, .button {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    font: inherit;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}

button:hover, .button:hover { filter: brightness(1.08); }

.inline-form { display: inline; margin: 0; }

/* Tabeller rullar i sidled på mobil i stället för att spräcka sidan */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }

/* Meddelanden */
.flash { padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: var(--radius); }
.flash-success { background: #e6f4ea; color: #1e4620; }
.flash-error   { background: #fdecea; color: #611a15; }
.flash-info    { background: #e8f0fe; color: #0b3d91; }

/* Bilder */
.img-guard {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.img-guard img {
    display: block;
    max-width: 100%;
    height: auto;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.img-cover {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    background: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.img-guard, .img-guard *, a:has(.img-guard) {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Sidhuvud */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    color: var(--header-text);
    background:
        repeating-radial-gradient(circle at 100% 50%, transparent 0 22px, rgba(255, 255, 255, 0.035) 22px 24px),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-bottom: 3px solid var(--accent);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.6rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand-logo { width: 46px; height: 46px; flex-shrink: 0; }
.brand-logo img { width: 100%; height: 100%; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.06em; }
.brand-tagline { font-size: 0.8rem; letter-spacing: 0.04em; opacity: 0.75; }

.site-nav { display: flex; align-items: center; gap: 0.25rem; }

.site-nav a, .site-nav button {
    padding: 0.5rem 0.8rem;
    font: inherit;
    font-weight: 500;
    color: inherit;
    background: none;
    border: 0;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}

.site-nav a:hover, .site-nav button:hover { background: rgba(255, 255, 255, 0.12); filter: none; }
.site-nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }

.nav-user { padding: 0 0.5rem; font-size: 0.9rem; opacity: 0.8; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle-label { display: none; }

/* Innehåll */
.site-main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.site-footer a { color: var(--muted); }

.muted { color: var(--muted); font-size: 0.9rem; }

/* Under utveckling */
.dev-notice {
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: #1a1a1a;
    background: repeating-linear-gradient(-45deg, #f5a524 0 14px, #f7b64b 14px 28px);
}

/* Startsidan */
.hero {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 0 1rem;
}

.hero-logo { width: 110px; height: 110px; flex-shrink: 0; }
.hero-logo img { width: 100%; height: 100%; }
.hero h1 { margin: 0; font-size: 2.4rem; letter-spacing: 0.05em; }
.hero-lead { margin: 0.25rem 0 0; font-size: 1.15rem; color: var(--muted); }

.notice-box {
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
}

.notice-box h2 { margin-top: 0; }

/* Felsidor */
.error-page {
    max-width: 560px;
    margin: 2rem auto;
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 5px solid var(--accent);
    border-radius: var(--radius);
}

.error-page .error-code {
    margin: 0;
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.05em;
    color: var(--brand);
}

.error-page h1 { margin: 0.5rem 0; }
.error-page p { color: var(--muted); }

/* Löptext (t.ex. Om kakor) */
.prose { max-width: 760px; }
.prose code { padding: 0.1rem 0.35rem; background: var(--border); border-radius: 4px; }

/* Kort, rutnät och staplar */
.period-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }

.period-picker a {
    padding: 0.35rem 0.9rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.period-picker a.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); font-weight: 600; }

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
}

.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; color: var(--brand); }
.stat-sub { font-size: 0.85rem; color: var(--muted); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.stats-box {
    padding: 0.75rem 1rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stats-box h2 { margin: 0.25rem 0 0.5rem; font-size: 1.1rem; }

.stats-table { font-size: 0.9rem; background: var(--surface); }
.stats-table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stats-table td, .stats-table th { padding: 0.4rem 0.5rem; }
.stats-table .label-col { word-break: break-word; }
.stats-table .bar-col { width: 30%; min-width: 60px; }

.bar {
    display: block;
    height: 10px;
    min-width: 2px;
    background: linear-gradient(90deg, var(--brand), var(--link));
    border-radius: 5px;
}

/* Mobil */
@media (max-width: 760px) {
    .header-inner { flex-wrap: wrap; gap: 0.5rem; }

    .brand-logo { width: 38px; height: 38px; }
    .brand-name { font-size: 1.15rem; }

    .nav-toggle-label {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 6px;
        cursor: pointer;
    }

    .nav-toggle:focus-visible + .nav-toggle-label { outline: 2px solid var(--accent); }

    .burger, .burger::before, .burger::after {
        position: relative;
        display: block;
        width: 24px;
        height: 2px;
        background: currentColor;
        border-radius: 2px;
        transition: transform 0.2s, background 0.2s;
    }

    .burger::before, .burger::after { content: ""; position: absolute; left: 0; }
    .burger::before { top: -7px; }
    .burger::after { top: 7px; }

    .nav-toggle:checked + .nav-toggle-label .burger { background: transparent; }
    .nav-toggle:checked + .nav-toggle-label .burger::before { transform: translateY(7px) rotate(45deg); }
    .nav-toggle:checked + .nav-toggle-label .burger::after { transform: translateY(-7px) rotate(-45deg); }

    .site-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 0.25rem 0 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .nav-toggle:checked ~ .site-nav { display: flex; }

    .site-nav a, .site-nav button, .site-nav form { width: 100%; text-align: left; }
    .site-nav a, .site-nav button { padding: 0.75rem 0.5rem; }
    .site-nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
    .nav-user { padding: 0.5rem; }

    .site-main { padding: 1rem 1rem 2rem; }

    .hero { gap: 1rem; padding-top: 0.5rem; }
    .hero-logo { width: 72px; height: 72px; }
    .hero h1 { font-size: 1.8rem; }
    .hero-lead { font-size: 1rem; }

    .stats-grid { grid-template-columns: 1fr; }

    input[type="text"], input[type="email"], input[type="password"], input[type="number"],
    input[type="search"], input[type="url"], input[type="tel"], select, textarea { max-width: none; }
}
