/* FLYTTEN - mobil-först */

:root {
    --bg:        #0b1120;
    --bg-2:      #111a2e;
    --card:      #16203a;
    --card-2:    #1c2846;
    --line:      #263252;
    --text:      #e7ecf6;
    --muted:     #93a2c0;
    --dim:       #64748b;
    --accent:    #f59e0b;
    --accent-2:  #fbbf24;
    --blue:      #3b82f6;
    --green:     #10b981;
    --red:       #ef4444;
    --radius:    14px;
    --radius-sm: 10px;
    --shadow:    0 4px 18px rgba(0, 0, 0, .35);
    --topbar-h:  56px;
    --bottom-h:  62px;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom));
}

a { color: inherit; text-decoration: none; }

/* ---------- Ikoner ---------- */

/* Alla ikoner är SVG i currentColor. Standardstorlek passar brödtext;
   varje sammanhang nedan sätter sin egen storlek. */
.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -.18em;
}

/* Text + ikon på samma rad ska ligga i linje med jämnt mellanrum */
.meta span,
.meta a,
.btn,
.chip,
.badge,
.row .title,
.sidebar a,
details.acc > summary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.meta span, .meta a { gap: 4px; }
.row .title { display: block; }
.row .title .icon { vertical-align: -.16em; margin-right: 3px; }

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 12px;
    background: rgba(11, 17, 32, .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: -.01em;
    flex-shrink: 0;
}
.brand-mark { display: flex; color: var(--accent); }
.brand-mark .icon { width: 22px; height: 22px; }
.brand-text { display: none; }

.topsearch { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; }
.topsearch-ico {
    position: absolute;
    left: 12px;
    width: 15px;
    height: 15px;
    color: var(--dim);
    pointer-events: none;
}
/* input[type=search] i formulärblocket längre ned har samma specificitet och
   skulle annars vinna på källordning, därför attributväljaren även här */
.topsearch input[type=search] {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.topsearch input[type=search]:focus {
    outline: none;
    border-color: var(--accent);
}
.topsearch input[type=search]::placeholder { color: var(--dim); }

.topnav-more { display: flex; gap: 2px; }
.topnav-more a {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    opacity: .75;
}
.topnav-more .icon { width: 18px; height: 18px; }
.topnav-more a.active { background: var(--card-2); opacity: 1; }

/* ---------- Skal ---------- */

.shell { display: block; }
.sidebar { display: none; }

.main {
    padding: 16px 12px 24px;
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------- Bottennav (mobil) ---------- */

.bottomnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(17, 26, 46, .96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
}
.bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--dim);
    font-size: 10.5px;
    font-weight: 600;
}
.bottomnav a .icon { width: 21px; height: 21px; }
.bottomnav a.active { color: var(--accent); }

/* ---------- Rubriker ---------- */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
}
.page-head h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -.02em;
}
.page-head .sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

h2.section {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin: 24px 0 10px;
    font-weight: 700;
}
h2.section:first-child { margin-top: 0; }

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }

.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Statistikbrickor */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}
.stat .n {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.1;
}
.stat .l {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}
.stat.accent .n { color: var(--accent); }
.stat.red .n    { color: var(--red); }
.stat.green .n  { color: var(--green); }
.stat.blue .n   { color: var(--blue); }

/* Nedräkning */
.countdown {
    background: linear-gradient(135deg, #7c3a02, #b45309);
    border: 1px solid #d97706;
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    margin-bottom: 14px;
}
.countdown .big {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
}
.countdown .lbl { color: #fde9c8; font-size: 13px; margin-top: 4px; }

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

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
}
.row.clickable:active { background: var(--card-2); }
.row .body { flex: 1; min-width: 0; }
.row .title {
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}
.row .meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}
.row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.row.done .title { text-decoration: line-through; opacity: .5; }
.row.overdue { border-left-color: var(--red); }

