/* EasyProject – grundstil. Inga externa beroenden, så att appen fungerar on prem utan internet. */

:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --surface-2: #f0f1ee;
    --border: #dfe1dc;
    --text: #1f2421;
    --text-2: #5d6560;
    --accent: #1d6b57;
    --accent-2: #e5f0ec;
    --warn: #a86500;
    --warn-bg: #fdf1dc;
    --critical: #b42318;
    --critical-bg: #fde8e6;
    --ok: #1d6b57;
    --nav-bg: #1b2420;
    --nav-text: #c9d1cc;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(20, 30, 25, .06);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

    /* Färger som tidigare var hårdkodade – egna tokens så att mörkt tema kan byta dem. */
    --accent-solid: #1d6b57;        /* bakgrund med vit text (knappar, bubblor) */
    --accent-solid-hover: #175a49;
    --on-accent: #ffffff;
    --row-hover: #fafbf9;
    --info: #2f5596;
    --info-bg: #e8eef7;
    --done: #3c5a4b;
    --done-bg: #e6eee9;
    --backdrop: rgba(15, 20, 18, .45);
    --dialog-shadow: 0 12px 40px rgba(0,0,0,.2);
    --preview-bg: #fcfcfb;
    --hint-text: #5c3b00;
    --hint-code-bg: rgba(255,255,255,.6);
    --plan-today: #f6fbf9;
    --plan-hover: #f9faf8;
    --heat-low: #eef5f2;
    --heat-mid: #cfe6dc;
    --heat-full: #9fcfb9;
    --offer-created: #9fb5d6;
    --offer-lost: #d99a8f;
    color-scheme: light;
}

/* ---------- Mörkt tema ----------
   Väljs med data-theme="dark" på <html>, eller följer enheten när inget val är gjort
   (data-theme saknas eller är "system"). Gäller bara skärm – utskrifter blir alltid ljusa. */

@media screen {
    :root[data-theme="dark"] {
        --bg: #111513;
        --surface: #191e1b;
        --surface-2: #222925;
        --border: #313a35;
        --text: #e3e8e5;
        --text-2: #9ba59f;
        --accent: #4fb89b;
        --accent-2: #1b3830;
        --warn: #e3a84f;
        --warn-bg: #3a2c14;
        --critical: #f2837a;
        --critical-bg: #3d1e1b;
        --ok: #4fb89b;
        --nav-bg: #0c0f0d;
        --nav-text: #b9c3bd;
        --shadow: 0 1px 2px rgba(0, 0, 0, .45);
        --accent-solid: #22806a;
        --accent-solid-hover: #2a937a;
        --on-accent: #ffffff;
        --row-hover: #1e2421;
        --info: #8eb0e8;
        --info-bg: #1e2b42;
        --done: #a6c2b3;
        --done-bg: #20302a;
        --backdrop: rgba(0, 0, 0, .6);
        --dialog-shadow: 0 12px 40px rgba(0,0,0,.6);
        --preview-bg: #151a17;
        --hint-text: #f0cb8e;
        --hint-code-bg: rgba(0,0,0,.3);
        --plan-today: #172c26;
        --plan-hover: #1e2421;
        --heat-low: #19302a;
        --heat-mid: #1f4a3c;
        --heat-full: #2b6b56;
        --offer-created: #6f88b0;
        --offer-lost: #bb7a6f;
        color-scheme: dark;
    }
    :root[data-theme="dark"] .c0 { --c: #9aa7e0; --c-bg: #262b45; }
    :root[data-theme="dark"] .c1 { --c: #5cb8a2; --c-bg: #1a332d; }
    :root[data-theme="dark"] .c2 { --c: #7ea6e3; --c-bg: #1c2a40; }
    :root[data-theme="dark"] .c3 { --c: #e0a850; --c-bg: #392c16; }
    :root[data-theme="dark"] .c4 { --c: #c290d8; --c-bg: #31233a; }
    :root[data-theme="dark"] .c5 { --c: #e9876f; --c-bg: #3b231d; }
    :root[data-theme="dark"] .c6 { --c: #8cc472; --c-bg: #213219; }
    :root[data-theme="dark"] .c7 { --c: #62bfd2; --c-bg: #17313a; }
    :root[data-theme="dark"] .c8 { --c: #bba68f; --c-bg: #2f2a24; }
}

@media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg: #111513;
        --surface: #191e1b;
        --surface-2: #222925;
        --border: #313a35;
        --text: #e3e8e5;
        --text-2: #9ba59f;
        --accent: #4fb89b;
        --accent-2: #1b3830;
        --warn: #e3a84f;
        --warn-bg: #3a2c14;
        --critical: #f2837a;
        --critical-bg: #3d1e1b;
        --ok: #4fb89b;
        --nav-bg: #0c0f0d;
        --nav-text: #b9c3bd;
        --shadow: 0 1px 2px rgba(0, 0, 0, .45);
        --accent-solid: #22806a;
        --accent-solid-hover: #2a937a;
        --on-accent: #ffffff;
        --row-hover: #1e2421;
        --info: #8eb0e8;
        --info-bg: #1e2b42;
        --done: #a6c2b3;
        --done-bg: #20302a;
        --backdrop: rgba(0, 0, 0, .6);
        --dialog-shadow: 0 12px 40px rgba(0,0,0,.6);
        --preview-bg: #151a17;
        --hint-text: #f0cb8e;
        --hint-code-bg: rgba(0,0,0,.3);
        --plan-today: #172c26;
        --plan-hover: #1e2421;
        --heat-low: #19302a;
        --heat-mid: #1f4a3c;
        --heat-full: #2b6b56;
        --offer-created: #6f88b0;
        --offer-lost: #bb7a6f;
        color-scheme: dark;
    }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c0 { --c: #9aa7e0; --c-bg: #262b45; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c1 { --c: #5cb8a2; --c-bg: #1a332d; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c2 { --c: #7ea6e3; --c-bg: #1c2a40; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c3 { --c: #e0a850; --c-bg: #392c16; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c4 { --c: #c290d8; --c-bg: #31233a; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c5 { --c: #e9876f; --c-bg: #3b231d; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c6 { --c: #8cc472; --c-bg: #213219; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c7 { --c: #62bfd2; --c-bg: #17313a; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .c8 { --c: #bba68f; --c-bg: #2f2a24; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
h1:focus { outline: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75rem; }

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

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--nav-bg);
    color: var(--nav-text);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; font-weight: 650; font-size: 1.05rem; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent-solid); color: var(--on-accent); display: grid; place-items: center; font-size: .85rem; }

.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 6px;
    color: var(--nav-text); font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .8; }

.sidebar-footer { margin-top: auto; font-size: .78rem; opacity: .6; padding: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: flex-end; gap: 12px;
    padding: 10px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar label { font-size: .85rem; color: var(--text-2); white-space: nowrap; }
.topbar select { min-width: 200px; max-width: 320px; }
.dev-tag { font-size: .72rem; background: var(--warn-bg); color: var(--warn); padding: 2px 8px; border-radius: 99px; }

.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky; top: 0; z-index: 20; height: auto;
        flex-direction: row; align-items: center; padding: 8px; overflow-x: auto; gap: 2px;
    }
    .brand { padding: 0 8px 0 4px; }
    .brand-name, .sidebar-footer { display: none; }
    .nav-link { white-space: nowrap; padding: 8px 10px; }
    .topbar { padding: 8px 16px; justify-content: space-between; }
    .topbar select { min-width: 0; flex: 1; }
    .content { padding: 16px 16px 40px; }
}

/* ---------- Sidhuvud ---------- */

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--text-2); margin: 2px 0 0; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: .85rem; color: var(--text-2); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-2); }
.project-no { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; color: var(--text-2); }

/* ---------- Kort och rutnät ---------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: .8rem; color: var(--text-2); }
.kpi-value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--text-2); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.critical .kpi-value { color: var(--critical); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--text-2); }
dl.facts dd { margin: 0; }

/* ---------- Tabeller ---------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: .78rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--row-hover); }
.table .num { text-align: right; white-space: nowrap; }
.table .muted { color: var(--text-2); }
.table .row-title { font-weight: 550; }

.empty { color: var(--text-2); padding: 18px 0; text-align: center; }

/* ---------- Märken och staplar ---------- */

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.badge-active { background: var(--accent-2); color: var(--accent); }
.badge-planned { background: var(--info-bg); color: var(--info); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-done { background: var(--done-bg); color: var(--done); }
.badge-muted { background: var(--surface-2); color: var(--text-2); }

.bar { position: relative; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.critical { background: var(--critical); }
.bar-label { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-2); margin-top: 3px; gap: 8px; }

.text-warn { color: var(--warn); }
.text-critical { color: var(--critical); }
.text-muted { color: var(--text-2); }
.text-ok { color: var(--ok); }
.nowrap { white-space: nowrap; }
.small { font-size: .85rem; }

.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 99px; background: var(--accent-2); color: var(--accent); font-size: .72rem; font-weight: 700; margin-right: 6px; vertical-align: middle; }

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

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

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

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 550; font-size: .9rem; line-height: 1.2;
    padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-solid-hover); }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: var(--critical-bg); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-icon { padding: 4px 8px; font-size: .85rem; color: var(--text-2); border-color: transparent; background: transparent; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field label { display: block; font-size: .85rem; font-weight: 550; margin-bottom: 4px; }
.field .hint { font-size: .78rem; color: var(--text-2); margin-top: 3px; }
.input, .field input:not([type=checkbox]), .field select, .field textarea, .topbar select, .toolbar input, .toolbar select {
    width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
}
.field textarea { min-height: 90px; resize: vertical; }
.field textarea.markdown { min-height: 260px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }

/* Fält med knapp bredvid, t.ex. organisationsnummer + Hämta. */
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; }
.input-action .btn { white-space: nowrap; }

