:root {
  --bg: #f4f7fb;
  --card: #fff;
  --text: #101828;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #214e6f;
  --accent2: #eaf2f8;
  --ok: #027a48;
  --warn: #b54708;
  --bad: #b42318;
  --shadow: 0 16px 40px rgba(16,24,40,.08);
  --radius: 16px;
  --topbar-bg: rgba(255,255,255,.94);
  --input-bg: #fff;
  --table-head-bg: #f9fafb;
  --table-row-hover: #f4f7fb;
}

/* Forced dark mode */
body[data-theme="dark"] {
  --bg: #0f1117;
  --card: #1a1d27;
  --text: #e4e7ef;
  --muted: #8d95a8;
  --line: #2a2f3d;
  --accent: #4e9ecf;
  --accent2: #1a2a38;
  --ok: #12b76a;
  --warn: #f79009;
  --bad: #f04438;
  --shadow: 0 16px 40px rgba(0,0,0,.4);
  --topbar-bg: rgba(26,29,39,.96);
  --input-bg: #22263a;
  --table-head-bg: #1e2132;
  --table-row-hover: #22263a;
}

/* System dark — follows OS preference only when data-theme="system" */
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] {
    --bg: #0f1117;
    --card: #1a1d27;
    --text: #e4e7ef;
    --muted: #8d95a8;
    --line: #2a2f3d;
    --accent: #4e9ecf;
    --accent2: #1a2a38;
    --ok: #12b76a;
    --warn: #f79009;
    --bad: #f04438;
    --shadow: 0 16px 40px rgba(0,0,0,.4);
    --topbar-bg: rgba(26,29,39,.96);
    --input-bg: #22263a;
    --table-head-bg: #1e2132;
    --table-row-hover: #22263a;
  }
}