/* Kryssruta för uppgifter */
.check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border: 2px solid var(--dim);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: transparent;
    font-size: 13px;
    padding: 0;
    transition: all .12s;
}
.check:hover { border-color: var(--green); }
.check.on {
    background: var(--green);
    border-color: var(--green);
    color: #04120c;
}
/* Bocken finns alltid i DOM:en; bara synlig när kryssrutan är ikryssad */
.check .icon {
    width: 14px;
    height: 14px;
    stroke-width: 3;
    opacity: 0;
    transition: opacity .12s;
}
.check.on .icon { opacity: 1; }

/* ---------- Brickor ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .01em;
    gap: 4px;
    color: var(--c, var(--muted));
    background: color-mix(in srgb, var(--c, #64748b) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, #64748b) 35%, transparent);
    white-space: nowrap;
}
.badge.solid { color: #0b1120; background: var(--c); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}
.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1204;
}

.chips {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

/* ---------- Knappar ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--card-2);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 15px; height: 15px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-icon .icon { width: 15px; height: 15px; }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1204;
}
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-icon {
    width: 30px;
    gap: 0;
    padding: 0;
    font-size: 14px;
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}
.btn-icon:hover { background: var(--card-2); color: var(--text); }
.btn-danger { color: var(--red); }

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

.field { margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=email], input[type=tel], input[type=url],
input[type=search], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text);
    font-family: inherit;
    font-size: 16px; /* 16px hindrar iOS från att zooma */
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2393a2c0' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 10px;
}
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Ikon- och färgväljare ---------- */

.iconpicker, .colorpicker {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.iconpicker input, .colorpicker input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.iconpicker span {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--muted);
    cursor: pointer;
}
.iconpicker span .icon { width: 19px; height: 19px; }
.iconpicker label:hover span { border-color: var(--muted); color: var(--text); }
.iconpicker input:checked + span {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-2));
    color: var(--accent);
}

.colorpicker span {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--line);
    cursor: pointer;
}
.colorpicker input:checked + span {
    border-color: var(--bg-2);
    box-shadow: 0 0 0 2px var(--text);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ---------- Modal ---------- */

.modal-bg {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(3, 7, 18, .7);
    backdrop-filter: blur(3px);
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal-bg.open { display: flex; }

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
    animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(20px); opacity: .5; } }

.modal h3 {
    margin: 0 0 14px;
    font-size: 17px;
    letter-spacing: -.01em;
}

/* ---------- Kalender ---------- */

.cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cal-head .month {
    font-size: 17px;
    font-weight: 700;
    text-transform: capitalize;
}

.cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.cal .dow {
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    padding-bottom: 4px;
}
.cal .day {
    border-radius: 9px;
    background: var(--card);
    border: 1px solid var(--line);
    padding: 4px 3px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    min-height: 56px;
    overflow: hidden;
}
/* Rutnätets radhöjd styrs av den högsta rutan i raden, så en vecka helt utan
   poster blir kompakt medan veckor med innehåll får plats för två chip */
.cal .day.has-events { min-height: 94px; }
.cal .day.out { opacity: .3; min-height: 0; }
.cal .day.today {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--card));
}
.cal .day .n { font-weight: 700; font-size: 12px; padding-left: 1px; }
.cal .day.today .n { color: var(--accent); }

/* Vad som händer den dagen — tid och titel, avkortat med ellips */
.cal .evs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
/* Mobilrutan är bara ~44px bred, så tiden får en egen rad ovanför titeln.
   Ligger de på samma rad kapas även klockslaget, vilket gör chippet oläsbart. */