/* Förslag från Bolagsverket på kundformuläret. */
.lookup-panel { background: var(--info-bg); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; font-size: .9rem; }
.lookup-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lookup-head .btn-icon { margin-left: auto; }
.lookup-head .muted, .lookup-panel .muted { color: var(--text-2); }
.lookup-choices { display: grid; gap: 6px; }
.lookup-choices .check { display: flex; align-items: flex-start; font-weight: 400; margin: 0; }
.lookup-choices .check input { margin-top: 3px; }
.lookup-actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { max-width: 320px; }
.toolbar select { width: auto; }

.validation-message { color: var(--critical); font-size: .8rem; margin-top: 3px; }
.validation-errors { color: var(--critical); margin: 0 0 12px; padding-left: 18px; font-size: .88rem; }
.invalid { border-color: var(--critical) !important; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: .9rem; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.alert-error { background: var(--critical-bg); color: var(--critical); }
.alert-ok { background: var(--accent-2); color: var(--accent); }

/* ---------- Dialog ---------- */

.dialog-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 50; display: grid; place-items: start center; padding: 6vh 16px 16px; overflow-y: auto; }
.dialog { background: var(--surface); border-radius: 10px; width: 100%; max-width: 620px; box-shadow: var(--dialog-shadow); }
.dialog.wide { max-width: 860px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; }
.dialog-body { padding: 18px 20px; }

/* ---------- Struktur (etapper och uppgifter) ---------- */

.phase { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.phase-header { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--surface-2); flex-wrap: wrap; }
.phase-title { font-weight: 650; flex: 1; min-width: 180px; }
.phase-meta { font-size: .82rem; color: var(--text-2); }
.milestone { color: var(--accent); margin-right: 4px; }
.phase .table td, .phase .table th { padding-left: 14px; }
.phase table.table { table-layout: fixed; min-width: 760px; }
.phase .col-task { width: 30%; }
.phase .col-resp { width: 14%; }
.phase .col-due { width: 14%; }
.phase .col-status { width: 13%; }
.phase .col-budget { width: 16%; }
.phase .col-actions { width: 13%; }
.phase td:not(.row-actions) { overflow: hidden; text-overflow: ellipsis; }
.link-btn { font: inherit; font-weight: 550; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--accent); text-decoration: underline; }
.phase-empty { padding: 12px 14px; color: var(--text-2); font-size: .88rem; }
.row-actions { white-space: nowrap; text-align: right; }

/* ---------- Mina uppgifter (mobilvänligt) ---------- */

