/* ENTER Control Center — professionellt dashboard-tema. Desktop först. */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --ink: #1a2233;
  --ink-soft: #55617a;
  --ink-faint: #8a93a6;
  --line: #e2e7f0;
  --brand: #0f4c81;
  --brand-2: #1769aa;
  --brand-ink: #ffffff;
  --sidebar: #0e1b2e;
  --sidebar-2: #16273f;
  --sidebar-ink: #c3cde0;
  --sidebar-ink-soft: #7d8aa5;
  --ok: #1a8f4c;
  --ok-bg: #e4f4ea;
  --warn: #b8770a;
  --warn-bg: #fbf0d9;
  --crit: #c02c2c;
  --crit-bg: #fbe4e4;
  --info: #1769aa;
  --info-bg: #e2eefa;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,30,50,.08), 0 1px 2px rgba(20,30,50,.04);
  --shadow-lg: 0 6px 24px rgba(20,30,50,.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { display: flex; align-items: center; gap: 10px; cursor: pointer; text-decoration: none; border-radius: 8px; padding: 4px; margin: -4px; transition: background .15s; }
.brand a.logo:hover { background: rgba(255,255,255,.06); }
.brand a.logo:hover .mark { filter: brightness(1.12); }
.brand .mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px; letter-spacing: .5px; }
.brand .name { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.15; }
.brand .sub { font-size: 11px; color: var(--sidebar-ink-soft); }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-ink); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--sidebar-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ic { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.nav a .badge-count { margin-left: auto; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.nav .group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--sidebar-ink-soft); padding: 14px 12px 6px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.apphead { position: sticky; top: 0; z-index: 10; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .crumb { color: var(--ink-faint); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .weather { flex: 0 0 auto; }
.topbar .today { font-size: 13px; color: var(--ink-soft); white-space: nowrap; flex: 0 0 auto; }
/* Dagens kalenderhändelser – rullgardin i sökraden (rad 2) */
.todaycal-wrap { position: relative; flex: 0 0 auto; }
.todaycal-trigger { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); white-space: nowrap; }
.todaycal-trigger:hover, .todaycal-wrap:hover .todaycal-trigger { border-color: var(--brand-2); color: var(--brand-2); }
.todaycal-trigger .tc-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 800; }
.todaycal-panel { position: absolute; top: 100%; right: 0; margin-top: 6px; width: 340px; max-height: 62vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  z-index: 50; display: none; padding: 4px; }
.todaycal-wrap:hover .todaycal-panel, .todaycal-wrap.open .todaycal-panel { display: block; }
/* osynlig brygga över gapet så panelen inte stängs när muspekaren rör sig till den */
.todaycal-panel::before { content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px; }
.todaycal-panel .tc-item { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--ink); }
.todaycal-panel .tc-item:hover { background: var(--panel-2, rgba(23,105,170,.07)); }
.todaycal-panel .tc-item.passed { opacity: .5; }
.todaycal-panel .tc-item .tc-t { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; flex: 0 0 auto; font-size: 12.5px; }
.todaycal-panel .tc-item .tc-ic { flex: 0 0 auto; }
.todaycal-panel .tc-item .tc-title { font-size: 12.5px; color: var(--ink-soft); }
.todaycal-panel .tc-empty { padding: 14px 12px; color: var(--ink-faint); font-size: 13px; }
.todaycal-panel .tc-foot { display: block; text-align: center; padding: 9px; margin-top: 2px; border-top: 1px solid var(--line);
  font-weight: 700; font-size: 12.5px; color: var(--brand-2); text-decoration: none; }