.cal .ev {
    display: block;
    font-size: 9.5px;
    line-height: 1.35;
    padding: 1px 2px 2px 4px;
    border-left: 2px solid var(--c, var(--blue));
    border-radius: 0 3px 3px 0;
    background: color-mix(in srgb, var(--c, var(--blue)) 18%, transparent);
    color: var(--text);
    min-width: 0;
}
.cal .ev b {
    display: block;
    color: var(--c, var(--blue));
    font-weight: 700;
    letter-spacing: -.02em;
}
.cal .ev i {
    display: block;
    font-style: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal .ev.more {
    border-left-color: transparent;
    background: transparent;
    color: var(--dim);
    font-weight: 600;
    padding-left: 4px;
}

/* ---------- Diverse ---------- */

.empty {
    text-align: center;
    padding: 34px 16px;
    color: var(--dim);
}
.empty .icon {
    width: 34px;
    height: 34px;
    display: block;
    margin: 0 auto 10px;
    opacity: .45;
    stroke-width: 1.4;
}

.flashes { margin-bottom: 12px; }
.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 8px;
}
.flash-ok  { background: color-mix(in srgb, var(--green) 18%, transparent); color: #6ee7b7; border: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.flash-err { background: color-mix(in srgb, var(--red) 18%, transparent);   color: #fca5a5; border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }

.muted { color: var(--muted); }
.dim   { color: var(--dim); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Stor logotyp på inloggnings- och installationssidan */
.brand-big { color: var(--accent); }
.brand-big .icon { width: 46px; height: 46px; stroke-width: 1.5; }

/* Lådikonen i kalenderrutan för flyttdagen */
.cal-move { width: 11px; height: 11px; color: var(--accent); }

.fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 14px);
    z-index: 55;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1204;
    border: none;
    font-size: 27px;
    font-weight: 300;
    line-height: 1;
    box-shadow: 0 6px 20px rgba(245, 158, 11, .4);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.progress {
    height: 7px;
    border-radius: 999px;
    background: var(--bg-2);
    overflow: hidden;
    border: 1px solid var(--line);
}
.progress > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

details.acc > summary {
    cursor: pointer;
    font-weight: 600;
    padding: 4px 0;
    list-style: none;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: '▸ '; color: var(--muted); }
details.acc[open] > summary::before { content: '▾ '; }

/* ---------- Desktop ---------- */

@media (min-width: 860px) {
    body { padding-bottom: 0; }
    .brand-text { display: inline; }
    .bottomnav { display: none; }
    .topnav-more { display: none; }

    .shell {
        display: grid;
        grid-template-columns: 216px 1fr;
        max-width: 1280px;
        margin: 0 auto;
        gap: 0;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 18px 10px;
        position: sticky;
        top: var(--topbar-h);
        align-self: start;
        height: calc(100vh - var(--topbar-h));
        border-right: 1px solid var(--line);
    }
    .sidebar a {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 9px 12px;
        border-radius: var(--radius-sm);
        color: var(--muted);
        font-size: 14px;
        font-weight: 600;
    }
    .sidebar a:hover { background: var(--card); color: var(--text); }
    .sidebar a.active { background: var(--card-2); color: var(--accent); }
    .sidebar a .icon { width: 18px; height: 18px; }
    .sidebar a.muted { margin-top: auto; }

    /* .main är grid-item här; margin:auto skulle upphäva stretch och krympa kolumnen */
    .main {
        padding: 22px 24px 40px;
        margin: 0;
        max-width: none;
        width: 100%;
    }
    .stats { grid-template-columns: repeat(4, 1fr); }
    .page-head h1 { font-size: 26px; }
    .cal .day { min-height: 64px; font-size: 13px; padding: 5px 4px; }
    .cal .day.has-events { min-height: 104px; }
    .cal .day .n { font-size: 13px; }
    /* Här finns ~145px bredd, så tid och titel får plats på samma rad */
    .cal .ev {
        display: flex;
        gap: 4px;
        font-size: 11px;
        padding: 2px 4px 2px 5px;
    }
    .cal .ev b { display: inline; flex-shrink: 0; }

    .modal-bg { align-items: center; }
    .modal { border-radius: 18px; padding: 22px; }

    .fab { display: none; }
}

@media (min-width: 560px) and (max-width: 859px) {
    .stats { grid-template-columns: repeat(4, 1fr); }
}