.task-cards { display: grid; gap: 12px; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.task-card.overdue { border-left: 4px solid var(--critical); }
.task-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.task-card h3 { margin: 2px 0 4px; }
.task-card .meta { font-size: .82rem; color: var(--text-2); }
.task-card .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.task-card h3 .link-btn { font-weight: inherit; }
.task-detail-meta { font-size: .82rem; color: var(--text-2); margin-bottom: 12px; }
.task-detail-facts { margin-bottom: 20px; }
.task-detail-budget { max-width: 320px; }
.task-detail-description { margin-bottom: 16px; }

/* ---------- Anteckningar ---------- */

.note { border-top: 1px solid var(--surface-2); padding: 14px 0; }
.note:first-child { border-top: 0; padding-top: 0; }
.note-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.note-head h3 { margin: 0; }
.note-meta { font-size: .8rem; color: var(--text-2); }
.markdown-body { margin-top: 8px; }
.markdown-body h3, .markdown-body h4, .markdown-body h5 { margin: 12px 0 6px; font-size: 1rem; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 22px; }
.markdown-body li.md-task { list-style: none; margin-left: -20px; }
.markdown-body li.md-task.done { color: var(--text-2); text-decoration: line-through; }
.markdown-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.preview { border: 1px dashed var(--border); border-radius: 6px; padding: 10px 14px; min-height: 260px; background: var(--preview-bg); overflow-y: auto; }

/* ---------- Blazor ---------- */

#blazor-error-ui {
    background: var(--critical-bg); color: var(--critical); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.blazor-error-boundary { background: var(--critical-bg); color: var(--critical); padding: 1rem; border-radius: 6px; }
.blazor-error-boundary::after { content: "Ett fel uppstod."; }

/* ---------- Konto ---------- */

.account-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.account-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 28px 28px 24px; }
.account-card h1 { font-size: 1.35rem; margin-bottom: 10px; }
.account-brand { color: var(--text); padding: 0 0 20px; }
.account-card .field input:not([type=checkbox]) { width: 100%; }
.account-submit { width: 100%; margin-top: 18px; padding: 10px 14px; }
.demo-hint { margin-top: 18px; padding: 10px 12px; border-radius: 6px; background: var(--warn-bg); color: var(--hint-text); }
.demo-hint code { background: var(--hint-code-bg); padding: 0 4px; border-radius: 3px; }

.user-chip { display: inline-flex; align-items: center; gap: 2px; color: var(--text); padding: 4px 8px; border-radius: 99px; }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-name { font-weight: 550; font-size: .9rem; }
.user-role { font-size: .78rem; color: var(--text-2); margin-left: 6px; }
.logout-form { margin: 0; }
@media (max-width: 900px) { .user-role { display: none; } .topbar { justify-content: flex-end; } }