/* ── Explicit dark overrides (belt-and-suspenders for forced dark) ── */
/* CSS variables alone may not override hardcoded colors; these do.   */
body[data-theme="dark"] { background: #0f1117 !important; color: #e4e7ef !important; }
body[data-theme="dark"] .topbar { background: rgba(26,29,39,.96) !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .card { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .menu-dropdown { background: #1a1d27 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .nav-link { color: #e4e7ef !important; }
body[data-theme="dark"] .nav-link:hover { background: #22263a !important; color: #e4e7ef !important; }
body[data-theme="dark"] .form-input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .portal-table thead th { background: #1e2132 !important; color: #8d95a8 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .portal-table tbody tr { border-color: #2a2f3d !important; }
body[data-theme="dark"] .portal-table tbody tr:hover { background: #22263a !important; }
body[data-theme="dark"] .portal-table td { color: #e4e7ef !important; }
body[data-theme="dark"] .page-heading { color: #4e9ecf !important; }
body[data-theme="dark"] .topbar-user { color: #8d95a8 !important; }
body[data-theme="dark"] .brand-tagline { color: #8d95a8 !important; }
body[data-theme="dark"] .btn { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #4e9ecf !important; }
body[data-theme="dark"] .btn-primary { background: #4e9ecf !important; border-color: #4e9ecf !important; color: #0f1117 !important; }
body[data-theme="dark"] .flash-success { background: #0d2b1d !important; border-color: #12b76a !important; color: #12b76a !important; }
body[data-theme="dark"] .flash-error { background: #2b0d0d !important; border-color: #f04438 !important; color: #f04438 !important; }
body[data-theme="dark"] .flash-info { background: #0d1e2b !important; border-color: #4e9ecf !important; color: #4e9ecf !important; }
body[data-theme="dark"] .nav-divider { border-color: #2a2f3d !important; }
body[data-theme="dark"] .nav-section { border-color: #2a2f3d !important; }
body[data-theme="dark"] .nav-section-label { color: #8d95a8 !important; }
body[data-theme="dark"] .form-label { color: #e4e7ef !important; }

/* Same explicit overrides for system dark */
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] { background: #0f1117 !important; color: #e4e7ef !important; }
  body[data-theme="system"] .topbar { background: rgba(26,29,39,.96) !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .card { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .menu-dropdown { background: #1a1d27 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .nav-link { color: #e4e7ef !important; }
  body[data-theme="system"] .nav-link:hover { background: #22263a !important; }
  body[data-theme="system"] .form-input,
  body[data-theme="system"] select,
  body[data-theme="system"] textarea { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .portal-table thead th { background: #1e2132 !important; color: #8d95a8 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .portal-table tbody tr { border-color: #2a2f3d !important; }
  body[data-theme="system"] .portal-table tbody tr:hover { background: #22263a !important; }
  body[data-theme="system"] .portal-table td { color: #e4e7ef !important; }
  body[data-theme="system"] .page-heading { color: #4e9ecf !important; }
  body[data-theme="system"] .btn { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #4e9ecf !important; }
  body[data-theme="system"] .btn-primary { background: #4e9ecf !important; border-color: #4e9ecf !important; color: #0f1117 !important; }
  body[data-theme="system"] .form-label { color: #e4e7ef !important; }
  body[data-theme="system"] .nav-section { border-color: #2a2f3d !important; }
  body[data-theme="system"] .nav-section-label { color: #8d95a8 !important; }
}

* { box-sizing: border-box; }

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

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

/* ── Topbar ────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo {
  max-height: 38px;
  width: auto;
  display: block;
}

.brand-tagline {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .02em;
}

.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-user {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Buttons ───────────────────────────────────────── */

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s;
}

.btn:hover { background: var(--accent2); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { opacity: .9; background: var(--accent); }

/* ── Hamburger menu ────────────────────────────────── */

.menu-wrap {
  position: relative;
}

.menu-toggle {
  border: 1px solid var(--line);
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 22px 55px rgba(16,24,40,.18);
  z-index: 120;
  flex-direction: column;
  gap: 3px;
}

.menu-dropdown.open { display: flex; }

.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  transition: background .1s;
}

.nav-link:hover { background: var(--accent2); }
.nav-link.active { background: var(--accent); color: #fff; }

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.nav-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.nav-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.nav-section-label {
  display: block;
  padding: 4px 12px 2px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: default;
  user-select: none;
}

/* ── Page container ────────────────────────────────── */

.page {
  max-width: 1780px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Page heading ──────────────────────────────────── */

.page-heading {
  margin: 0 0 22px;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
}

/* ── Cards ─────────────────────────────────────────── */

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

/* ── Stat grid ─────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-card strong {
  display: block;
  font-size: 30px;
  color: var(--accent);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 5px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

a.stat-card {
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}

a.stat-card:hover {
  border-color: #a8bfd4;
  box-shadow: 0 20px 50px rgba(16,24,40,.12);
}

.big-action-warn {
  border-color: #fedf89;
  background: #fffdf5;
}

/* ── Big actions grid ──────────────────────────────── */

.section-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 12px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.big-action {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: border-color .15s, box-shadow .15s;
}

.big-action:hover {
  border-color: #a8bfd4;
  box-shadow: 0 20px 50px rgba(16,24,40,.12);
}

.big-action strong {
  display: block;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 5px;
}

.big-action span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* ── Workflow card ─────────────────────────────────── */

.workflow-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.workflow-card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
}

.workflow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #344054;
}

.workflow-step b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
}

.workflow-tip {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

/* ── Form elements ─────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.form-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input-bg);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33,78,111,.12);
}

.form-input.is-invalid { border-color: var(--bad); }

.form-error {
  margin-top: 5px;
  color: var(--bad);
  font-size: 12px;
}

/* ── Login page ────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}


.login-brand h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.btn-login {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .15s;
}

.btn-login:hover { opacity: .88; }

/* ── Status / badge pills ──────────────────────────── */

.badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}

.badge-ok  { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.badge-warn { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.badge-bad  { background: #fff4f2; color: #b42318; border-color: #fecdca; }
.badge-info { background: #eff8ff; color: #175cd3; border-color: #b2ddff; }

/* ── Warn box ──────────────────────────────────────── */

.warn-box {
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #7a4b00;
  padding: 12px 14px;
  border-radius: 13px;
  font-size: 13px;
  margin-bottom: 20px;
}

/* ── Flash messages ────────────────────────────────── */

.flash-success,
.flash-error {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 18px;
}

.flash-success {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: #027a48;
}

.flash-info {
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #7a4b00;
}

.flash-error {
  background: #fff4f2;
  border: 1px solid #fecdca;
  color: #b42318;
}

/* ── Register layout ───────────────────────────────── */

.register-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.register-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.register-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.register-detail {
  position: sticky;
  top: 74px;
}

/* ── Filter bar ────────────────────────────────────── */

.filter-bar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.filter-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-search {
  flex: 1;
  min-width: 180px;
}

.filter-status {
  width: 190px;
  flex-shrink: 0;
}

/* ── Portal table ──────────────────────────────────── */

.table-wrap { padding: 0; overflow: hidden; }

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.portal-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--table-head-bg);
}

.portal-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background .1s;
}

.portal-table tbody tr:last-child { border-bottom: 0; }
.portal-table tbody tr:hover { background: var(--table-row-hover); }
.portal-table tbody tr.row-active { background: var(--accent2); }

.portal-table td {
  padding: 11px 14px;
  vertical-align: middle;
  color: var(--text);
}

.customer-no-tag {
  display: inline-block;
  background: var(--accent2);
  color: var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .03em;
}

.text-muted { color: var(--muted); font-size: 12px; }

.table-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.table-link:hover { opacity: .75; }

.card-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.card-empty p { margin: 0 0 16px; font-size: 14px; }

/* ── Pagination ────────────────────────────────────── */

.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.pagination-info {
  font-size: 12px;
  color: var(--muted);
}

.pagination {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.page-item {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: background .1s;
}

.page-item:hover { background: var(--accent2); }
.page-item-active { background: var(--accent); color: #fff; border-color: var(--accent); cursor: default; }
.page-item-disabled { color: var(--muted); cursor: default; }

/* ── Detail panel ──────────────────────────────────── */

.detail-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-section-title {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  margin: 16px 0 8px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid #f0f4f8;
}

.detail-row span:first-child {
  color: var(--muted);
  flex-shrink: 0;
  width: 130px;
}

.detail-row span:last-child {
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.detail-actions {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
}

.detail-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 32px 16px;
}

/* ── Form page ─────────────────────────────────────── */

.form-page {
  max-width: 820px;
}

.form-card {
  padding: 28px 32px;
}

.form-section-title {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ── Misc ──────────────────────────────────────────── */

.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 16px;
}

.back-link:hover { color: var(--accent); }

.btn-danger {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}

.btn-danger:hover { opacity: .88; background: var(--bad); }

.req { color: var(--bad); }

/* ── Info box (read-only context, e.g. agreement forms) */

.info-box {
  background: #f0f7ff;
  border: 1px solid #b2ddff;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
}

/* ── Agreement number tag ──────────────────────────── */

.agreement-no-tag {
  display: inline-block;
  background: #eff8ff;
  color: #175cd3;
  border: 1px solid #b2ddff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .03em;
}

/* ── Kundens avtal section ─────────────────────────── */

.agreements-section {
  margin-top: 20px;
  padding-top: 4px;
}

.agreement-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafbfd;
}

.agreement-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
}

/* ── Kundens maskiner section ──────────────────────── */

.machines-section {
  margin-top: 20px;
  padding-top: 4px;
}

.machines-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.machine-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafbfd;
}

.machine-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 1200px) {
  .stat-grid      { grid-template-columns: repeat(2, 1fr); }
  .actions-grid   { grid-template-columns: repeat(2, 1fr); }
  .register-layout { grid-template-columns: 1fr; }
  .register-detail { position: static; }
}

@media (max-width: 700px) {
  .topbar         { flex-wrap: wrap; gap: 10px; }
  .topbar-user    { display: none; }
  .stat-grid      { grid-template-columns: 1fr 1fr; }
  .actions-grid   { grid-template-columns: 1fr; }
  .page           { padding: 14px; }
  .login-card     { padding: 28px 20px; }
  .form-grid-2    { grid-template-columns: 1fr; }
  .filter-status  { width: 100%; }
  .form-card      { padding: 20px 16px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   NYHETSFLÖDE — news feed module styling
   ═══════════════════════════════════════════════════════════════════════ */

.news-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.news-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 6px rgba(16,24,40,0.05);
  transition: box-shadow 0.15s;
}
.news-card:hover {
  box-shadow: 0 6px 18px rgba(16,24,40,0.09);
}
.news-card.news-card-affecting {
  border-left: 4px solid var(--warn);
}

.news-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.news-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.news-card-source {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.news-card-category {
  font-size: 11px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 6px;
}
.news-card-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.news-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.4;
}
.news-card-title-link {
  color: var(--accent);
  text-decoration: none;
}
.news-card-title-link:hover { text-decoration: underline; }

.news-card-summary {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  line-height: 1.55;
}
.news-card-action {
  font-size: 12.5px;
  background: var(--accent2);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 7px 12px;
  color: var(--text);
  margin-top: 6px;
}
.news-card-action-label {
  font-weight: 700;
  margin-right: 4px;
}
.news-card-details {
  margin-top: 8px;
}

/* Dark mode */
body[data-theme="dark"] .news-card { background: #1a1d27 !important; border-color: #2a2f3d !important; box-shadow: none !important; }
body[data-theme="dark"] .news-card.news-card-affecting { border-left-color: #f79009 !important; }
body[data-theme="dark"] .news-card-action { background: #1a2a38 !important; }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .news-card { background: #1a1d27 !important; border-color: #2a2f3d !important; box-shadow: none !important; }
  body[data-theme="system"] .news-card-action { background: #1a2a38 !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   STITCH LAYOUT SHELL — sidebar + topbar
   Added to replace the old hamburger-menu topbar pattern.
   Colors from _stitch_reference/DESIGN.md
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.portal-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 260px;
  background: #0b2447;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 0;
  flex-shrink: 0;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  transition: background 0.13s;
  flex: 1;
  min-width: 0;
}
.sidebar-brand:hover {
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}
.sidebar-brand-mark {
  display: flex;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,0.13);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-brand-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-sub {
  display: block;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.40);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.sidebar-nav-section {
  margin-bottom: 18px;
}
.sidebar-nav-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.55);
  padding: 0 12px;
  margin-bottom: 3px;
}
.sidebar-nav-link {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  transition: background 0.13s, color 0.13s;
  border-left: 3px solid transparent;
  line-height: 1.3;
}
.sidebar-nav-link:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  text-decoration: none;
}
.sidebar-nav-link.active {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  font-weight: 700;
  border-left-color: #5ed4fd;
}
.sidebar-nav-link-disabled {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.22);
  cursor: default;
  border-left: 3px solid transparent;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sidebar-system-status {
  display: flex;
  align-items: center;
  gap: 7px;
}
.sidebar-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #5ed4fd;
  flex-shrink: 0;
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.sidebar-status-text {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

/* ── Portal shell ─────────────────────────────────────────────────────── */
.portal-shell {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/*
 * .page uses margin:0 auto for block centering, but inside a flex column
 * container it sizes to content-width and centers — causing the page to
 * shrink to a narrow column when collapsible sections are hidden.
 * Adding width:100% restores correct full-width block behavior.
 */
.portal-shell > .page {
  width: 100%;
  box-sizing: border-box;
}

/* ── Portal topbar ────────────────────────────────────────────────────── */
.portal-topbar {
  position: sticky;
  top: 0;
  height: 64px;
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 0 var(--line), 0 2px 12px rgba(16,24,40,.04);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 100;
  flex-shrink: 0;
}
.portal-topbar-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.portal-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mobile hamburger — hidden on desktop */
.topbar-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  color: var(--text);
  transition: background 0.12s;
  line-height: 0;
}
.topbar-sidebar-toggle:hover { background: var(--accent2); }

/* User name (compact, no pill) */
.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Avatar button — circular, far right */
.topbar-avatar-wrap {
  position: relative;
  display: inline-flex;
  margin-left: 4px;
}
.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.topbar-avatar:hover,
.topbar-avatar-wrap.open .topbar-avatar {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11,36,71,0.10);
}

/* Avatar dropdown menu */
.topbar-avatar-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 200px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(16,24,40,0.12);
  z-index: 300;
  overflow: hidden;
  padding: 6px 0;
}
.topbar-avatar-wrap.open .topbar-avatar-menu { display: block; }
.topbar-avatar-menu-name {
  padding: 10px 16px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-avatar-menu-role {
  padding: 0 16px 10px;
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
}
.topbar-avatar-menu-divider {
  height: 1px;
  background: var(--line);
  margin: 0 0 6px;
}
.topbar-avatar-menu-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.topbar-avatar-menu-item:hover { background: var(--accent2); }
.topbar-avatar-menu-logout { color: #e53e3e; }
.topbar-avatar-menu-logout:hover { background: #fff5f5; color: #c53030; }

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Notification button */
.notif-wrap {
  position: relative;
  display: inline-flex;
}
.topbar-notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-notif-btn:hover {
  background: var(--accent2);
  color: var(--accent);
}
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #e53e3e;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* Notification dropdown */
.notif-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(16,24,40,.12);
  z-index: 300;
  overflow: hidden;
}
.notif-menu-header {
  padding: 11px 14px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.notif-menu-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}
.notif-read-all-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.notif-row {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.notif-row--unread {
  background: var(--accent2);
}
.notif-row-msg {
  color: var(--text);
  line-height: 1.45;
}
.notif-row-time {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.notif-read-one-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-top: 3px;
}
.notif-empty {
  padding: 16px 14px;
  color: var(--muted);
  font-size: 12px;
}
.notif-menu-footer {
  padding: 9px 14px;
}
.notif-footer-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.notif-footer-link:hover { text-decoration: underline; }


/* Fix sticky register-detail offset for 64px topbar */
.register-detail { top: 76px; }

/* ── Sidebar backdrop (mobile overlay) ───────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 190;
}

/* ── Mobile: sidebar slides in, shell fills full width ───────────────── */
@media (max-width: 900px) {
  .portal-sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .portal-sidebar.sidebar-open {
    transform: translateX(0);
  }
  .sidebar-backdrop.sidebar-open {
    display: block;
  }
  .portal-shell {
    margin-left: 0;
  }
  .portal-topbar {
    padding: 0 16px;
  }
  .topbar-sidebar-toggle {
    display: block;
  }
}

/* ── Sidebar brand row (brand + collapse button) ─────────────────────── */
.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 12px 16px 20px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* Collapse toggle button */
.sidebar-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.45);
  transition: background 0.13s, color 0.13s, transform 0.22s;
  flex-shrink: 0;
  margin-left: 6px;
}
.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,0.09);
  color: #ffffff;
}
.sidebar-collapse-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
  transition: transform 0.22s ease;
  /* ‹ chevron pointing left = "collapse left" */
}

/* ── Nav badge (letter abbreviation shown in collapsed mode) ─────────── */
.sidebar-nav-badge {
  display: none; /* hidden in expanded mode */
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.13s, color 0.13s;
}
/* Active badge gets clinical blue tint */
.sidebar-nav-link.active .sidebar-nav-badge {
  background: rgba(94,212,253,0.18);
  color: #5ed4fd;
}

/* ── Collapsed sidebar state ─────────────────────────────────────────── */
.portal-sidebar.sidebar-collapsed {
  width: 72px;
}
.portal-sidebar.sidebar-collapsed .sidebar-collapse-icon {
  transform: rotate(180deg); /* chevron flips to point right = "expand" */
}
.portal-sidebar.sidebar-collapsed .sidebar-brand-text {
  display: none;
}
.portal-sidebar.sidebar-collapsed .sidebar-nav-label {
  display: none;
}
/* Hide text, show badge */
.portal-sidebar.sidebar-collapsed .sidebar-nav-text {
  display: none;
}
.portal-sidebar.sidebar-collapsed .sidebar-nav-badge {
  display: flex;
}
.portal-sidebar.sidebar-collapsed .sidebar-nav-link,
.portal-sidebar.sidebar-collapsed .sidebar-nav-link-disabled {
  justify-content: center;
  padding: 8px 0;
}
/* Hover badge highlight */
.portal-sidebar.sidebar-collapsed .sidebar-nav-link:hover .sidebar-nav-badge {
  background: rgba(255,255,255,0.16);
  color: #ffffff;
}
/* Disabled badge is more muted */
.portal-sidebar.sidebar-collapsed .sidebar-nav-link-disabled .sidebar-nav-badge {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.22);
}
.portal-sidebar.sidebar-collapsed .sidebar-status-text {
  display: none;
}
.portal-sidebar.sidebar-collapsed .sidebar-footer {
  padding: 14px 0;
  display: flex;
  justify-content: center;
}
.portal-sidebar.sidebar-collapsed .sidebar-system-status {
  justify-content: center;
}
.portal-sidebar.sidebar-collapsed .sidebar-brand-row {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.portal-sidebar.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}
.portal-sidebar.sidebar-collapsed .sidebar-collapse-btn {
  margin-left: 0;
}

/* Shell shifts left when sidebar collapses */
.portal-shell.shell-sidebar-collapsed {
  margin-left: 72px;
}

/* Smooth transition for sidebar width and shell margin */
.portal-sidebar {
  transition: width 0.22s ease;
}
.portal-shell {
  transition: margin-left 0.22s ease;
}

/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD v3 — glass header + KPI polish
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Glass greeting header ────────────────────────────────────────────── */
.dash-glass-header {
  margin: -24px -24px 28px;          /* bleed to page edges */
  padding: 40px 32px 36px;
  background: linear-gradient(135deg,
    rgba(11,36,71,0.06) 0%,
    rgba(94,212,253,0.07) 50%,
    rgba(11,36,71,0.04) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(11,36,71,0.08);
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
}

/* Soft ambient glow orb — top-right */
.dash-glass-header::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -40px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(94,212,253,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.dash-glass-header-inner {
  position: relative;
  z-index: 1;
}

.dash-glass-greeting {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.dash-glass-date {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 500;
}

.dash-glass-context {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-glass-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.dash-glass-chip-warn {
  background: rgba(181,71,8,0.10);
  color: #b54708;
  border: 1px solid rgba(181,71,8,0.18);
}

.dash-glass-chip-info {
  background: rgba(11,36,71,0.08);
  color: var(--accent);
  border: 1px solid rgba(11,36,71,0.12);
}

/* Dark mode */
body[data-theme="dark"] .dash-glass-header {
  background: linear-gradient(135deg,
    rgba(94,212,253,0.05) 0%,
    rgba(78,158,207,0.07) 50%,
    rgba(0,0,0,0) 100%
  ) !important;
  border-bottom-color: rgba(94,212,253,0.08) !important;
}
body[data-theme="dark"] .dash-glass-header::before {
  background: radial-gradient(circle, rgba(94,212,253,0.08) 0%, transparent 70%) !important;
}
body[data-theme="dark"] .dash-glass-greeting { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-glass-date     { color: #8d95a8 !important; }
body[data-theme="dark"] .dash-glass-chip-warn {
  background: rgba(247,144,9,0.12) !important;
  color: #f79009 !important;
  border-color: rgba(247,144,9,0.20) !important;
}
body[data-theme="dark"] .dash-glass-chip-info {
  background: rgba(78,158,207,0.12) !important;
  color: #4e9ecf !important;
  border-color: rgba(78,158,207,0.20) !important;
}

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .dash-glass-header {
    background: linear-gradient(135deg, rgba(94,212,253,0.05) 0%, rgba(78,158,207,0.07) 50%, rgba(0,0,0,0) 100%) !important;
    border-bottom-color: rgba(94,212,253,0.08) !important;
  }
  body[data-theme="system"] .dash-glass-greeting { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-glass-date     { color: #8d95a8 !important; }
  body[data-theme="system"] .dash-glass-chip-warn  { background: rgba(247,144,9,0.12) !important; color: #f79009 !important; border-color: rgba(247,144,9,0.20) !important; }
  body[data-theme="system"] .dash-glass-chip-info  { background: rgba(78,158,207,0.12) !important; color: #4e9ecf !important; border-color: rgba(78,158,207,0.20) !important; }
}

/* Mobile */
@media (max-width: 700px) {
  .dash-glass-header {
    margin: -14px -14px 24px;
    padding: 28px 18px 24px;
    border-radius: 0 0 20px 20px;
  }
  .dash-glass-greeting { font-size: 24px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD v2 — premium internal portal styling
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Welcome header ───────────────────────────────────────────────────── */
.dash-welcome {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.dash-welcome-greeting {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  line-height: 1.2;
}
.dash-welcome-date {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ── Inline widget menu ───────────────────────────────────────────────── */
.dash-widget-menu-wrap {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
}
.dash-widget-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s, color 0.12s;
  box-shadow: 0 1px 4px rgba(16,24,40,0.08);
}
.dash-grid-item:hover .dash-widget-menu-btn,
.dash-widget-menu-wrap:focus-within .dash-widget-menu-btn {
  opacity: 1;
}
/* Always visible on touch devices */
@media (hover: none) {
  .dash-widget-menu-btn { opacity: 1; }
}
.dash-widget-menu-btn:hover {
  background: var(--accent2);
  color: var(--accent);
}
.dash-widget-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16,24,40,0.13);
  z-index: 50;
  overflow: hidden;
  padding: 4px 0;
}
.dash-widget-menu.open { display: block; }
.dash-widget-menu.flip-up {
  top: auto;
  bottom: calc(100% + 4px);
}
.dash-widget-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.11s;
  white-space: nowrap;
}
.dash-widget-menu-item:hover { background: var(--accent2); }
.dash-widget-menu-item--danger { color: #e53e3e; }
.dash-widget-menu-item--danger:hover { background: #fff5f5; color: #c53030; }

/* Dark mode */
body[data-theme="dark"] .dash-widget-menu-btn  { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #8d95a8 !important; }
body[data-theme="dark"] .dash-widget-menu-btn:hover { background: #22263a !important; color: #4e9ecf !important; }
body[data-theme="dark"] .dash-widget-menu       { background: #1e2132 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-widget-menu-item  { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-widget-menu-item:hover { background: #22263a !important; }
body[data-theme="dark"] .dash-widget-menu-item--danger { color: #fc8181 !important; }
body[data-theme="dark"] .dash-widget-menu-item--danger:hover { background: #2a1a1a !important; }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .dash-widget-menu-btn  { background: #1a1d27 !important; border-color: #2a2f3d !important; color: #8d95a8 !important; }
  body[data-theme="system"] .dash-widget-menu-btn:hover { background: #22263a !important; color: #4e9ecf !important; }
  body[data-theme="system"] .dash-widget-menu       { background: #1e2132 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-widget-menu-item  { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-widget-menu-item:hover { background: #22263a !important; }
  body[data-theme="system"] .dash-widget-menu-item--danger { color: #fc8181 !important; }
}

/* ── Dashboard grid ───────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  align-items: start;
}
.dash-grid-item {
  grid-column: span 12; /* safe fallback */
  min-width: 0;
  position: relative;
}
.dash-grid-item--small  { grid-column: span 3; }
.dash-grid-item--medium { grid-column: span 6; }
.dash-grid-item--wide   { grid-column: span 9; }
.dash-grid-item--large  { grid-column: span 12; }

/* Tablet: small→6, medium→6, wide stays 9 */
@media (max-width: 1100px) {
  .dash-grid-item--small  { grid-column: span 6; }
  .dash-grid-item--medium { grid-column: span 6; }
  .dash-grid-item--wide   { grid-column: span 9; }
}
/* Mobile: everything full width */
@media (max-width: 700px) {
  .dash-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .dash-grid-item,
  .dash-grid-item--small,
  .dash-grid-item--medium,
  .dash-grid-item--wide,
  .dash-grid-item--large { grid-column: span 1; }
}

/* ── Section wrapper — card panel ─────────────────────────────────────── */
.dash-section {
  display: block;
  width: 100%;
  margin-bottom: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 4px rgba(16,24,40,0.05);
  overflow: hidden;
}

/* ── Section toggle header ────────────────────────────────────────────── */
.dash-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 16px 22px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 0;
  border-radius: 0;
  transition: background 0.13s;
}
.dash-section-toggle:hover { background: var(--accent2); }
.dash-section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text);
  margin: 0;
}
.dash-section-toggle-right {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
}
.dash-section-toggle-icon { font-size: 13px; line-height: 1; }

/* Section content gets its own padding */
#section-kpi_stats,
#section-denna_vecka,
#section-mina_uppgifter,
#section-senaste_nyheter,
#section-mina_favoriter,
#section-snabba_atgarder {
  padding: 22px;
}

/* ── KPI stat cards ───────────────────────────────────────────────────── */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.dash-kpi-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.05);
  padding: 22px 20px 20px;
  text-decoration: none;
  display: block;
  position: relative;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
  overflow: hidden;
}
.dash-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0.18;
  border-radius: 14px 14px 0 0;
}
.dash-kpi-card:hover {
  box-shadow: 0 8px 24px rgba(16,24,40,0.10);
  border-color: #a8bfd4;
  transform: translateY(-2px);
  text-decoration: none;
}
.dash-kpi-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 12px;
}
.dash-kpi-value {
  display: block;
  font-size: 38px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.03em;
}
.dash-kpi-card.kpi-warn {
  border-color: #fedf89;
}
.dash-kpi-card.kpi-warn::before { background: #f79009; opacity: 0.5; }
.dash-kpi-card.kpi-warn .dash-kpi-value { color: #b54708; }
.dash-kpi-card.kpi-error {
  border-color: #fecdca;
}
.dash-kpi-card.kpi-error::before { background: #e53e3e; opacity: 0.6; }
.dash-kpi-card.kpi-error .dash-kpi-value { color: #e53e3e; }

/* ── Favourite / shortcut cards ───────────────────────────────────────── */
.dash-fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.dash-fav-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,0.05);
  padding: 18px 18px;
  text-decoration: none;
  display: block;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.dash-fav-card:hover {
  box-shadow: 0 8px 22px rgba(16,24,40,0.10);
  border-color: #a8bfd4;
  transform: translateY(-2px);
  text-decoration: none;
}
.dash-fav-card.fav-warn {
  border-color: #fedf89;
  background: #fffdf5;
}
.dash-fav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 5px;
}
.dash-fav-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ── Section action row (buttons below stats) ─────────────────────────── */
.dash-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

/* ── Dark mode ────────────────────────────────────────────────────────── */
body[data-theme="dark"] .dash-welcome { border-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-welcome-greeting { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-section { background: #1a1d27 !important; border-color: #2a2f3d !important; box-shadow: none !important; }
body[data-theme="dark"] .dash-section-toggle { border-bottom-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-section-toggle:hover { background: #22263a !important; }
body[data-theme="dark"] .dash-section-title { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-kpi-card { background: #13151e !important; border-color: #2a2f3d !important; box-shadow: none !important; }
body[data-theme="dark"] .dash-kpi-card.kpi-warn { border-color: #3d2a00 !important; }
body[data-theme="dark"] .dash-kpi-card.kpi-error { border-color: #3d1212 !important; }
body[data-theme="dark"] .dash-fav-card { background: #13151e !important; border-color: #2a2f3d !important; box-shadow: none !important; }
body[data-theme="dark"] .dash-fav-card.fav-warn { background: #1a1400 !important; border-color: #3d2a00 !important; }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .dash-welcome { border-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-welcome-greeting { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-section { background: #1a1d27 !important; border-color: #2a2f3d !important; box-shadow: none !important; }
  body[data-theme="system"] .dash-section-toggle { border-bottom-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-section-toggle:hover { background: #22263a !important; }
  body[data-theme="system"] .dash-section-title { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-kpi-card { background: #13151e !important; border-color: #2a2f3d !important; box-shadow: none !important; }
  body[data-theme="system"] .dash-fav-card { background: #13151e !important; border-color: #2a2f3d !important; box-shadow: none !important; }
}

/* ── Dashboard responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  .dash-kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-fav-grid  { grid-template-columns: 1fr; gap: 10px; }
  .dash-welcome-greeting { font-size: 20px; }
  #section-kpi_stats,
  #section-denna_vecka,
  #section-mina_uppgifter,
  #section-senaste_nyheter,
  #section-mina_favoriter,
  #section-snabba_atgarder { padding: 14px; }
}

/* ── Anpassa dashboard button ─────────────────────────────────────────── */
.dash-customize-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 2; /* above .dash-glass-header-inner (z-index:1) so clicks reach the button */
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(11,36,71,0.12);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  white-space: nowrap;
}
.dash-customize-btn:hover {
  background: rgba(255,255,255,0.80);
  border-color: rgba(11,36,71,0.22);
}

/* ── Customize modal overlay ──────────────────────────────────────────── */
.dash-customize-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11,36,71,0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.dash-customize-overlay.active { display: flex; }

.dash-customize-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(11,36,71,0.18);
  width: 100%;
  max-width: 420px;
  padding: 28px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.dash-customize-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.dash-customize-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
.dash-customize-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.dash-customize-close:hover { background: var(--accent2); color: var(--accent); }

.dash-customize-help {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 18px;
}

/* ── Widget list rows ─────────────────────────────────────────────────── */
.dash-widget-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.dash-widget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  gap: 10px;
  transition: border-color 0.12s;
}
.dash-widget-row:hover { border-color: #a8bfd4; }
.dash-widget-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.dash-widget-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.dash-widget-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.dash-cust-size {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s;
}
.dash-cust-size:focus { border-color: var(--accent); }
.dash-drag-handle {
  font-size: 16px;
  color: var(--muted);
  cursor: grab;
  padding: 0 6px 0 2px;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s;
}
.dash-widget-row:hover .dash-drag-handle { opacity: 1; color: var(--accent); }
.dash-widget-dragging {
  opacity: 0.45;
  background: var(--accent2) !important;
  border-color: var(--accent) !important;
  cursor: grabbing;
}
.dash-customize-actions { display: flex; gap: 8px; }

/* ── Senaste nyheter widget ───────────────────────────────────────────── */
.dash-news-list { display: flex; flex-direction: column; gap: 0; }
.dash-news-row {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0;
}
.dash-news-row-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dash-news-source {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.dash-news-title { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 0 0 4px; line-height: 1.4; }
.dash-news-link { color: var(--accent); text-decoration: none; }
.dash-news-link:hover { text-decoration: underline; }
.dash-news-summary { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ── Dark mode — customize + news ────────────────────────────────────── */
body[data-theme="dark"] .dash-customize-btn { background: rgba(78,158,207,0.12) !important; border-color: rgba(78,158,207,0.20) !important; color: #4e9ecf !important; }
body[data-theme="dark"] .dash-customize-btn:hover { background: rgba(78,158,207,0.22) !important; }
body[data-theme="dark"] .dash-customize-modal { background: #1a1d27 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-widget-row { background: #13151e !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-widget-row:hover { border-color: #4e9ecf !important; }
body[data-theme="dark"] .dash-widget-name { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-cust-size   { background: #13151e !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .dash-drag-handle { color: #8d95a8 !important; }
body[data-theme="dark"] .dash-widget-row:hover .dash-drag-handle { color: #4e9ecf !important; }
body[data-theme="dark"] .dash-widget-dragging { background: #1a2a38 !important; border-color: #4e9ecf !important; }
body[data-theme="dark"] .dash-news-row { border-color: #2a2f3d !important; }
body[data-theme="dark"] .dash-news-title { color: #e4e7ef !important; }
body[data-theme="dark"] .dash-news-summary { color: #8d95a8 !important; }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .dash-customize-btn { background: rgba(78,158,207,0.12) !important; border-color: rgba(78,158,207,0.20) !important; color: #4e9ecf !important; }
  body[data-theme="system"] .dash-customize-modal { background: #1a1d27 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-widget-row { background: #13151e !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-widget-name { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-cust-size   { background: #13151e !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .dash-drag-handle { color: #8d95a8 !important; }
  body[data-theme="system"] .dash-widget-row:hover .dash-drag-handle { color: #4e9ecf !important; }
  body[data-theme="system"] .dash-widget-dragging { background: #1a2a38 !important; border-color: #4e9ecf !important; }
  body[data-theme="system"] .dash-news-row { border-color: #2a2f3d !important; }
  body[data-theme="system"] .dash-news-title { color: #e4e7ef !important; }
  body[data-theme="system"] .dash-news-summary { color: #8d95a8 !important; }
}
@media (max-width: 700px) {
  .dash-customize-btn { font-size: 11.5px; padding: 5px 9px; }
  .dash-customize-modal { max-width: calc(100vw - 32px); padding: 20px 16px; }
}

/* ── Dark mode for topbar ─────────────────────────────────────────────── */
/* Sidebar is always navy regardless of theme — no dark overrides needed  */
body[data-theme="dark"] .portal-topbar {
  background: rgba(26,29,39,.97) !important;
  border-color: #2a2f3d !important;
  box-shadow: 0 1px 0 0 #2a2f3d, 0 2px 12px rgba(0,0,0,.18) !important;
}
body[data-theme="dark"] .topbar-user-name         { color: #e4e7ef !important; }
body[data-theme="dark"] .topbar-avatar            { background: #2d5c8a !important; }
body[data-theme="dark"] .topbar-avatar:hover,
body[data-theme="dark"] .topbar-avatar-wrap.open .topbar-avatar { box-shadow: 0 0 0 3px rgba(94,212,253,0.15) !important; }
body[data-theme="dark"] .topbar-avatar-menu       { background: #1e2132 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .topbar-avatar-menu-name  { color: #e4e7ef !important; }
body[data-theme="dark"] .topbar-avatar-menu-divider { background: #2a2f3d !important; }
body[data-theme="dark"] .topbar-avatar-menu-item  { color: #e4e7ef !important; }
body[data-theme="dark"] .topbar-avatar-menu-item:hover { background: #22263a !important; }
body[data-theme="dark"] .topbar-avatar-menu-logout { color: #fc8181 !important; }
body[data-theme="dark"] .topbar-avatar-menu-logout:hover { background: #2a1a1a !important; }
body[data-theme="dark"] .topbar-sep               { background: #2a2f3d !important; }
body[data-theme="dark"] .topbar-notif-btn         { color: #8d95a8 !important; }
body[data-theme="dark"] .topbar-notif-btn:hover   { background: #22263a !important; color: #4e9ecf !important; }
body[data-theme="dark"] .topbar-sidebar-toggle    { color: #e4e7ef !important; }
body[data-theme="dark"] .notif-menu               { background: #1e2132 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .notif-menu-header,
body[data-theme="dark"] .notif-row                { border-color: #2a2f3d !important; }
body[data-theme="dark"] .notif-row--unread        { background: #22263a !important; }
body[data-theme="dark"] .notif-row-msg            { color: #e4e7ef !important; }
body[data-theme="dark"] .notif-menu-title         { color: #e4e7ef !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .portal-topbar          { background: rgba(26,29,39,.97) !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .topbar-user-name       { color: #e4e7ef !important; }
  body[data-theme="system"] .topbar-avatar          { background: #2d5c8a !important; }
  body[data-theme="system"] .topbar-avatar-menu     { background: #1e2132 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .topbar-avatar-menu-name { color: #e4e7ef !important; }
  body[data-theme="system"] .topbar-avatar-menu-item { color: #e4e7ef !important; }
  body[data-theme="system"] .topbar-avatar-menu-item:hover { background: #22263a !important; }
  body[data-theme="system"] .topbar-avatar-menu-logout { color: #fc8181 !important; }
  body[data-theme="system"] .topbar-sep             { background: #2a2f3d !important; }
  body[data-theme="system"] .topbar-notif-btn       { color: #8d95a8 !important; }
  body[data-theme="system"] .topbar-sidebar-toggle  { color: #e4e7ef !important; }
  body[data-theme="system"] .notif-menu             { background: #1e2132 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .notif-row--unread      { background: #22263a !important; }
}

/* ── Leads page ──────────────────────────────────────────────────────────── */

/* Header */
.leads-header {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 16px; margin-bottom: 28px;
}
.leads-title {
  font-size: 28px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 4px;
}
.leads-subtitle { font-size: 14px; color: var(--muted); margin: 0; }
.leads-header-actions { display: flex; gap: 10px; align-items: center; }

.leads-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(33,78,111,.25);
  transition: opacity .15s;
}
.leads-btn-primary:hover:not(:disabled) { opacity: .88; }
.leads-btn-primary:disabled { opacity: .42; cursor: default; }

.leads-btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px;
  background: transparent; color: var(--accent);
  font-size: 13.5px; font-weight: 600;
  border: 1.5px solid var(--accent); cursor: pointer;
  transition: background .15s;
}
.leads-btn-secondary:hover:not(:disabled) { background: var(--accent2); }
.leads-btn-secondary:disabled { opacity: .42; cursor: default; }

/* KPI grid */
.leads-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.leads-kpi-card {
  background: var(--card);
  border-radius: 14px; padding: 22px 20px 18px;
  box-shadow: 0 2px 8px rgba(16,24,40,.06);
  border: 1px solid var(--line);
  border-left-width: 4px;
}
.leads-kpi-primary { border-left-color: var(--accent); }
.leads-kpi-blue    { border-left-color: #19a7ce; }
.leads-kpi-green   { border-left-color: #4caf50; }
.leads-kpi-amber   { border-left-color: var(--warn); }
.leads-kpi-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 8px;
}
.leads-kpi-value {
  font-size: 32px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em; line-height: 1;
}

/* Filter bar */
.leads-filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(16,24,40,.04);
}
.leads-search-wrap { position: relative; flex: 1; min-width: 200px; }
.leads-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--muted); pointer-events: none;
}
.leads-search-input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
  font-size: 13.5px; outline: none; box-sizing: border-box;
}
.leads-filter-select {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
  font-size: 13.5px; outline: none; min-width: 140px;
}

/* Table card */
.leads-table-card {
  background: var(--card); border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(16,24,40,.06);
  overflow: hidden;
}
.leads-table-scroll { overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table thead th {
  padding: 13px 18px;
  background: var(--table-head-bg);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); border-bottom: 1px solid var(--line);
  white-space: nowrap; text-align: left;
}
.leads-table tbody tr { border-bottom: 1px solid var(--line); transition: background .1s; }
.leads-table tbody tr:last-child { border-bottom: none; }
.leads-table tbody tr:hover { background: var(--table-row-hover); }
.leads-table td { padding: 14px 18px; font-size: 13.5px; color: var(--text); vertical-align: middle; }
.leads-muted { color: var(--muted); }

.leads-company-wrap { display: flex; align-items: center; gap: 10px; }
.leads-company-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent2); color: var(--accent);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: uppercase; letter-spacing: .02em;
}
.leads-company-name { font-weight: 700; color: var(--text); }
.leads-email-link { color: var(--accent); text-decoration: none; }
.leads-email-link:hover { text-decoration: underline; }

/* Status badges */
.leads-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.leads-badge-new        { background: #dbeafe; color: #1d4ed8; }
.leads-badge-contacted  { background: #fef3c7; color: #92400e; }
.leads-badge-offer_sent { background: #e0f2fe; color: #0369a1; }
.leads-badge-won        { background: #dcfce7; color: #15803d; }
.leads-badge-lost       { background: #fee2e2; color: #991b1b; }
.leads-badge-archived   { background: #f3f4f6; color: #6b7280; }

/* Responsive */
@media (max-width: 1100px) { .leads-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .leads-kpi-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px)  {
  .leads-header { flex-direction: column; align-items: flex-start; }
  .leads-header-actions { width: 100%; justify-content: flex-end; }
}

/* ── Dark mode — Leads ───────────────────────────────────────────────────── */
body[data-theme="dark"] .leads-title  { color: #e4e7ef !important; }
body[data-theme="dark"] .leads-kpi-card { background: #1a1d27 !important; border-top-color: #2a2f3d !important; border-right-color: #2a2f3d !important; border-bottom-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-kpi-value { color: #e4e7ef !important; }
body[data-theme="dark"] .leads-filter-bar { background: #1a1d27 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-search-input { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .leads-filter-select { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .leads-table-card { background: #1a1d27 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-company-name { color: #e4e7ef !important; }
body[data-theme="dark"] .leads-company-avatar { background: #1a2a38 !important; color: #4e9ecf !important; }
body[data-theme="dark"] .leads-badge-new        { background: #1e3a8a22 !important; color: #93c5fd !important; }
body[data-theme="dark"] .leads-badge-contacted  { background: #78350f22 !important; color: #fcd34d !important; }
body[data-theme="dark"] .leads-badge-offer_sent { background: #0c4a6e22 !important; color: #7dd3fc !important; }
body[data-theme="dark"] .leads-badge-won        { background: #14532d22 !important; color: #86efac !important; }
body[data-theme="dark"] .leads-badge-lost       { background: #7f1d1d22 !important; color: #fca5a5 !important; }
body[data-theme="dark"] .leads-badge-archived   { background: #37415122 !important; color: #9ca3af !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-title  { color: #e4e7ef !important; }
  body[data-theme="system"] .leads-kpi-card { background: #1a1d27 !important; border-top-color: #2a2f3d !important; border-right-color: #2a2f3d !important; border-bottom-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-kpi-value { color: #e4e7ef !important; }
  body[data-theme="system"] .leads-filter-bar { background: #1a1d27 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-search-input { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .leads-filter-select { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .leads-table-card { background: #1a1d27 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-company-name { color: #e4e7ef !important; }
  body[data-theme="system"] .leads-company-avatar { background: #1a2a38 !important; color: #4e9ecf !important; }
  body[data-theme="system"] .leads-badge-new        { background: #1e3a8a22 !important; color: #93c5fd !important; }
  body[data-theme="system"] .leads-badge-contacted  { background: #78350f22 !important; color: #fcd34d !important; }
  body[data-theme="system"] .leads-badge-offer_sent { background: #0c4a6e22 !important; color: #7dd3fc !important; }
  body[data-theme="system"] .leads-badge-won        { background: #14532d22 !important; color: #86efac !important; }
  body[data-theme="system"] .leads-badge-lost       { background: #7f1d1d22 !important; color: #fca5a5 !important; }
  body[data-theme="system"] .leads-badge-archived   { background: #37415122 !important; color: #9ca3af !important; }
}

/* ── Leads row clickable ─────────────────────────────────────────────────── */
.leads-row { cursor: pointer; }
.leads-row:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.leads-notes-cell { max-width: 180px; }
.leads-ej-angiven { color: var(--muted); font-style: italic; font-size: 12px; }

/* ── Lead details modal ──────────────────────────────────────────────────── */
.leads-modal-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(16,24,40,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.leads-modal-overlay[hidden] { display: none; }

.leads-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(16,24,40,.18);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
}

.leads-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.leads-modal-header-text { display: flex; flex-direction: column; gap: 8px; }
.leads-modal-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  margin: 0; line-height: 1.25; letter-spacing: -0.01em;
}
.leads-modal-close {
  flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); font-size: 18px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
  margin-top: 2px;
}
.leads-modal-close:hover { background: var(--accent2); color: var(--accent); }

.leads-modal-body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 4px; }

.leads-modal-section {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; margin-bottom: 14px;
}
.leads-modal-section:last-child { margin-bottom: 0; }

.leads-modal-field {
  display: flex; align-items: baseline; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.leads-modal-field:last-child { border-bottom: none; }

.leads-modal-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); white-space: nowrap; min-width: 130px; flex-shrink: 0;
}
.leads-modal-value {
  font-size: 13.5px; color: var(--text); word-break: break-word;
}

/* Dark mode — modal */
body[data-theme="dark"] .leads-modal { background: #1a1d27 !important; border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-modal-header { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-modal-title { color: #e4e7ef !important; }
body[data-theme="dark"] .leads-modal-close { border-color: #2a2f3d !important; color: #8d95a8 !important; }
body[data-theme="dark"] .leads-modal-close:hover { background: #22263a !important; color: #4e9ecf !important; }
body[data-theme="dark"] .leads-modal-section { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-modal-field { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-modal-value { color: #e4e7ef !important; }
body[data-theme="dark"] .leads-row:focus { outline-color: #4e9ecf !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-modal { background: #1a1d27 !important; border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-modal-header { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-modal-title { color: #e4e7ef !important; }
  body[data-theme="system"] .leads-modal-close { border-color: #2a2f3d !important; color: #8d95a8 !important; }
  body[data-theme="system"] .leads-modal-close:hover { background: #22263a !important; color: #4e9ecf !important; }
  body[data-theme="system"] .leads-modal-section { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-modal-field { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-modal-value { color: #e4e7ef !important; }
  body[data-theme="system"] .leads-row:focus { outline-color: #4e9ecf !important; }
}

@media (max-width: 600px) {
  .leads-modal { border-radius: 14px; }
  .leads-modal-label { min-width: 100px; font-size: 10px; }
  .leads-modal-value { font-size: 13px; }
}

/* ── Leads create modal ──────────────────────────────────────────────────── */
.leads-create-modal { max-width: 580px; }
.leads-modal-subtitle { font-size: 13px; color: var(--muted); margin: 2px 0 0; }

.leads-create-form { display: flex; flex-direction: column; }

.leads-form-errors {
  margin: 0 24px 4px;
  padding: 12px 16px;
  background: #fee2e2; border: 1px solid #fca5a5; border-radius: 10px;
  font-size: 13px; color: #991b1b;
}
.leads-form-errors ul { margin: 0; padding-left: 18px; }
.leads-form-errors li { margin-bottom: 2px; }

.leads-form-section {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; margin: 4px 24px 14px;
}
.leads-form-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.leads-form-row:last-child { border-bottom: none; }

.leads-form-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); white-space: nowrap;
  min-width: 160px; flex-shrink: 0; padding-top: 8px;
}
.leads-form-req { color: var(--bad); }

.leads-form-input {
  flex: 1; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
  font-size: 13.5px; outline: none; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.leads-form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(33,78,111,.12); }

.leads-form-textarea { resize: vertical; min-height: 76px; }
.leads-form-select { appearance: none; cursor: pointer; }

.leads-form-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
}

/* Dark mode — create modal */
body[data-theme="dark"] .leads-form-errors { background: #7f1d1d33 !important; border-color: #fca5a544 !important; color: #fca5a5 !important; }
body[data-theme="dark"] .leads-form-section { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-form-row { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-form-footer { border-color: #2a2f3d !important; }
body[data-theme="dark"] .leads-form-input { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
body[data-theme="dark"] .leads-form-input:focus { border-color: #4e9ecf !important; box-shadow: 0 0 0 2px rgba(78,158,207,.15) !important; }
body[data-theme="dark"] .leads-modal-subtitle { color: #8d95a8 !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-form-errors { background: #7f1d1d33 !important; border-color: #fca5a544 !important; color: #fca5a5 !important; }
  body[data-theme="system"] .leads-form-section { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-form-row { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-form-footer { border-color: #2a2f3d !important; }
  body[data-theme="system"] .leads-form-input { background: #22263a !important; border-color: #2a2f3d !important; color: #e4e7ef !important; }
  body[data-theme="system"] .leads-form-input:focus { border-color: #4e9ecf !important; box-shadow: 0 0 0 2px rgba(78,158,207,.15) !important; }
  body[data-theme="system"] .leads-modal-subtitle { color: #8d95a8 !important; }
}

@media (max-width: 600px) {
  .leads-form-label { min-width: 0; width: 100%; padding-top: 0; }
  .leads-form-row { flex-direction: column; gap: 6px; }
  .leads-form-footer { flex-direction: column-reverse; }
  .leads-form-footer .leads-btn-primary,
  .leads-form-footer .leads-btn-secondary { width: 100%; justify-content: center; }
}

/* ── Lead details modal footer ───────────────────────────────────────────── */
.leads-modal-footer {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
  gap: 10px;
}

body[data-theme="dark"] .leads-modal-footer { border-color: #2a2f3d !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-modal-footer { border-color: #2a2f3d !important; }
}

@media (max-width: 600px) {
  .leads-modal-footer { padding: 12px 16px 16px; }
  .leads-modal-footer .leads-btn-primary { width: 100%; justify-content: center; }
}

/* ── Lead modal — linked offers section ──────────────────────────────────── */
.leads-modal-offers-section { margin-top: 4px; }
.leads-offer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.leads-offer-link-strong { font-weight: 700; }
.leads-modal-field-info { background: transparent; }

/* Offer status badge variants */
.leads-badge-offer-draft    { background: #f3f4f6; color: #6b7280; }
.leads-badge-offer-sent     { background: #e0f2fe; color: #0369a1; }
.leads-badge-offer-accepted { background: #dcfce7; color: #15803d; }
.leads-badge-offer-declined { background: #fee2e2; color: #991b1b; }
.leads-badge-offer-expired  { background: #fef3c7; color: #92400e; }

body[data-theme="dark"] .leads-badge-offer-draft    { background: #37415122 !important; color: #9ca3af !important; }
body[data-theme="dark"] .leads-badge-offer-sent     { background: #0c4a6e22 !important; color: #7dd3fc !important; }
body[data-theme="dark"] .leads-badge-offer-accepted { background: #14532d22 !important; color: #86efac !important; }
body[data-theme="dark"] .leads-badge-offer-declined { background: #7f1d1d22 !important; color: #fca5a5 !important; }
body[data-theme="dark"] .leads-badge-offer-expired  { background: #78350f22 !important; color: #fcd34d !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-badge-offer-draft    { background: #37415122 !important; color: #9ca3af !important; }
  body[data-theme="system"] .leads-badge-offer-sent     { background: #0c4a6e22 !important; color: #7dd3fc !important; }
  body[data-theme="system"] .leads-badge-offer-accepted { background: #14532d22 !important; color: #86efac !important; }
  body[data-theme="system"] .leads-badge-offer-declined { background: #7f1d1d22 !important; color: #fca5a5 !important; }
  body[data-theme="system"] .leads-badge-offer-expired  { background: #78350f22 !important; color: #fcd34d !important; }
}

/* ── Lead modal — header actions & edit button ───────────────────────────── */
.leads-modal-header-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.leads-modal-edit-btn {
  padding: 6px 14px; border-radius: 8px;
  background: var(--accent2); color: var(--accent);
  font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--accent); cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.leads-modal-edit-btn:hover { background: var(--accent); color: #fff; }

body[data-theme="dark"] .leads-modal-edit-btn { background: #1a2a38 !important; color: #4e9ecf !important; border-color: #4e9ecf !important; }
body[data-theme="dark"] .leads-modal-edit-btn:hover { background: #4e9ecf !important; color: #0f1117 !important; }

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .leads-modal-edit-btn { background: #1a2a38 !important; color: #4e9ecf !important; border-color: #4e9ecf !important; }
  body[data-theme="system"] .leads-modal-edit-btn:hover { background: #4e9ecf !important; color: #0f1117 !important; }
}

/* ── Global search — topbar form ─────────────────────────────────────── */
.topbar-search-form {
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 360px;
  margin: 0 12px;
}
.topbar-search-input {
  width: 100%;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.topbar-search-input::placeholder { color: var(--text-muted, #9ca3af); }
.topbar-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 59,130,246),.12);
}

/* ── Global search — results page ───────────────────────────────────── */
.search-page-form { margin: 0 0 28px; }
.search-page-field {
  display: flex;
  gap: 10px;
  max-width: 560px;
}
.search-page-input {
  flex: 1;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-page-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 59,130,246),.12);
}
.search-page-btn { height: 42px; padding: 0 20px; white-space: nowrap; }

.search-message {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 20px;
}
.search-message--warn  { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }
.search-message--info  { background: var(--accent2); color: var(--text); border: 1px solid var(--line); }
.search-message--empty { background: var(--card); color: var(--text-muted, #6b7280); border: 1px solid var(--line); }

.search-summary {
  font-size: 14px;
  color: var(--text-muted, #6b7280);
  margin: 0 0 20px;
}
.search-summary strong { color: var(--text); }

.search-group { margin-bottom: 32px; }
.search-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted, #6b7280);
  margin: 0 0 10px;
}
.search-group-list { display: flex; flex-direction: column; gap: 6px; }

.search-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.search-result-card:hover {
  background: var(--accent2);
  border-color: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.search-result-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-result-title  { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-subtitle { font-size: 12px; color: var(--text-muted, #6b7280); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-type { flex-shrink: 0; font-size: 11px; }

/* Mobile */
@media (max-width: 768px) {
  .topbar-search-form { max-width: none; margin: 0 8px; }
  .topbar-search-input { font-size: 14px; }
}

/* Dark mode */
body[data-theme="dark"] .search-message--warn  { background: #3d2c00; color: #fde68a; border-color: #78450a; }
body[data-theme="dark"] .search-result-card:hover { background: var(--accent2); }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] .search-message--warn { background: #3d2c00; color: #fde68a; border-color: #78450a; }
}

/* -- Guided tour --------------------------------------------------- */
#tour-highlight { transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease; }

/* ── Portal theme presets ─────────────────────────────────────────── */
/* default_blue is the baseline — sidebar #0b2447, accent #214e6f.   */
/* These overrides apply on top of the light/dark/system theme.       */

/* Sidebar brand logo — small icon fallback (unused now, kept for safety) */
.sidebar-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 9px;
  flex-shrink: 0;
}

/* Full-width logo replaces brand title area */
.sidebar-brand--logo {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 4px 6px;
}
.sidebar-brand-logo-full {
  max-height: 44px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
/* Hide full logo in collapsed sidebar; show CM mark instead */
.portal-sidebar.sidebar-collapsed .sidebar-brand--logo .sidebar-brand-logo-full { display: none; }
.portal-sidebar.sidebar-collapsed .sidebar-brand--logo .sidebar-brand-sub      { display: none; }

/* teal */
body[data-portal-theme="teal"] { --accent: #0d9488; --accent2: #ccfbf1; }
body[data-portal-theme="teal"] .portal-sidebar { background: #0a3d3d; }
body[data-portal-theme="teal"] .sidebar-nav-link.active { border-left-color: #14b8a6; }
body[data-portal-theme="teal"] .btn-primary { background: #0d9488; border-color: #0d9488; }

/* neutral */
body[data-portal-theme="neutral"] { --accent: #475569; --accent2: #f1f5f9; }
body[data-portal-theme="neutral"] .portal-sidebar { background: #1e293b; }
body[data-portal-theme="neutral"] .sidebar-nav-link.active { border-left-color: #94a3b8; }
body[data-portal-theme="neutral"] .btn-primary { background: #475569; border-color: #475569; }

/* dark_blue */
body[data-portal-theme="dark_blue"] { --accent: #3b82f6; --accent2: #dbeafe; }
body[data-portal-theme="dark_blue"] .portal-sidebar { background: #0f172a; }
body[data-portal-theme="dark_blue"] .sidebar-nav-link.active { border-left-color: #60a5fa; }
body[data-portal-theme="dark_blue"] .btn-primary { background: #3b82f6; border-color: #3b82f6; }

/* green */
body[data-portal-theme="green"] { --accent: #16a34a; --accent2: #dcfce7; }
body[data-portal-theme="green"] .portal-sidebar { background: #0f2d20; }
body[data-portal-theme="green"] .sidebar-nav-link.active { border-left-color: #4ade80; }
body[data-portal-theme="green"] .btn-primary { background: #16a34a; border-color: #16a34a; }

/* warm */
body[data-portal-theme="warm"] { --accent: #b45309; --accent2: #fef3c7; }
body[data-portal-theme="warm"] .portal-sidebar { background: #2d1a0e; }
body[data-portal-theme="warm"] .sidebar-nav-link.active { border-left-color: #fbbf24; }
body[data-portal-theme="warm"] .btn-primary { background: #b45309; border-color: #b45309; }

/* purple */
body[data-portal-theme="purple"] { --accent: #7c3aed; --accent2: #ede9fe; }
body[data-portal-theme="purple"] .portal-sidebar { background: #1e1040; }
body[data-portal-theme="purple"] .sidebar-nav-link.active { border-left-color: #a78bfa; }
body[data-portal-theme="purple"] .btn-primary { background: #7c3aed; border-color: #7c3aed; }

/* rose */
body[data-portal-theme="rose"] { --accent: #be123c; --accent2: #ffe4e6; }
body[data-portal-theme="rose"] .portal-sidebar { background: #2d0f1e; }
body[data-portal-theme="rose"] .sidebar-nav-link.active { border-left-color: #fb7185; }
body[data-portal-theme="rose"] .btn-primary { background: #be123c; border-color: #be123c; }

/* cm_core — dark amber/gold premium */
body[data-portal-theme="cm_core"] { --accent: #d97706; --accent2: #fef3c7; }
body[data-portal-theme="cm_core"] .portal-sidebar { background: #1a1208; }
body[data-portal-theme="cm_core"] .sidebar-nav-link.active { border-left-color: #f59e0b; }
body[data-portal-theme="cm_core"] .btn-primary { background: #d97706; border-color: #d97706; }

/* cm_core dark-mode enrichment — explicit dark only.
   System mode (data-theme="system") relies on the OS media query block already in portal.css;
   we only override explicit dark here to avoid duplicating rules inside a media query. */
body[data-theme="dark"][data-portal-theme="cm_core"] { --accent: #f59e0b; --accent2: #2d1e06; --card: #1c1a12; --line: #2d2618; }
/* Override the hardcoded !important dark-mode rules for key elements */
body[data-theme="dark"][data-portal-theme="cm_core"] .page-heading  { color: #f59e0b !important; }
body[data-theme="dark"][data-portal-theme="cm_core"] .btn           { color: #f59e0b !important; }
body[data-theme="dark"][data-portal-theme="cm_core"] .btn-primary   { background: #d97706 !important; border-color: #d97706 !important; color: #fff !important; }

/* ── Sidebar contrast modifier ────────────────────────────────────── */
/* "high" cranks up text and bg opacity on top of any theme.         */
body[data-sidebar-contrast="high"] .sidebar-nav-label {
  color: rgba(255,255,255,0.75);
  font-size: 10px;
  letter-spacing: 0.12em;
}
body[data-sidebar-contrast="high"] .sidebar-nav-link {
  color: rgba(255,255,255,0.92);
}
body[data-sidebar-contrast="high"] .sidebar-nav-link:hover {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
}
body[data-sidebar-contrast="high"] .sidebar-nav-link.active {
  background: rgba(255,255,255,0.26);
  color: #ffffff;
}
