/* =========================================================
   Battman – stilmall (samma grund som familj- och nyheter.lavenius.se)
   Tokens (ljust/mörkt) → bas → layout → komponenter → batterier → mobil
   ========================================================= */

:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --card: #ffffff;
    --surface: #fbfcfe;
    --surface-2: #eef1f6;
    --input-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.94);
    --text: #172033;
    --muted: #697386;
    --line: #dfe3ea;
    --primary: #a16207;
    --primary-dark: #854d0e;
    --on-primary: #ffffff;
    --accent: #fef3c7;
    --shadow: 0 10px 28px rgba(23, 32, 51, 0.06);

    --warn: #f59e0b;
    --warn-bg: #fffbeb;
    --warn-line: #fcd34d;
    --warn-text: #92400e;
    --ok: #22c55e;
    --ok-bg: #ecfdf3;
    --ok-line: #bbf7d0;
    --ok-text: #166534;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-line: #fecaca;
    --danger-text: #b91c1c;

    --radius: 16px;
    --radius-sm: 10px;
    --gap: 1rem;
    --pad: 1.25rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f141b;
        --card: #171e28;
        --surface: #1b2330;
        --surface-2: #232d3b;
        --input-bg: #121821;
        --header-bg: rgba(20, 27, 37, 0.94);
        --text: #e6ebf2;
        --muted: #95a1b4;
        --line: #2b3646;
        --primary: #fbbf24;
        --primary-dark: #fcd34d;
        --on-primary: #1c1400;
        --accent: #2a2310;
        --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
        --warn-bg: #2a2214;
        --warn-line: #6b5518;
        --warn-text: #fcd34d;
        --ok-bg: #11291c;
        --ok-line: #1f5133;
        --ok-text: #4ade80;
        --danger: #ef4444;
        --danger-bg: #2a1416;
        --danger-line: #5b2226;
        --danger-text: #f87171;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f141b;
    --card: #171e28;
    --surface: #1b2330;
    --surface-2: #232d3b;
    --input-bg: #121821;
    --header-bg: rgba(20, 27, 37, 0.94);
    --text: #e6ebf2;
    --muted: #95a1b4;
    --line: #2b3646;
    --primary: #fbbf24;
    --primary-dark: #fcd34d;
    --on-primary: #1c1400;
    --accent: #2a2310;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    --warn-bg: #2a2214;
    --warn-line: #6b5518;
    --warn-text: #fcd34d;
    --ok-bg: #11291c;
    --ok-line: #1f5133;
    --ok-text: #4ade80;
    --danger: #ef4444;
    --danger-bg: #2a1416;
    --danger-line: #5b2226;
    --danger-text: #f87171;
}

/* ---------- Bas ---------- */

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.75rem; line-height: 1.2; }
h2 { margin-bottom: 0.75rem; font-size: 1.2rem; line-height: 1.25; }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

input, select, textarea, button { font: inherit; }

input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
    background: var(--input-bg);
    color: var(--text);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select { height: 44px; min-height: 44px; line-height: 1.3; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 0;
    border-color: var(--primary);
}

select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 2.4rem;
    background-color: var(--input-bg);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 1.15rem) 50%, calc(100% - 0.8rem) 50%;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
    background-repeat: no-repeat;
    cursor: pointer;
    text-overflow: ellipsis;
}

input[type="range"] { min-height: 0; height: 32px; padding: 0; border: 0; background: transparent; accent-color: var(--primary); }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--on-primary);
    cursor: pointer;
    font-weight: 650;
    white-space: nowrap;
}

button:hover, .button:hover { background: var(--primary-dark); color: var(--on-primary); }
button:disabled { opacity: 0.6; cursor: progress; }

.button.secondary, button.secondary { background: var(--surface-2); color: var(--text); }
.button.secondary:hover, button.secondary:hover { background: var(--line); color: var(--text); }