.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.recovery-codes code { background: var(--surface-2); padding: 6px 8px; border-radius: 4px; text-align: center; font-size: .9rem; }
ol.steps { padding-left: 20px; margin: 0; }
ol.steps > li { margin-bottom: 18px; }
.qr-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.qr { width: 180px; height: 180px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.authenticator-key { font-size: 1rem; background: var(--surface-2); padding: 8px 10px; border-radius: 6px; letter-spacing: .04em; }

/* ---------- Filer och foton ---------- */

.uploader .form-grid { grid-template-columns: 1fr; }
.upload-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.file-button { position: relative; overflow: hidden; }
.file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-button.disabled { opacity: .55; pointer-events: none; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.photo { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.photo figcaption { padding: 8px 10px; font-size: .85rem; display: grid; gap: 4px; }
.photo-comment { font-weight: 550; min-height: 1.2em; }
.photo-meta { color: var(--text-2); font-size: .78rem; }
.photo-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.link-btn.small { font-size: .78rem; color: var(--accent); }

/* ---------- Steg 1b: gemensamt ---------- */

.card-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gantt-actions .link-btn, .ai-meta .link-btn { color: var(--accent); font-weight: 400; font-size: inherit; }
.gantt-actions .link-btn.danger { color: var(--critical); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.selected td { background: var(--accent-2); }
.table tr.group-row td { background: var(--surface-2); font-weight: 600; font-size: .88rem; }
.table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; }
.segmented { display: flex; gap: 14px; flex-wrap: wrap; padding-top: 6px; }

/* Projektfärger (planering). Samma index som PlanningService.ColorFor. */
/* c0 = ärenden utan projekt */
.c0 { --c: #4f5fa8; --c-bg: #e8ebf8; }
.c1 { --c: #2f7d6b; --c-bg: #e3f1ec; }
.c2 { --c: #3b6fb6; --c-bg: #e6eef9; }
.c3 { --c: #b7791f; --c-bg: #fbf0dc; }
.c4 { --c: #8e4fa8; --c-bg: #f3e8f8; }
.c5 { --c: #c2553d; --c-bg: #fbe9e4; }
.c6 { --c: #4f8a3a; --c-bg: #eaf4e4; }
.c7 { --c: #2b8a9e; --c-bg: #e2f2f5; }
.c8 { --c: #7a6a58; --c-bg: #f1ede8; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--c, var(--accent)); margin-right: 6px; vertical-align: -1px; }
.swatch.range { background: var(--surface-2); border: 1px solid var(--border); }
.swatch.deadline { background: var(--critical); width: 3px; }

/* ---------- Estimat ---------- */

.estimate-edit .input { padding: 5px 7px; font-size: .88rem; min-width: 70px; }
.estimate-edit td { padding: 4px 6px; }
.estimate-edit td:nth-child(2) .input { min-width: 220px; }
.estimate-edit .input.num { text-align: right; width: 96px; }
.estimate-description { background: var(--surface-2); border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }

/* ---------- Resursplanering: tavla ---------- */

.plan-toolbar { align-items: center; }
.plan-toolbar .check { white-space: nowrap; }
.plan-toolbar select { max-width: 280px; }
.plan-period { margin: 0 6px; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.plan-layout.with-side { grid-template-columns: minmax(0, 1fr) 300px; }
@media (max-width: 1200px) { .plan-layout.with-side { grid-template-columns: minmax(0, 1fr); } }
.plan-card { padding: 14px; }
.plan-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: .82rem; }
.legend-item { color: var(--text); white-space: nowrap; }
.plan-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.plan-grid { --person-w: 170px; display: grid; min-width: max-content; font-size: .8rem; }
@media (max-width: 700px) {
    .plan-grid { --person-w: 112px; }
    .plan-person { font-size: .78rem; padding: 6px; }
    .plan-person .avatar { display: none; }
    .plan-person .bar-label span:last-child { display: none; }
}
.plan-grid > div { border-right: 1px solid var(--surface-2); border-bottom: 1px solid var(--surface-2); }
.plan-corner, .plan-dayhead { background: var(--surface); position: sticky; top: 0; z-index: 2; padding: 6px; font-weight: 600; color: var(--text-2); }
.plan-corner { left: 0; z-index: 3; }
.plan-dayhead { text-align: center; display: flex; flex-direction: column; gap: 1px; text-transform: capitalize; }
.plan-dayhead .wk { font-size: .7rem; color: var(--accent); font-weight: 700; }
.plan-dayhead .holiday-name { font-size: .68rem; color: var(--warn); font-weight: 500; text-transform: none; }
.plan-dayhead.today { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.plan-person { position: sticky; left: 0; z-index: 1; background: var(--surface); padding: 8px; display: grid; gap: 5px; align-content: start; font-size: .85rem; font-weight: 550; }
.plan-person .bar-label { font-weight: 400; }
.plan-cell { min-height: 74px; padding: 4px; display: flex; flex-direction: column; gap: 3px; position: relative; background: var(--surface); }
.plan-cell.weekend, .plan-dayhead.weekend { background: var(--surface-2); }
.plan-cell.holiday, .plan-dayhead.holiday { background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
.plan-cell.absence { background: repeating-linear-gradient(135deg, var(--warn-bg) 0 6px, var(--surface) 6px 12px); }
.plan-cell.over { box-shadow: inset 0 0 0 2px var(--critical); }
.plan-cell.today { background-color: var(--plan-today); }
.plan-cell.past { opacity: .75; }
.plan-cell:not(.weekend):hover { background-color: var(--plan-hover); }
.absence-label { font-size: .7rem; color: var(--warn); font-weight: 600; }
.cell-load { margin-top: auto; font-size: .68rem; color: var(--text-2); text-align: right; }
.plan-chip { background: var(--c-bg); border-left: 3px solid var(--c); border-radius: 4px; padding: 2px 5px; display: flex; gap: 5px; align-items: baseline; cursor: pointer; overflow: hidden; line-height: 1.25; user-select: none; }
.plan-chip[draggable=true] { cursor: grab; }
.plan-chip:hover { filter: brightness(.96); }
:root[data-theme="dark"] .plan-chip:hover { filter: brightness(1.15); }
.plan-chip.late { box-shadow: inset 0 0 0 1px var(--critical); }
.plan-chip.dragging { opacity: .45; }
.chip-hours { font-weight: 700; color: var(--c); white-space: nowrap; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekend .plan-chip { padding: 2px; justify-content: center; }
.plan-empty { padding: 20px; text-align: center; color: var(--text-2); }

.plan-conflicts { align-self: start; max-height: 80vh; overflow-y: auto; }
.plan-conflicts h2 { display: flex; align-items: center; gap: 8px; }
.conflict { border-left: 3px solid var(--border); padding: 6px 0 8px 10px; margin-bottom: 10px; }
.conflict.critical { border-left-color: var(--critical); }
.conflict.warn { border-left-color: var(--warn); }
.conflict.info { border-left-color: var(--info); }
.conflict-kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
.conflict .suggestion { margin-top: 6px; white-space: normal; text-align: left; display: block; }

/* Beläggning per vecka */
.heatmap td.heat { text-align: center; padding: 4px; }
.heatmap .heat-btn { width: 100%; border: 0; background: none; cursor: pointer; padding: 4px; display: grid; font: inherit; color: inherit; }
.heatmap td.heat span, .heatmap .heat-btn span { font-size: .72rem; color: var(--text-2); display: block; }
.heat.none { background: var(--surface-2); }
.heat.low { background: var(--heat-low); }
.heat.mid { background: var(--heat-mid); }
.heat.full { background: var(--heat-full); }
.heat.over { background: var(--critical-bg); color: var(--critical); }
.heat-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; color: var(--text-2); }
.heat-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Projektets tidsplan (Gantt) ---------- */

.gantt-scroll { overflow-x: auto; }
.gantt { min-width: calc(280px + var(--weeks) * 60px); font-size: .82rem; }
.gantt-head, .gantt-row { display: grid; grid-template-columns: 280px minmax(0, 1fr); border-bottom: 1px solid var(--surface-2); }
.gantt-head { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 600; color: var(--text-2); }
.gantt-label { padding: 7px 10px 7px 0; }
.gantt-track { position: relative; min-height: 46px; background-image: linear-gradient(to right, var(--surface-2) 1px, transparent 1px); background-size: calc(100% / var(--weeks)) 100%; }
.gantt-head .gantt-track { min-height: 32px; }
.gantt-week { position: absolute; top: 0; bottom: 0; padding: 8px 6px; white-space: nowrap; overflow: hidden; font-size: .75rem; }
.gantt-phase { padding: 8px 0 4px; font-weight: 700; font-size: .85rem; border-bottom: 1px solid var(--border); }
.gantt-row.done { opacity: .55; }
.gantt-range { position: absolute; top: 9px; bottom: 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; }
.gantt-block { position: absolute; bottom: 9px; background: var(--c); border-radius: 2px; opacity: .85; min-width: 3px; max-height: calc(100% - 18px); }
.gantt-block.late { outline: 2px solid var(--critical); }
.gantt-deadline { position: absolute; top: 4px; bottom: 4px; width: 2px; background: var(--critical); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .5; z-index: 1; }
.gantt-actions { display: flex; gap: 12px; margin-top: 3px; font-size: .78rem; }

/* ---------- AI-assistent ---------- */

.ai-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ai-chat { display: flex; flex-direction: column; gap: 12px; max-height: 62vh; overflow-y: auto; padding: 4px 2px 10px; }
.ai-msg { display: flex; flex-direction: column; }
.ai-msg.user { align-items: flex-end; }
.ai-bubble { border-radius: 10px; padding: 10px 14px; max-width: 860px; }
.ai-msg.user .ai-bubble { background: var(--accent-solid); color: var(--on-accent); white-space: pre-wrap; }
.ai-msg.assistant .ai-bubble { background: var(--surface-2); }
.ai-bubble.markdown-body { margin-top: 0; }
.ai-bubble.markdown-body > :last-child { margin-bottom: 0; }
.ai-meta { display: flex; gap: 6px; margin-top: 4px; align-items: center; }
.ai-thinking { color: var(--text-2); font-style: italic; }
.ai-input { display: grid; gap: 8px; margin-top: 10px; }
.ai-input textarea { width: 100%; resize: vertical; }
.ai-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media print {
    .sidebar, .topbar, .tabs, .no-print, .page-header .actions, .alert { display: none !important; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Inställningar och plattform ---------- */

.tenant-name { margin: -6px 0 14px; padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,.06); color: #fff; font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.key-hint { background: var(--surface-2); padding: 4px 8px; border-radius: 4px; font-size: .9rem; }
.facts-list { padding-left: 18px; margin: 0; display: grid; gap: 8px; color: var(--text-2); }
.card-header .actions strong { min-width: 120px; text-align: center; text-transform: capitalize; }
.tenant-table code { font-size: .82rem; }
.tenant-table .row-title .small { word-break: break-all; }
.tenant-table td:nth-child(6) { min-width: 120px; }
.tenant-table .row-actions { white-space: normal; text-align: right; }
.tenant-table .row-actions .btn { margin: 2px 0 2px 4px; }

/* ---------- Min tid ---------- */

.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.week-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 2px; }
.week-day .wd { font-size: .78rem; color: var(--text-2); text-transform: capitalize; }
.week-day.off { background: var(--surface-2); }
.week-day.today { border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
@media (max-width: 700px) {
    .week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    /* Raderna blir kort på mobilen: projekt och timmar överst, uppgift, kommentar och status under, knapparna till höger. */
    .my-time thead { display: none; }
    .my-time, .my-time tbody { display: block; }
    .my-time tr.group-row { display: flex; justify-content: space-between; background: var(--surface-2); }
    .my-time tr.group-row td:empty { display: none; }
    .my-time tr:not(.group-row) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 4px; border-bottom: 1px solid var(--surface-2); }
    .my-time tr:not(.group-row) td { border: 0; padding: 1px 6px; text-align: left; }
    .my-time tr:not(.group-row) td:nth-child(4) { grid-column: 2; grid-row: 1; font-weight: 600; text-align: right; }
    .my-time tr:not(.group-row) td:nth-child(6) { grid-column: 2; grid-row: 2 / span 3; align-self: end; }
    .my-time tr:not(.group-row) td:nth-child(1), .my-time tr:not(.group-row) td:nth-child(2),
    .my-time tr:not(.group-row) td:nth-child(3), .my-time tr:not(.group-row) td:nth-child(5) { grid-column: 1; }
}

/* ---------- Planering: att planera (dra in uppgifter) ---------- */

.plan-side { display: grid; gap: 16px; align-content: start; }
.plan-side .card { margin-bottom: 0; }
.plan-backlog h2, .plan-conflicts h2 { display: flex; align-items: center; gap: 8px; }
.backlog-list { display: grid; gap: 6px; max-height: 52vh; overflow-y: auto; padding-right: 2px; }
.backlog-item { background: var(--c-bg); border-left: 4px solid var(--c); border-radius: 6px; padding: 7px 9px; cursor: grab; user-select: none; }
.backlog-item:hover { filter: brightness(.96); }
.backlog-item.dragging { opacity: .45; }
.backlog-title { font-weight: 600; font-size: .86rem; line-height: 1.25; }
.backlog-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .76rem; color: var(--text-2); margin-top: 2px; align-items: baseline; }
.backlog-meta strong { color: var(--c); }
.plan-grid.drag-active .plan-cell:not(.weekend):not(.holiday) { outline: 1px dashed var(--accent); outline-offset: -3px; }
.plan-grid.drag-active .plan-cell:not(.weekend):not(.holiday):hover { background-color: var(--accent-2); }
.plan-empty-hint { background: var(--accent-2); color: var(--text); border-radius: 6px; padding: 10px 14px; margin-bottom: 10px; font-size: .88rem; display: grid; gap: 2px; }
.drop-result { margin-bottom: 10px; }
.drop-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Planering: stor tavla (hela bredden, storlek, sidopanel, helskärm) ---------- */

.content:has(.plan-page) { max-width: none; }
.plan-view-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plan-view-tools .btn .badge { margin-left: 4px; }
.plan-focus-btn .when-focus { display: none; }
body.focus-mode .plan-focus-btn .when-focus { display: inline; }
body.focus-mode .plan-focus-btn .when-normal { display: none; }
body.focus-mode .plan-page .page-header { margin-bottom: 8px; }
body.focus-mode .plan-page .page-header .subtitle { display: none; }

/* Tavlan fyller skärmens höjd; rubrikraden och personkolumnen står kvar när man rullar. */
.plan-page .plan-scroll { overflow: auto; max-height: calc(100dvh - 290px); min-height: 360px; }
body.focus-mode .plan-page .plan-scroll { max-height: calc(100dvh - 200px); }
@media (min-width: 1201px) {
    .plan-page .plan-side { position: sticky; top: 12px; align-self: start; max-height: calc(100dvh - 24px); overflow-y: auto; }
}

/* Storlek: kompakt (många personer och dagar), normal, stor (lättläst, två rader text i blocken). */
/* Kolumnbredden styrs av storleken – långa rubriker kortas med … i stället för att bredda dagen. */
.plan-page .plan-grid { --day-w: 112px; --weekend-w: 34px; min-width: 0; }
.plan-page .plan-grid > div { min-width: 0; }
.plan-page .plan-chip { min-width: 0; }
.plan-page.density-kompakt .plan-grid { --day-w: 76px; --weekend-w: 22px; font-size: .74rem; }
.plan-page.density-kompakt .plan-cell { min-height: 46px; padding: 2px; gap: 2px; }
.plan-page.density-kompakt .plan-person { padding: 4px 6px; gap: 3px; font-size: .78rem; }
.plan-page.density-kompakt .plan-chip { padding: 1px 4px; gap: 4px; }
.plan-page.density-kompakt .plan-dayhead { padding: 4px 2px; }
.plan-page.density-stor .plan-grid { --day-w: 150px; --weekend-w: 40px; font-size: .88rem; }
.plan-page.density-stor .plan-cell { min-height: 104px; padding: 6px; gap: 4px; }
.plan-page.density-stor .plan-person { padding: 10px; font-size: .92rem; }
.plan-page.density-stor .plan-chip { padding: 4px 7px; align-items: flex-start; }
.plan-page.density-stor .chip-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (min-width: 701px) {
    .plan-page.density-kompakt .plan-grid { --person-w: 140px; }
    .plan-page.density-stor .plan-grid { --person-w: 210px; }
}

/* ---------- Offerter ---------- */

.offer-months { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 6px 0 0; overflow-x: auto; }
.offer-month { flex: 1 0 34px; display: flex; flex-direction: column; align-items: stretch; height: 100%; }
.offer-month-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border); }
.offer-bar { width: 9px; min-height: 0; border-radius: 3px 3px 0 0; }
.offer-bar.created, .offer-swatch.created { background: var(--offer-created); }
.offer-bar.won, .offer-swatch.won { background: var(--accent); }
.offer-bar.lost, .offer-swatch.lost { background: var(--offer-lost); }
.offer-month-label { font-size: .72rem; color: var(--text-2); text-align: center; margin-top: 4px; white-space: nowrap; }

/* ---------- Tema ---------- */

.theme-toggle { font-size: 1rem; line-height: 1; padding: 6px 8px; }
.theme-toggle .icon-sun { display: none; }
@media screen {
    :root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
    :root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
}
@media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .icon-sun { display: inline; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}

.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.theme-option { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: .9rem; font-weight: 550; background: var(--surface); }
.theme-option:hover { background: var(--surface-2); }
.theme-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-option input { margin: 0 6px 0 0; accent-color: var(--accent); }
.theme-preview { height: 54px; border-radius: 6px; border: 1px solid var(--border); display: grid; grid-template-columns: 26% 1fr; overflow: hidden; }
.theme-preview i { display: block; }
.theme-preview .tp-nav { background: #1b2420; }
.theme-preview.light .tp-main { background: linear-gradient(#ffffff 0 30%, #f5f6f4 30%); }
.theme-preview.dark .tp-nav { background: #0c0f0d; }
.theme-preview.dark .tp-main { background: linear-gradient(#191e1b 0 30%, #111513 30%); }
.theme-preview.system .tp-main { background: linear-gradient(105deg, #f5f6f4 0 50%, #111513 50%); }
@media (max-width: 520px) { .theme-options { grid-template-columns: 1fr; } }

/* ---------- Filer i uppgiftsformuläret ---------- */

.task-files { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.task-files-title { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.task-files .empty { padding: 8px 0; text-align: left; }
.task-files .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.count-badge { display: inline-block; min-width: 1.5em; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: .78rem; font-weight: 600; text-align: center; }
.pending-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pending-file { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.pending-icon { font-size: 1.3rem; }
.pending-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.pending-name { font-weight: 550; overflow-wrap: anywhere; }
.pending-main .input { width: 100%; }
.task-files .uploader { margin-top: 14px; }

/* ---------- Anteckningar på uppgiften ---------- */

.task-notes { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.task-section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.task-section-head .task-files-title { margin: 0; }
.task-notes .empty { padding: 8px 0; text-align: left; }
.task-note { padding: 10px 0; }
.task-note .note-head h4 { margin: 0; font-size: .95rem; }
.task-note .markdown-body { margin-top: 4px; }
.note-editor { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.note-editor-label { display: flex; justify-content: space-between; align-items: baseline; }
.note-editor textarea.note-body { min-height: 120px; }
.note-preview { min-height: 120px; }
.note-editor-actions { margin-top: 10px; }
.dialog-body > .task-notes:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Taggar ---------- */
.tag {
    --tag-fg: #6b746f;
    display: inline-flex; align-items: center; gap: 3px;
    font-size: .74rem; font-weight: 600; line-height: 1.5;
    padding: 1px 9px; border-radius: 99px; white-space: nowrap;
    color: var(--tag-fg);
    background: color-mix(in srgb, var(--tag-fg) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--tag-fg) 22%, transparent);
    margin: 0 4px 4px 0; font-family: inherit;
}
button.tag { cursor: pointer; }
button.tag:hover { border-color: var(--tag-fg); }
button.tag:disabled { cursor: default; opacity: .6; }
.tag.off { background: transparent; border-color: var(--border); color: var(--text-2); font-weight: 500; }
.tag.inactive { opacity: .55; font-style: italic; }
.tag-add { background: transparent; border: 1px dashed var(--border); color: var(--text-2); }
.tag-none { --tag-fg: var(--text-2); background: transparent; border-style: dashed; }
.tag-blue { --tag-fg: #3d6fd0; }
.tag-green { --tag-fg: #2f8a57; }
.tag-teal { --tag-fg: #1f8a8a; }
.tag-purple { --tag-fg: #8357c4; }
.tag-orange { --tag-fg: #c56a12; }
.tag-red { --tag-fg: #c8402f; }
.tag-yellow { --tag-fg: #9c7f00; }
.tag-gray { --tag-fg: #6b746f; }
.tag-picker { display: flex; flex-wrap: wrap; align-items: center; }
.tag-new { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin: 4px 0 10px; }
.tag-filter > .small:first-child { margin-right: 8px; margin-bottom: 4px; }
.tag-add-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tag-add-row .input:first-child { flex: 1; min-width: 180px; }
.note-tags { margin-left: 6px; }
.note-tags .tag { margin-bottom: 0; }
.input-sm { padding: 4px 8px; font-size: .85rem; width: auto; }
.alert-info { background: var(--info-bg); color: var(--info); }
.hidden-input { position: absolute !important; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; left: -9999px; }

/* ---------- Filbibliotek ---------- */
.files-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .files-layout { grid-template-columns: 1fr; } }
.library-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.library-search { flex: 1; min-width: 220px; }
.template-choice { display: inline-flex; gap: 6px; align-items: center; }
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px; border-radius: 6px; background: var(--accent-2); }
.file-group { margin-top: 14px; }
.file-group-head { display: flex; gap: 8px; align-items: center; margin: 0 0 6px; font-size: .95rem; }
.file-group-head .tag { font-size: .85rem; margin: 0; }
.file-table .col-check { width: 28px; }
.file-thumb { width: 52px; }
.file-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); display: block; }
.file-icon { font-size: 1.5rem; display: inline-block; width: 44px; text-align: center; }
.file-tags { min-width: 160px; }
.btn-tag-edit { opacity: .55; }
tr:hover .btn-tag-edit { opacity: 1; }
.inline-edit { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.template-item { border-top: 1px solid var(--surface-2); padding: 10px 0; }
.template-item:first-of-type { border-top: 0; }
.template-item-head { display: flex; gap: 8px; align-items: center; }
.template-item-head .row-actions { margin-left: auto; }
.template-tags { margin-top: 6px; }
.template-order { padding-left: 20px; margin: 0; }
.template-order li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }

/* ---------- Anteckning som egen sida ---------- */
.content:has(.note-page) { max-width: none; }
.note-page { display: flex; flex-direction: column; gap: 12px; }
.note-page-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0; }
.note-page-bar .breadcrumb { margin: 0; }
.note-page-bar .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.note-title-input { font-size: 1.5rem; font-weight: 650; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); width: 100%; padding: 6px 2px; font-family: inherit; }
.note-title-input:focus { outline: none; border-bottom-color: var(--accent); }
.note-meta-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.note-meta-row .field { min-width: 150px; }
.note-meta-row .note-tags-field { flex: 1; min-width: 260px; }
.note-files-card { margin-top: 4px; }
.note-files { display: flex; flex-wrap: wrap; gap: 12px; }
.note-file { width: 170px; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.note-file img { width: 100%; height: 110px; object-fit: cover; border-radius: 4px; display: block; }
.note-file-doc { font-size: 2.6rem; text-align: center; display: block; height: 110px; line-height: 110px; text-decoration: none; }
.note-file-name { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-file-actions { display: flex; gap: 4px; justify-content: space-between; align-items: center; }

/* Markdown-redigeraren */
.md-editor { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.md-editor.dragover { outline: 2px dashed var(--accent); outline-offset: 2px; }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.md-toolbar > button, .md-file-button { border: 1px solid transparent; background: transparent; color: var(--text); padding: 4px 8px; border-radius: 5px; font-size: .84rem; cursor: pointer; font-family: inherit; line-height: 1.3; }
.md-toolbar > button:hover, .md-file-button:hover { background: var(--surface); border-color: var(--border); }
.md-file-button { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.md-file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.md-file-button.disabled { opacity: .5; pointer-events: none; }
.md-toolbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.md-toolbar-spacer { flex: 1; }
.md-modes { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.md-modes button { border: 0; background: transparent; color: var(--text-2); padding: 4px 10px; font-size: .82rem; cursor: pointer; font-family: inherit; }
.md-modes button + button { border-left: 1px solid var(--border); }
.md-modes button.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.md-panes { display: grid; grid-template-columns: 1fr 1fr; min-height: 320px; }
.md-editor.write .md-panes, .md-editor.preview .md-panes { grid-template-columns: 1fr; }
.md-input { border: 0; resize: vertical; padding: 14px 16px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92rem; line-height: 1.6; background: transparent; color: var(--text); width: 100%; min-height: 320px; }
.md-input:focus { outline: none; }
.md-preview { padding: 12px 18px; overflow-y: auto; border-left: 1px solid var(--border); margin-top: 0; }
.md-editor.preview .md-preview { border-left: 0; }
.note-page .md-input, .note-page .md-preview { height: calc(100vh - 360px); min-height: 380px; }
.md-status { display: flex; justify-content: space-between; gap: 10px; font-size: .76rem; color: var(--text-2); padding: 5px 10px; border-top: 1px solid var(--border); }
.md-help { padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface-2); line-height: 2; }
@media (max-width: 900px) {
    .md-editor.both .md-panes { grid-template-columns: 1fr; }
    .md-editor.both .md-preview { border-left: 0; border-top: 1px solid var(--border); height: auto; max-height: 50vh; }
    .note-page .md-input { height: 55vh; }
}
.dialog .md-input, .dialog .md-preview { height: 320px; }

/* Fokusläge: bara anteckningen syns */
body.focus-mode .sidebar, body.focus-mode .topbar { display: none; }
body.focus-mode .shell { grid-template-columns: 1fr; }
body.focus-mode .content { padding-top: 12px; }
body.focus-mode .note-page .md-input, body.focus-mode .note-page .md-preview { height: calc(100vh - 290px); }

/* Bilder, citat och tabeller i Markdown */
.markdown-body img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); margin: 4px 0; }
.markdown-body a.md-img { display: inline-block; max-width: 100%; }
.markdown-body blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--text-2); }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.markdown-body .md-table { overflow-x: auto; margin: 8px 0 12px; }
.markdown-body table { border-collapse: collapse; font-size: .9rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.markdown-body th { background: var(--surface-2); }
.note .markdown-body img { max-height: 420px; width: auto; }
@media (max-width: 900px) {
    .note-page-bar { position: static; }
    .note-meta-row .field { min-width: 0; flex: 1 1 140px; }
    .note-title-input { font-size: 1.25rem; }
}

/* ---------- Projektassistent ---------- */
.assistant-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .assistant-layout { grid-template-columns: 1fr; } .assistant-chats .chat-list { max-height: 180px; } }
.assistant-chats { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 12px; }
.assistant-new { width: 100%; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 65vh; overflow-y: auto; }
.chat-item { width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 9px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; font-family: inherit; color: var(--text); }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-2); }
.chat-title { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { font-size: .74rem; color: var(--text-2); }
.assistant-main { min-width: 0; }
.assistant-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.assistant-head h2 { margin: 0; }
.assistant-head h2.editable { cursor: text; }
.assistant-head h2.editable:hover { text-decoration: underline dotted; }
.assistant-messages { max-height: calc(100vh - 380px); min-height: 280px; }
.assistant-intro { color: var(--text-2); max-width: 760px; }
.assistant-intro p { margin-top: 0; }
.ai-steps { font-size: .78rem; color: var(--text-2); margin-bottom: 4px; max-width: 860px; }
.ai-steps summary { cursor: pointer; }
.ai-steps ul, .live-steps { margin: 4px 0 0; padding-left: 18px; }
.live-steps { font-style: normal; font-size: .82rem; }
.action-card { border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 8px; padding: 10px 14px; margin-top: 8px; max-width: 860px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.action-card.approved { border-left-color: var(--accent); }
.action-card.rejected { border-left-color: var(--border); opacity: .8; }
.action-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.action-preview summary { cursor: pointer; font-size: .82rem; color: var(--text-2); }
.action-preview .markdown-body { max-height: 360px; overflow-y: auto; border: 1px dashed var(--border); border-radius: 6px; padding: 8px 12px; background: var(--preview-bg); margin-top: 6px; }
.action-buttons { display: flex; gap: 8px; }
.action-result a { margin-left: 4px; }
.attached { display: flex; flex-wrap: wrap; gap: 4px; }
.attached .link-btn { margin-left: 4px; font-size: .75rem; }

/* ---------- Ärenden (steg 1g) ---------- */
.case-table tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.case-table .badge { margin-left: 4px; }
.case-history { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.case-history .case-event { padding-left: 12px; border-left: 2px solid var(--border); }
.case-history .case-note { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.case-note-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.case-note-head .row-actions { margin-left: auto; display: flex; gap: 4px; }
.case-note-form textarea { width: 100%; }
.case-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.case-files li { display: flex; gap: 10px; align-items: center; }
.case-files li > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.case-files img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.plain-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.section-title { font-size: 1.05rem; margin: 4px 0 10px; }
.case-card { border-left: 3px solid var(--c, #4f5fa8); }

/* ---------- Mina uppgifter: filter, planeringsläge och grupper per projekt ---------- */

.mytasks-filters { gap: 10px 14px; align-items: center; }
.mytasks-filters select { max-width: 260px; padding: 6px 10px; }
.filter-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border-radius: 99px; padding: 3px; }
.filter-chip { font: inherit; font-size: .84rem; border: 0; background: none; color: var(--text-2); border-radius: 99px; padding: 5px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.filter-chip:hover { color: var(--text); }
.filter-chip.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.filter-chip .count { font-size: .74rem; color: var(--text-2); font-weight: 500; }
.filter-chip.plan-none.active .count { color: var(--warn); }
.filter-chip.plan-full.active .count { color: var(--ok); }
.mytasks-hint { margin: -4px 0 12px; }

.task-group { margin-bottom: 22px; }
.task-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.task-group-head .section-title { margin: 0; }
.mytasks-projects-title { margin-top: 6px; }
.project-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 10px 12px 12px; }
.project-group > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.project-group > summary::-webkit-details-marker { display: none; }
.project-group > summary::before { content: "▸"; color: var(--text-2); font-size: .8rem; transition: transform .15s; }
.project-group[open] > summary::before { transform: rotate(90deg); }
.project-group[open] > summary { margin-bottom: 10px; }
.project-group .group-name { font-size: 1rem; }
.group-links { margin-left: auto; display: inline-flex; gap: 12px; font-size: .82rem; }

/* Planeringsläget syns som färgad kant och en rad på kortet. */
.task-card.plan-none { border-left: 4px solid var(--warn); }
.task-card.plan-partial { border-left: 4px solid var(--info); }
.task-card.plan-full { border-left: 4px solid var(--ok); }
.task-card.overdue { border-left-color: var(--critical); }
.plan-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.plan-days { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.plan-day { font-size: .76rem; background: var(--accent-2); color: var(--text); border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
.plan-day strong { color: var(--accent); }
.plan-day.other { background: var(--surface-2); color: var(--text-2); }
@media (max-width: 700px) {
    .mytasks-filters select { max-width: none; flex: 1 1 140px; }
    .group-links { margin-left: 0; width: 100%; }
}
table.compact td { padding-top: 6px; padding-bottom: 6px; }

/* ---------- Ärendekö och e-post (steg 1h) ---------- */
.queue-layout { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .queue-layout { grid-template-columns: 1fr; } }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.queue-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.queue-item:hover { background: var(--surface-2); }
.queue-item.active { background: var(--accent-2); border-color: var(--accent); }
.queue-from { font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; gap: 8px; }
.queue-subject { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: 12px; max-height: 360px; overflow-y: auto; font-size: .92rem; }
.ai-suggestion { background: var(--info-bg); color: var(--info); padding: 8px 10px; border-radius: 8px; }
.case-history .case-mail { border: 1px solid var(--border); border-left: 3px solid var(--info); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.case-history .case-mail.out { border-left-color: var(--accent); }
.case-mail .mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.case-mail .mail-text.markdown-body { white-space: normal; }
.case-mail .markdown-body img, .case-note .markdown-body img { max-height: 420px; width: auto; }
.similar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.approval-person td { background: var(--surface-2); font-weight: 600; }
.ai-summary { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.compact-kpis { grid-template-columns: repeat(3, 1fr); margin-bottom: 4px; }
.compact-kpis .kpi { padding: 10px 12px; }
.nav-link.nav-sub { padding-left: 34px; font-size: .92rem; }

/* ---------- ÄTA ---------- */
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.ata-warnings { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.ata-warnings li { margin: 0; padding: 8px 12px; border-radius: 6px; font-size: .88rem; display: flex; gap: 8px; align-items: baseline; }
.ata-warnings li a { color: inherit; font-weight: 600; }
.ata-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
.ata-facts dt { color: var(--text-2); }
.ata-facts dd { margin: 0; }
.ata-amount { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.ata-amount.neg { color: var(--done); }
.ata-steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 16px; padding: 0; list-style: none; font-size: .8rem; }
.ata-steps li { padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.ata-steps li.done { background: var(--accent-2); color: var(--accent); }
.ata-steps li.current { background: var(--accent); color: #fff; font-weight: 600; }
.ata-row-sub { font-size: .8rem; color: var(--text-2); }
@media (max-width: 760px) {
  .ata-facts { grid-template-columns: 1fr; gap: 2px; }
  .ata-facts dd { margin-bottom: 6px; }
}