@media (max-width: 900px) { .todaycal-wrap { display: none; } }
/* ---- SOS: panikknapp som suddar/pixlar hela appen ---- */
.report-btn { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.report-btn:hover { background: rgba(15,76,129,.08); }
.sos-btn { border-color: #e0b4b4; color: #b42318; font-weight: 700; }
.sos-btn:hover { background: #fbeaea; border-color: #d98a8a; }
.sos-overlay { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center;
  background: rgba(230,232,236,.55); backdrop-filter: blur(16px) saturate(.7) contrast(.95); -webkit-backdrop-filter: blur(16px) saturate(.7) contrast(.95); }
.sos-overlay[hidden] { display: none !important; }
/* Pixelrutnät ovanpå oskärpan – ger den "pixliga" känslan */
.sos-pixels { position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.45) 1px, transparent 1px),
    linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 14px 14px, 14px 14px, 14px 14px, 14px 14px;
  background-position: 0 0, 0 0, 7px 7px, 7px 7px;
  mix-blend-mode: overlay; }
.sos-panel { position: relative; z-index: 1; }
.sos-unlock { padding: 12px 22px; border-radius: 40px; border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.75); color: #333; font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,.12); opacity: .28; transition: opacity .2s, transform .15s; }
.sos-unlock:hover { opacity: 1; transform: translateY(-1px); }
.upd-steps { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.upd-step { display: flex; gap: 12px; align-items: baseline; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.upd-step:last-child { border-bottom: none; }
.upd-step .us-label { font-weight: 600; min-width: 230px; flex: none; }
.upd-step .us-detail { color: var(--ink-soft); }
@media (max-width: 700px) { .upd-step { flex-direction: column; gap: 2px; } .upd-step .us-label { min-width: 0; } }
.mailticker { display: flex; flex-direction: column; gap: 2px; max-width: 380px; padding: 4px 14px; margin-right: 4px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-decoration: none; }
.mailticker .mt-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; font-weight: 800; flex: none; }
.mailticker .mt-in .mt-label { color: var(--ok); }
.mailticker .mt-out .mt-label { color: var(--brand-2); }
.mailticker:hover { background: var(--panel-2); text-decoration: none; }
/* ---- Global sökruta ---- */
.searchrow { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 28px; display: flex; align-items: center; gap: 12px; }
.searchbox { position: relative; flex: 1; max-width: 720px; }
/* Snabb mail-panel bredvid sökrutan */
.mailquick-wrap { position: relative; }
.mailquick-wrap .btn { position: relative; white-space: nowrap; }
.mq-badge { display: inline-flex; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 800; align-items: center; justify-content: center; }
.mailquick { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 30; overflow: hidden; }
.mq-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mq-list { max-height: 360px; overflow: auto; }
.mq-item { display: block; padding: 9px 14px; border-bottom: 1px solid var(--line); text-decoration: none; }
.mq-item:last-child { border-bottom: 0; }
.mq-item:hover { background: var(--panel-2); }
.mq-title { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mq-sub { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mq-empty { padding: 16px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.mq-foot { display: block; padding: 10px 14px; text-align: center; font-weight: 600; font-size: 12.5px; border-top: 1px solid var(--line); text-decoration: none; color: var(--brand-2); }
.mq-foot:hover { background: var(--panel-2); }
.searchbox .search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; pointer-events: none; }
.searchbox input { width: 100%; padding: 10px 96px 10px 36px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 14px; background: var(--panel-2); color: var(--ink); }
.searchbox input:focus { outline: none; border-color: var(--brand-2); background: var(--panel); box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
.searchbox .search-hint { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--ink-faint); pointer-events: none; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 60vh; overflow: auto; z-index: 30; padding: 6px; }
.sr-group { padding: 4px 0; }
.sr-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; font-weight: 800; color: var(--ink-faint); padding: 6px 10px 2px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.sr-item:hover { background: var(--panel-2); }
.sr-ic { width: 20px; text-align: center; font-size: 14px; flex: none; }
.sr-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sr-title { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-tag { font-size: 10.5px; font-weight: 700; color: var(--brand-2); background: rgba(23,105,170,.10); padding: 2px 8px; border-radius: 20px; flex: none; }
.sr-empty { padding: 16px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---- PDF-förhandsvisning ---- */
.pdf-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.pdf-modal[hidden] { display: none !important; }
.pdf-backdrop { position: absolute; inset: 0; background: rgba(15,25,40,.55); }
.pdf-panel { position: relative; width: 90vw; height: 92vh; max-width: 1100px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.pdf-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pdf-title { font-weight: 700; font-size: 14px; color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-actions { display: flex; gap: 8px; align-items: center; }
.pdf-frame { flex: 1; width: 100%; border: 0; background: #525659; }
.compose-panel { height: auto; max-width: 640px; }
.compose-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.compose-body .pc-f input, .compose-body .pc-f textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; color: var(--ink); }
.compose-body textarea { min-height: 220px; resize: vertical; }
.mail-atts { font-size: 12.5px; }
.mail-atts-label { color: var(--ink-soft); font-weight: 600; }
.mail-att { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; margin: 2px; }
.mail-att a { color: var(--ink-faint); cursor: pointer; font-weight: 700; text-decoration: none; }
.mail-att a:hover { color: var(--crit); }
/* ---- Väderremsa i header ---- */
.weather { display: flex; gap: 3px; padding: 0 12px; margin-right: 4px; border-right: 1px solid var(--line); cursor: help; }
.wx-day { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 40px; padding: 3px 5px; border-radius: 7px; line-height: 1.1; }
.wx-day .wx-wd { font-size: 10px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .3px; }
.wx-day .wx-ic { font-size: 15px; }
.wx-day .wx-t { font-size: 12px; font-weight: 700; color: var(--ink); }
.wx-day .wx-mm { font-size: 9px; font-weight: 700; color: var(--ink-faint); }
.wx-day .wx-mm.dry { opacity: .4; }
.wx-day.wet-rain { background: rgba(23, 105, 170, .10); }
.wx-day.wet-rain .wx-mm { color: var(--brand-2); }
.wx-day.wet-snow { background: rgba(120, 130, 145, .12); }
.wx-day.today { box-shadow: inset 0 0 0 1.5px var(--brand); }
.wx-day.tomorrow { box-shadow: inset 0 0 0 1px var(--line); }
@media (max-width: 1200px) { .weather .wx-day:nth-child(n+5) { display: none; } }
@media (max-width: 900px) { .weather { display: none; } }
.mailticker .mt-row { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; overflow: hidden; }
.mailticker .mt-row .mt-txt { overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.mailticker .mt-row .mt-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-weight: 700; }
.mailticker .mt-in .mt-dir { color: var(--ok); font-weight: 800; }
.mailticker .mt-out .mt-dir { color: var(--brand-2); font-weight: 800; }
.mailticker .mt-empty { font-size: 12px; color: var(--ink-faint); }
@media (max-width: 1100px) { .mailticker { display: none; } }
.content { padding: 22px 28px 60px; max-width: 1500px; width: 100%; }

/* ---- Kort ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card > .card-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card > .card-head h2 { font-size: 14.5px; margin: 0; font-weight: 700; }
.card > .card-head .count { color: var(--ink-faint); font-weight: 600; font-size: 12.5px; }
.card > .card-head .head-action { margin-left: auto; font-size: 12.5px; }
.card > .card-body { padding: 14px 16px; }
.card.pad > .card-body { padding: 16px; }
.card-body.tight { padding: 0; }
/* ---- Rullgardin (hopfällbara sektioner för integritet) ---- */
.card.collapsible > .card-head { cursor: pointer; user-select: none; }
.card.collapsible > .card-head:hover { background: var(--panel-2); }
.card-chev { color: var(--ink-faint); font-size: 12px; transition: transform .15s; display: inline-block; }
.card.collapsed > .card-head { border-bottom: 0; }
.card.collapsed > .card-head .card-chev { transform: rotate(-90deg); }
.card.collapsed > .card-body { display: none !important; }

/* ---- Grid ---- */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }
@media (max-width: 1200px) { .g-4 { grid-template-columns: repeat(2,1fr);} .g-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 860px) { .app{grid-template-columns:1fr;} .sidebar{position:relative;height:auto;} .g-2,.g-3,.g-4{grid-template-columns:1fr;} .col-span-2{grid-column:auto;} }

/* ---- KPI-brickor ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width:1200px){ .kpis{grid-template-columns:repeat(2,1fr);} }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; }
.kpi .label { font-size: 12px; color: var(--ink-soft); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.kpi .meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.kpi.accent-crit { border-left: 4px solid var(--crit); }
.kpi.accent-warn { border-left: 4px solid var(--warn); }
.kpi.accent-ok { border-left: 4px solid var(--ok); }
.kpi.accent-info { border-left: 4px solid var(--info); }
.kpi.kpi-hover { cursor: help; transition: box-shadow .12s, transform .12s; }
.kpi.kpi-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kpi.kpi-hover::after { content: "ⓘ"; position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--ink-faint); opacity: .55; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: #eef1f6; color: var(--ink-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok{background:var(--ok);} .dot.warn{background:var(--warn);} .dot.crit{background:var(--crit);} .dot.info{background:var(--info);}

/* ---- Tabeller ---- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); font-weight: 700; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; }
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr.clickable:hover { background: var(--panel-2); cursor: pointer; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-faint); }
.strong { font-weight: 700; }
.crit-text { color: var(--crit); font-weight: 700; }
.warn-text { color: var(--warn); font-weight: 700; }
.ok-text { color: var(--ok); font-weight: 700; }
.nowrap { white-space: nowrap; }

/* ---- Listrader (åtgärdslistor) ---- */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: none; }
.row-item.row-click { cursor: pointer; transition: background .12s; }
.row-item.row-click:hover { background: var(--panel-2, rgba(23,105,170,.06)); }
.row-item.row-click:hover .title { color: var(--brand-2); }
.row-item .lead { width: 4px; align-self: stretch; border-radius: 3px; background: var(--line); }
.row-item.sev-hög .lead, .row-item.sev-kritisk .lead { background: var(--crit); }
.row-item.sev-medel .lead { background: var(--warn); }
.row-item.sev-låg .lead { background: var(--info); }
.row-item .body { flex: 1; min-width: 0; }
.row-item .title { font-weight: 600; }
.row-item .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.row-item .right { text-align: right; white-space: nowrap; display:flex; flex-direction:column; align-items:flex-end; gap:4px; }

/* ---- Chart (SVG bars) ---- */
.chart { width: 100%; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.chart-legend .lg { display: flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ---- Knappar ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Progressbar ---- */
.progress { height: 8px; background: #eef1f6; border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-2); }

/* ---- Projektkort ---- */
.pcard-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pcard-head .pno { font-size: 12px; color: var(--ink-faint); font-weight: 700; letter-spacing: .5px; }
.pcard-head h1 { margin: 2px 0 4px; font-size: 22px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px 22px; }
.meta-grid .m .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); font-weight: 700; }
.meta-grid .m .v { font-weight: 600; margin-top: 1px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- Övrigt ---- */
.empty { padding: 22px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-faint); font-weight: 700; margin: 4px 0 10px; }
.pill-legend { display:inline-flex; gap:8px; align-items:center; }
.back-link { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.loading { padding: 40px; text-align: center; color: var(--ink-faint); }
.spin { display:inline-block; width:20px;height:20px;border:2px solid var(--line);border-top-color:var(--brand);border-radius:50%;animation:sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg);} }
.security-banner { background: linear-gradient(90deg,#eef6ff,#f7fbff); border:1px solid #cfe2f7; border-radius:var(--radius); padding:12px 16px; display:flex; gap:12px; align-items:flex-start; margin-bottom:18px; }
.security-banner .ic { font-size:18px; }
.security-banner b { color: var(--brand); }
.toast { position: fixed; bottom: 22px; left: 22px; background: var(--ink); color:#fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size:13px; z-index: 70; opacity:0; transform: translateY(8px); transition: all .2s; }
.toast.show { opacity:1; transform: translateY(0); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--crit); }

/* Reklamations-chip */
.btn.chip-reklam { border-color: #f0c9c9; color: var(--crit); }
.btn.chip-reklam.primary { background: var(--crit); border-color: var(--crit); color: #fff; }

/* ---- Miniräknare (flytande på alla sidor) ---- */
#calc-fab { position: fixed; bottom: 22px; right: 22px; width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 22px; cursor: pointer; box-shadow: var(--shadow-lg); z-index: 60; display: grid; place-items: center; transition: transform .15s, background .15s; }
#calc-fab:hover { background: var(--brand-2); transform: translateY(-2px); }
#calc-panel { position: fixed; bottom: 84px; right: 22px; width: 264px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 65; overflow: hidden; }
#calc-panel .calc-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); cursor: move; user-select: none; }
#calc-panel .calc-head b { font-size: 13px; }
#calc-panel .calc-head .x { margin-left: auto; border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-faint); line-height: 1; }
#calc-expr { padding: 8px 14px 0; text-align: right; font-size: 12px; color: var(--ink-faint); min-height: 16px; font-variant-numeric: tabular-nums; word-break: break-all; }
#calc-display { padding: 2px 14px 10px; text-align: right; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-all; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); }
.calc-grid button { border: none; background: var(--panel); padding: 15px 0; font-size: 17px; cursor: pointer; font-weight: 600; }
.calc-grid button:hover { background: var(--panel-2); }
.calc-grid button.op { color: var(--brand-2); }
.calc-grid button.eq { background: var(--brand); color: #fff; }
.calc-grid button.eq:hover { background: var(--brand-2); }
.calc-grid button.fn { color: var(--crit); font-size: 15px; }
.calc-grid button.wide { grid-column: span 2; }

/* ---- Trello-säljtavla (kanban) ---- */
.tboard { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 14px; }
.tcol { min-width: 274px; max-width: 274px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.tcol-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; font-weight: 700; font-size: 13px; }
.tcol-head .cnt { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font-size: 12px; color: var(--ink-faint); }
.tcol-cards { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; box-shadow: var(--shadow); text-decoration: none; display: block; color: var(--ink); }
.tcard:hover { border-color: var(--brand-2); box-shadow: var(--shadow-lg); text-decoration: none; }
.tcard .tc-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.tcard .tc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.tcard .tc-due { font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #eef1f6; }
.tcard .tc-due.overdue { background: var(--crit-bg); color: var(--crit); }
.tcard .tc-due.soon { background: var(--warn-bg); color: var(--warn); }
.tcard .tc-mem { margin-left: auto; display: inline-flex; gap: 3px; }
.tcard .tc-mem span { background: var(--brand); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 9px; font-weight: 700; }
.tcol-more { text-align: center; font-size: 12px; color: var(--ink-faint); padding: 6px; }

/* ---- Offerter / säljpipeline ---- */
.qk { font-size: 11px; color: var(--ink-faint); font-weight: 700; margin-bottom: 3px; }
.q-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 1100px) { .q-board { grid-template-columns: repeat(2, 1fr); } }
.q-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 80px; }
.q-colhead { font-size: 12px; font-weight: 700; color: var(--ink-soft); padding: 4px 6px 8px; display: flex; justify-content: space-between; }
.q-colhead span { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; color: var(--ink-faint); }
.q-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.q-card:hover { border-color: var(--brand-2); box-shadow: var(--shadow-lg); }
.q-card .q-title { font-weight: 600; font-size: 13px; }
.q-card .q-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.q-card .q-follow { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; font-weight: 600; }
.q-card .q-follow.due { color: var(--crit); }
.q-empty { color: var(--ink-faint); font-size: 12px; text-align: center; padding: 8px 0; }

/* ---- Offertunderlag (PDF-uppladdning) ---- */
.qf-list { display: flex; flex-direction: column; }
.qf-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qf-row:last-child { border-bottom: 0; }
.qf-ic { font-size: 20px; line-height: 1; margin-top: 1px; }
.qf-main { flex: 1; min-width: 0; }
.qf-name { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.qf-name a { color: var(--brand-2); text-decoration: none; }
.qf-name a:hover { text-decoration: underline; }
.qf-meta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.qf-ok { color: var(--ok); font-weight: 600; }
.qf-prev { margin-top: 6px; }
.qf-prev summary { font-size: 12px; color: var(--ink-soft); cursor: pointer; font-weight: 600; }
.qf-prev pre { margin: 6px 0 0; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; color: var(--ink); }
.qf-del { color: var(--ink-faint); }
.qf-del:hover { color: var(--crit); border-color: var(--crit); }

/* ---- Övervakning ---- */
.mon-terms { display: flex; flex-wrap: wrap; gap: 8px; }
.mon-term { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--ink); }
.mon-term a { color: var(--ink-faint); cursor: pointer; font-weight: 700; text-decoration: none; }
.mon-term a:hover { color: var(--crit); }

/* ---- Pris, moms & ROT ---- */
.pc-types { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pc-type { padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink-soft); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.pc-type:hover { border-color: var(--brand-2); }
.pc-type.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pc-row { display: flex; gap: 14px; flex-wrap: wrap; }
.pc-costgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 640px) { .pc-costgrid { grid-template-columns: 1fr; } }
.pc-f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.pc-f input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; color: var(--ink); width: 100%; }
.pc-sum { margin-top: 12px; padding: 9px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; color: var(--ink-soft); display: flex; justify-content: space-between; }
.pc-sum b { color: var(--ink); font-size: 15px; }
.pc-rotbox { margin-top: 12px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 10px; }
.pc-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.pc-check input { width: 16px; height: 16px; }
.pc-preview { margin-top: 14px; }
.pc-lines { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-width: 460px; }
.pc-lines > div { display: flex; justify-content: space-between; padding: 9px 14px; font-size: 13px; color: var(--ink-soft); }
.pc-lines > div:not(:last-child) { border-bottom: 1px solid var(--line); }
.pc-lines > div b { color: var(--ink); font-weight: 600; }
.pc-lines .pc-subrow span { color: var(--ink); font-weight: 700; }
.pc-lines .pc-subrow b { font-weight: 800; }
.pc-final { background: var(--brand); }
.pc-final span, .pc-final b { color: #fff !important; font-weight: 800 !important; font-size: 15px !important; }

/* ---- Kalender-tidslinje ---- */
.tl-jump { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tl-jump a { font-size: 12.5px; font-weight: 600; padding: 6px 11px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--ink-soft); }
.tl-jump a:hover { background: var(--panel-2); text-decoration: none; }
.tl-jump a.today { background: var(--brand); color: #fff; border-color: var(--brand); }
.timeline { position: relative; margin-left: 8px; }
.timeline::before { content: ""; position: absolute; left: 92px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-day { position: relative; margin-bottom: 6px; }
.tl-dayhead { display: flex; align-items: center; gap: 12px; padding: 14px 0 8px; position: sticky; top: 58px; background: linear-gradient(var(--bg) 70%, transparent); z-index: 2; }
.tl-dayhead .dot { position: absolute; left: 86px; width: 14px; height: 14px; border-radius: 50%; background: var(--brand); border: 3px solid var(--bg); }
.tl-dayhead .lbl { margin-left: 112px; font-weight: 700; text-transform: capitalize; }
.tl-dayhead .rel { color: var(--ink-faint); font-size: 12.5px; font-weight: 600; }
.tl-day.is-today .tl-dayhead .dot { background: var(--crit); }
.tl-event { display: flex; align-items: stretch; gap: 0; margin: 0 0 8px; }
.tl-event .tl-time { width: 78px; flex: none; text-align: right; padding: 12px 12px 0 0; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.tl-event .tl-node { width: 28px; flex: none; position: relative; }
.tl-event .tl-node::before { content: ""; position: absolute; left: 9px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--brand-2); }
.tl-event.money .tl-node::before { border-color: var(--crit); background: var(--crit); }
.tl-event .tl-card { flex: 1; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand-2); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); }
.tl-event.money .tl-card { border-left-color: var(--crit); }
.tl-event .tl-card .t { font-weight: 600; }
.tl-event .tl-card .s { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.tl-event .tl-card .lnk { float: right; font-size: 12px; }

/* ---- Produktion: projektkort med hover-status ---- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.proj-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 15px; cursor: default; }
.proj-card.h-varning { border-left-color: var(--warn); }
.proj-card.h-kritisk { border-left-color: var(--crit); }
.proj-card.h-ok { border-left-color: var(--ok); }
.proj-card .pc-head { display: flex; align-items: center; gap: 8px; }
.proj-card .pc-no { font-size: 11px; font-weight: 700; color: var(--ink-faint); letter-spacing: .5px; }
.proj-card .pc-name { font-weight: 700; margin: 3px 0 2px; }
.proj-card .pc-meta { font-size: 12px; color: var(--ink-soft); }
.proj-card .pc-badges { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.proj-tip { position: absolute; top: calc(100% + 6px); left: -1px; right: -1px; z-index: 45; background: #eef1f6; border: 1px solid #d4dae6; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px; display: none; }
#global-tip { position: fixed; z-index: 80; display: none; max-width: 320px; background: #eef1f6; border: 1px solid #d4dae6; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: 13px; pointer-events: none; }
#global-tip .tip-sec { margin-bottom: 9px; } #global-tip .tip-sec:last-child { margin-bottom: 0; }
#global-tip .tip-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); font-weight: 700; margin-bottom: 3px; }
#global-tip .tip-row { font-size: 12.5px; padding: 2px 0; display: flex; gap: 8px; align-items: baseline; }
#global-tip .tip-row .lead2 { width: 6px; height: 6px; border-radius: 50%; flex: none; margin-top: 5px; }
.proj-card:hover { box-shadow: var(--shadow-lg); border-color: var(--brand-2); }
.proj-card:hover .proj-tip { display: block; }
.proj-tip .tip-sec { margin-bottom: 9px; }
.proj-tip .tip-sec:last-child { margin-bottom: 0; }
.proj-tip .tip-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); font-weight: 700; margin-bottom: 3px; }
.proj-tip .tip-row { font-size: 12.5px; padding: 2px 0; display: flex; gap: 8px; align-items: baseline; }
.proj-tip .tip-row .lead2 { width: 6px; height: 6px; border-radius: 50%; flex: none; margin-top: 5px; }
.proj-tip .ok { color: var(--ok); font-weight: 600; }

/* ---- Inloggningsskärm (åtkomst utifrån) ---- */
.auth-screen { position: fixed; inset: 0; z-index: 200000; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f2740, #14314a); padding: 20px; }
.auth-screen[hidden] { display: none !important; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.4); padding: 28px 26px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.auth-name { font-weight: 800; font-size: 16px; color: var(--ink); }
.auth-co { font-size: 12px; color: var(--ink-soft); }
.auth-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.auth-card input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font: inherit; margin-bottom: 10px; box-sizing: border-box; }
.auth-card input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(23,105,170,.14); }
.auth-btn { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.auth-err { color: var(--crit); font-size: 12.5px; margin-top: 10px; }
.auth-err[hidden] { display: none; }

/* ---- Att fakturera-flik ---- */
.inv-list { display: flex; flex-direction: column; }
.inv-item { display: flex; gap: 12px; align-items: stretch; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.inv-item:last-child { border-bottom: none; }
.inv-item.done { background: var(--ok-bg); }
.inv-main { flex: 1; min-width: 0; text-decoration: none; color: var(--ink); display: block; }
.inv-main:hover .inv-subj { color: var(--brand-2); text-decoration: underline; }
.inv-top { display: flex; align-items: baseline; gap: 12px; }
.inv-subj { font-weight: 700; }
.inv-date { margin-left: auto; font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.inv-prev { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.inv-done { font-size: 11.5px; color: var(--ok); font-weight: 700; margin-top: 4px; }
.inv-act { display: flex; align-items: center; flex: none; }