.button.danger, button.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger-text); }
.button.danger:hover, button.danger:hover { background: var(--danger); color: #fff; }

.icon-button {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
}
.icon-button:hover { background: var(--surface-2); color: var(--danger-text); }

.link-button {
    min-height: 0;
    padding: 0;
    background: none;
    color: var(--primary);
    font-weight: 700;
}
.link-button:hover { background: none; color: var(--primary-dark); text-decoration: underline; }

label {
    display: grid;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 650;
}

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small-note { margin: 0.6rem 0 0; font-size: 0.85rem; }

/* ---------- Layout ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; font-weight: 800; color: var(--text); }

.main-nav { display: flex; flex: 1; align-items: center; gap: 0.25rem; }
.main-nav > a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 650;
    white-space: nowrap;
}
.main-nav > a:hover { color: var(--text); background: var(--surface-2); }
.main-nav > a.active { color: var(--primary); background: var(--accent); }

.nav-count {
    min-width: 1.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.35rem;
    text-align: center;
}

.who { display: inline-flex; align-items: center; gap: 0.45rem; margin-left: auto; color: var(--muted); font-weight: 650; white-space: nowrap; }

.container { width: min(860px, calc(100% - 2rem)); margin: 1.75rem auto 3rem; padding-bottom: env(safe-area-inset-bottom); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-heading form { margin: 0; }
.heading-meta { text-align: right; }
.heading-meta span { display: block; color: var(--muted); font-size: 0.8rem; }
.heading-meta strong { font-size: 1.15rem; }
.heading-sub { margin: 0.2rem 0 0; font-size: 0.9rem; }

.eyebrow {
    margin: 0 0 0.15rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.eyebrow a { color: inherit; }

/* ---------- Kort ---------- */

.auth-card, .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card { max-width: 430px; margin: 10vh auto; padding: 2rem; }
.auth-card h1 { margin-bottom: 1rem; }
.auth-logo { display: block; margin-bottom: 1rem; border-radius: 14px; }

.card { margin-bottom: var(--gap); padding: var(--pad); }
.card > :last-child { margin-bottom: 0; }

.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.85rem; }
.card-header h2 { margin-bottom: 0; }
.card-header.padded { padding: 0.6rem 0.75rem 0; }

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: var(--gap);
    border-radius: 12px;
    padding: 0.7rem 1rem;
    background: var(--ok-bg);
    border: 1px solid var(--ok-line);
    color: var(--ok-text);
}
.flash form { margin: 0; }
.flash .link-button { color: var(--ok-text); }

.empty-state { margin: 0.75rem 0 1rem; color: var(--muted); text-align: center; }
.empty-card { text-align: center; padding: 2rem var(--pad); }
.big-emoji { margin: 0 0 0.5rem; font-size: 2.5rem; }

/* ---------- Formulär ---------- */

.form-stack, .form-grid, .inline-form { display: grid; gap: 0.85rem; }
.form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.form-grid .wide { grid-column: span 2; }
.inline-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; max-width: 560px; }
.inline-form.compact { gap: 0.4rem; max-width: none; }
.inline-form.compact input { height: 40px; min-height: 40px; }

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    padding: 0.2rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}
.segmented button, .segmented .segment span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.35rem 0.9rem;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}
.segmented button:hover, .segmented .segment span:hover { background: var(--surface-2); color: var(--text); }
.segmented button.active, .segmented .segment input:checked + span { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.segmented .segment { display: inline-flex; }
.segmented .segment input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; pointer-events: none; }
.segmented .segment input:focus-visible + span { outline: 2px solid var(--primary); }

.cron-info summary { color: var(--muted); font-size: 0.9rem; font-weight: 650; cursor: pointer; margin-top: 0.6rem; }
.cron-info input { margin-top: 0.5rem; }
input.mono { font-size: 0.8rem; }

/* ---------- Flikar ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.85rem; }
.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    background: var(--card);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tabs .count {
    min-width: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}
.tabs a.active .count { background: rgba(255, 255, 255, 0.25); color: inherit; }

.tab-bar { display: none; }

/* ---------- Listor ---------- */

.list-card { padding: 0.5rem; }
.item-list { display: grid; margin: 0; padding: 0; list-style: none; }
.item-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.6rem;
    align-items: center;
    min-height: 52px;
    padding: 0.5rem 0.4rem 0.5rem 0.6rem;
    border-radius: 12px;
}
.item-row + .item-row { border-top: 1px solid var(--line); border-radius: 0; }
.item-main { display: grid; gap: 0.1rem; min-width: 0; }
.item-title { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.35rem; font-size: 0.8rem; }
.item-actions { display: flex; align-items: center; gap: 0.15rem; }
.item-row form { margin: 0; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.8rem;
    font-weight: 800;
    flex-shrink: 0;
}
.avatar.small { width: 1.3rem; height: 1.3rem; font-size: 0.62rem; background: transparent; }

.role-badge { display: inline-flex; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 650; }
.role-badge.role-admin { background: var(--accent); color: var(--primary); }

.pill {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 650;
    vertical-align: middle;
}

.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.danger-zone p { margin: 0; font-size: 0.85rem; }

/* ---------- MCP-token ---------- */

.token-reveal {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--warn-line);
    border-radius: 12px;
    background: var(--warn-bg);
    color: var(--warn-text);
}
.token-reveal p { margin: 0; }
.token-reveal input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.token-list { margin: 0.75rem 0; border: 1px solid var(--line); border-radius: 12px; }
.token-list button.danger { min-height: 34px; padding: 0.25rem 0.75rem; font-size: 0.85rem; }
.token-create { margin-top: 0.85rem; }

/* ---------- Notiser ---------- */

.push-device { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.push-status { margin: 0; }
.push-status.is-ok { color: var(--ok-text); }
.push-status.is-warn { color: var(--warn-text); }
.push-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.push-devices { margin-bottom: 1.25rem; }

.notify-form { display: grid; gap: 1rem; }
.notify-form > button { justify-self: start; }
.notify-group { display: grid; gap: 0.6rem; min-width: 0; margin: 0; padding: 0.85rem 1rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.notify-group legend { padding: 0 0.35rem; font-weight: 700; }
.notify-group .small-note { margin: 0 0 0.15rem; }
.notify-grid { grid-template-columns: 10rem minmax(0, 1fr); }
.notify-grid .wide { grid-column: auto; }

label.check { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-size: 0.95rem; font-weight: 500; cursor: pointer; }
label.check input { flex: none; width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); }

/* =========================================================
   Batterier
   ========================================================= */

.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.85rem; }
.summary-item {
    display: grid;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
}
.summary-item strong { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-item span { color: var(--muted); font-size: 0.8rem; font-weight: 650; }
.summary-item.is-due:not(.is-zero) { border-color: var(--danger-line); background: var(--danger-bg); }
.summary-item.is-due:not(.is-zero) strong { color: var(--danger-text); }
.summary-item.is-soon:not(.is-zero) strong { color: var(--warn-text); }
.summary-item.is-ok strong { color: var(--ok-text); }
.summary-item.is-zero strong { color: var(--muted); }
a.summary-item { color: inherit; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
a.summary-item:hover { border-color: var(--muted); }
.summary-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }

.bat-list {
    overflow: hidden;
    margin-bottom: var(--gap);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.bat-card {
    --status: var(--ok);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0.85rem 0.7rem 0.75rem;
    border-left: 4px solid transparent;
}
.bat-card + .bat-card { border-top: 1px solid var(--line); }
.bat-card.status-due { --status: var(--danger); border-left-color: var(--danger); }
.bat-card.status-unknown { --status: var(--muted); border-left-color: var(--warn); }
.bat-card.status-soon { --status: var(--warn); }
.bat-card.status-retired { --status: var(--line); opacity: 0.7; }

.bat-link { display: flex; align-items: center; gap: 0.85rem; min-width: 0; color: var(--text); }
.bat-main { display: grid; gap: 0.05rem; min-width: 0; }
.bat-name { font-weight: 700; overflow-wrap: anywhere; }
.bat-meta { color: var(--muted); font-size: 0.8rem; }
.bat-due { color: var(--muted); font-size: 0.85rem; }
.status-due .bat-due { color: var(--danger-text); font-weight: 600; }
.status-unknown .bat-due { color: var(--warn-text); }

a.gauge.is-action { margin: -0.35rem 0; padding: 0.35rem 0.2rem; border-radius: 10px; color: inherit; cursor: pointer; transition: background 0.15s ease, transform 0.1s ease; }
a.gauge.is-action:hover { background: var(--surface-2); }
a.gauge.is-action:active { transform: scale(0.94); }

/* Dialog: registrera laddning */
.log-dialog {
    width: min(30rem, calc(100% - 1.5rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.log-dialog::backdrop { background: rgba(15, 20, 27, 0.45); }
.log-dialog form { padding: var(--pad); }
.log-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.log-dialog-head h2 { margin: 0; overflow-wrap: anywhere; }
.log-dialog .kind-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.log-dialog .kind-picker .segment span { width: 100%; justify-content: center; }
.log-dialog .log-form > button { justify-self: stretch; min-height: 46px; }
.log-more summary { color: var(--muted); font-size: 0.9rem; font-weight: 650; cursor: pointer; }
.log-more .log-extra { margin-top: 0.6rem; grid-template-columns: minmax(0, 1fr); }
.quick-button { min-height: 34px; padding: 0.3rem 0.65rem; font-size: 0.85rem; }

/* Liggande batteri som nivåmätare */
.gauge { display: grid; justify-items: center; gap: 0.15rem; flex: none; width: 3.4rem; }
.gauge-body, .hero-gauge .gauge-body {
    position: relative;
    display: block;
    width: 44px;
    height: 22px;
    border: 2px solid var(--muted);
    border-radius: 5px;
    padding: 2px;
}
.gauge-body::after {
    content: '';
    position: absolute;
    top: 5px;
    right: -6px;
    width: 3px;
    height: 8px;
    border-radius: 0 2px 2px 0;
    background: var(--muted);
}
.gauge-fill {
    display: block;
    width: calc(var(--lvl, 0) * 1%);
    min-width: 2px;
    height: 100%;
    border-radius: 2px;
    background: var(--status, var(--ok));
    transition: width 0.3s ease;
}
.status-unknown .gauge-fill { width: 0; }
.gauge-text { color: var(--muted); font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status-due .gauge-text { color: var(--danger-text); }
.is-critical .gauge-body { border-color: var(--danger); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { border-color: var(--line); } }

.status-pill {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0.02rem 0.5rem;
    border-radius: 999px;
    background: var(--ok-bg);
    color: var(--ok-text);
    font-size: 0.7rem;
    font-weight: 750;
    vertical-align: 0.1em;
}
.status-pill.status-due { background: var(--danger-bg); color: var(--danger-text); }
.status-pill.status-unknown, .status-pill.status-soon { background: var(--warn-bg); color: var(--warn-text); }
.status-pill.status-retired { background: var(--surface-2); color: var(--muted); }
.bat-hero .status-pill { margin-left: 0; margin-bottom: 0.4rem; }

.bat-card.status-draft { --status: var(--muted); }
.status-pill.status-draft { background: var(--surface-2); color: var(--muted); }
.bat-hero.status-draft { --status: var(--muted); }
.bat-hero form { margin-top: 0.5rem; }

.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.section-title { margin: 1.25rem 0 0.1rem; font-size: 1.05rem; }
.section-note { margin: 0 0 0.6rem; }

.bulk-lines { min-height: 16rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; line-height: 1.6; }
.bulk-help { margin: 0.25rem 0 0.75rem; padding-left: 1.1rem; color: var(--muted); font-size: 0.875rem; }
.bulk-help code { color: var(--text); }
.bulk-preview { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.875rem; }
.bulk-preview strong { color: var(--text); }

.retired-box summary { margin: 0.5rem 0 0.75rem; color: var(--muted); font-weight: 650; cursor: pointer; }

.preset-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1rem; }

/* Batterisidan */
.bat-hero { --status: var(--ok); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.bat-hero.status-due { --status: var(--danger); border-color: var(--danger-line); }
.bat-hero.status-soon { --status: var(--warn); }
.bat-hero.status-unknown { --status: var(--muted); border-color: var(--warn-line); }
.hero-gauge { display: grid; justify-items: center; gap: 0.2rem; min-width: 6rem; }
.hero-gauge .gauge-body { width: 84px; height: 40px; border-width: 3px; border-radius: 8px; padding: 3px; }
.hero-gauge .gauge-body::after { top: 11px; right: -8px; width: 5px; height: 12px; }
.hero-gauge strong { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-gauge .muted { font-size: 0.75rem; }
.hero-main p { margin-bottom: 0.25rem; }
.hero-action strong { font-size: 1.05rem; }

.log-form { display: grid; gap: 0.85rem; }
.log-form > button { justify-self: start; }
.kind-picker { display: flex; }
.level-field span { color: var(--text); font-size: 0.95rem; }
.level-field output { font-weight: 800; font-variant-numeric: tabular-nums; }
.log-extra { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 0.85rem; }

.forecast { display: block; width: 100%; height: auto; }
.forecast .grid { stroke: var(--line); stroke-width: 1; }
.forecast .axis { fill: var(--muted); font-size: 11px; }
.forecast .min-line { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.forecast .min-label { fill: var(--danger-text); }
.forecast .curve { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.forecast .now-line { stroke: var(--text); stroke-width: 1; opacity: 0.4; }

.reason-date { min-width: 5.5rem; color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.event-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.8rem;
    height: 1.8rem;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}
.event-row.kind-full .event-level { background: var(--ok-bg); color: var(--ok-text); }
.event-row.kind-used .event-level { background: var(--warn-bg); color: var(--warn-text); }
.event-row.kind-storage .event-level { background: var(--accent); color: var(--primary); }

.notes { margin: 0; white-space: normal; }

.battery-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; }
.battery-actions form { margin: 0; }
.battery-actions .inline-form { flex: 1 1 18rem; }

.battery-form .preset-pick { margin-bottom: 0.85rem; max-width: 26rem; }
.form-actions { display: flex; gap: 0.5rem; margin-bottom: 2rem; }

/* Dator: batterierna i två kolumner, bredare sida */
@media (min-width: 901px) {
    .container:has(.bat-list) { width: min(1200px, calc(100% - 3rem)); }
    .bat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; overflow: visible; background: transparent; border: 0; box-shadow: none; }
    .bat-card { border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
    .bat-card.status-due { border-left: 4px solid var(--danger); }
    .bat-card.status-unknown { border-left: 4px solid var(--warn); }
    .bat-list .empty-state { grid-column: 1 / -1; }
}

/* =========================================================
   Mobil
   ========================================================= */

@media (max-width: 900px) {
    :root { --gap: 0.65rem; --pad: 0.85rem; --radius: 14px; }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.08rem; margin-bottom: 0.6rem; }

    .container { width: calc(100% - 1.25rem); margin: 0.85rem auto 2rem; }

    .page-heading { align-items: center; margin-bottom: 0.65rem; }
    .page-heading .button { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.85rem; }

    .card, .bat-list { box-shadow: none; }

    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .form-grid .wide, .form-grid > button { grid-column: 1 / -1; }
    .notify-grid { grid-template-columns: minmax(0, 1fr); }
    .inline-form { grid-template-columns: 1fr; }
    .inline-form.compact { grid-template-columns: minmax(0, 1fr) auto; }
    .log-extra { grid-template-columns: minmax(0, 1fr); }

    input, select, textarea { font-size: 16px; } /* förhindrar iOS-zoom */

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-left: -0.625rem;
        margin-right: -0.625rem;
        padding: 0 0.625rem 0.1rem;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { flex: 0 0 auto; }

    /* App-känsla: ingen toppmeny, flikrad längst ned */
    .has-user .site-header { display: none; }
    .has-user .container { margin-top: max(0.85rem, env(safe-area-inset-top)); padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
    .tab-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        padding: 0.3rem 0.25rem max(0.35rem, env(safe-area-inset-bottom));
        background: var(--header-bg);
        border-top: 1px solid var(--line);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
    .tab-bar a { display: grid; justify-items: center; gap: 0.1rem; padding: 0.2rem 0; color: var(--muted); font-size: 0.68rem; font-weight: 650; }
    .tab-bar a.active { color: var(--primary); }
    .tab-icon { position: relative; display: block; width: 26px; height: 26px; }
    .tab-icon svg { width: 26px; height: 26px; }
    .tab-badge {
        position: absolute;
        top: -4px;
        left: 17px;
        min-width: 1.15rem;
        padding: 0 0.3rem;
        border-radius: 999px;
        background: var(--danger);
        color: #fff;
        font-size: 0.66rem;
        font-weight: 800;
        line-height: 1.15rem;
        text-align: center;
    }

    .summary-item { padding: 0.5rem 0.65rem; }
    .summary-item strong { font-size: 1.35rem; }

    .bat-list { margin-left: -0.625rem; margin-right: -0.625rem; border-left: 0; border-right: 0; border-radius: 0; }
    .bat-card { gap: 0.6rem; padding: 0.7rem 0.75rem 0.75rem 0.5rem; }

    .log-dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
    .log-dialog form { padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom)); }

    .bat-hero { gap: 0.85rem; }
    .hero-gauge { min-width: 5rem; }
    .hero-gauge .gauge-body { width: 64px; height: 32px; }
    .hero-gauge .gauge-body::after { top: 8px; height: 10px; }
    .hero-gauge strong { font-size: 1.3rem; }

    .kind-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kind-picker .segment span { width: 100%; justify-content: center; }
    .kind-picker .segment:first-child { grid-column: 1 / -1; }

    .list-card { padding: 0.25rem 0.35rem; }
    .user-row { grid-template-columns: auto minmax(0, 1fr); }
    .user-row .item-actions { grid-column: 2; }

    .danger-zone { align-items: flex-start; flex-direction: column; }
    .segmented:not(.kind-picker) { display: flex; }
    .segmented:not(.kind-picker) button, .segmented:not(.kind-picker) .segment { flex: 1; justify-content: center; }
    .form-actions button, .form-actions .button { flex: 1; }
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; font-weight: 400; }
