/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --brand:        #1F3F6B;
  --brand-dark:   #1e40af;
  --brand-light:  #eaf1ff;
  --brand-hover:  #1d4ed8;

  --danger:       #ef4444;
  --danger-bg:    #fee2e2;
  --warning:      #d97706;
  --warning-bg:   #fef3c7;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --info:         #2563eb;
  --info-bg:      #dbeafe;
  --gray:         #64748b;
  --gray-bg:      #f1f5f9;

  --text:         #1a2332;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;

  --surface:      #ffffff;
  --surface-alt:  #f8fafc;
  --surface-hover:#f1f5f9;
  --border:       #e2e8f0;

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
  --radius-xl:    24px;

  --shadow-sm:    0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:       0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:    0 16px 40px rgba(15,23,42,.12);

  --font:         'Barlow', system-ui, -apple-system, sans-serif;

  /* ─ Sidebar tokens ─ */
  --sidebar-w:    260px;
  --mobile-nav-h: calc(62px + env(safe-area-inset-bottom));
  --sb-bg:        #ffffff;
  --sb-border:    #e2e8f0;
  --sb-hover:     #f1f5f9;
  --sb-active:    #eaf1ff;
  --sb-text:      #1a2332;
  --sb-muted:     #64748b;
  --sb-accent:    #1e40af;
  --transition:   0.18s ease;
}

/* ─── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: #eef2f6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; }
p { margin: 0; }

/* ─── App wrapper ────────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

a.brand-mark { text-decoration: none; color: inherit; }
a.brand-mark:focus-visible { outline: 2px solid var(--brand); border-radius: 4px; }

.brand-mark img {
  display: block;
  height: 4rem;
  width: auto;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover { color: var(--text); background: var(--surface-alt); }
.nav-link.active { color: var(--brand-dark); background: var(--brand-light); font-weight: 600; }

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role  { font-size: 11px; color: var(--text-light); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover { background: var(--surface-alt); color: var(--text); }

.mobile-menu-toggle { display: none; }

/* ─── Main content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  font-size: 13px;
  color: var(--text-light);
}

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand-dark);
}

.intro-text {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 560px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 0;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: none; }

.button-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .26);
}
.button-primary:hover { background: var(--brand-hover); }

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.button-secondary:hover { background: var(--surface-alt); }

.button-danger {
  background: var(--danger);
  color: #fff;
}

.btn-muted-danger {
  background: var(--surface-alt);
  color: #b45309;
  border: 1px solid #e5c99a;
}
.btn-muted-danger:hover { background: #fef3c7; border-color: #d97706; color: #92400e; }

.button-sm { padding: 6px 14px; font-size: 13px; }
.button-full { width: 100%; justify-content: center; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─── Button group (connected flat buttons) ──────────────────────────────────── */
.btn-group {
  display: inline-flex;
  align-items: stretch;
}
.btn-group > .button {
  border-radius: 0;
  transform: none !important;
}
.btn-group > .button:not(:first-child) {
  border-left-width: 0;
  margin-left: 0;
}
.btn-group > .button:hover { position: relative; z-index: 1; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.card-header h2, .card-header h3 {
  font-size: 16px;
  font-weight: 700;
}

/* ─── Stat grid ──────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.stat-card__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-card--brand .stat-card__value { color: var(--brand-dark); }
.stat-card--warn  .stat-card__value { color: var(--warning); }
.stat-card--info  .stat-card__value { color: var(--info); }
.stat-card--gray  .stat-card__value { color: var(--gray); }
.stat-card--dark  .stat-card__value { color: #374151; }

.stat-card { cursor: default; }
.stat-card.is-active { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }

thead { background: var(--surface-alt); }

th {
  padding: 13px 18px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 14px 18px;
  font-size: 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f9fbfd; }

.row-link { cursor: pointer; }

/* ─── Cases panel (filter + grid in one white box) ──────────────────────────── */
.cases-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cases-panel .filter-bar {
  padding: 14px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

/* ─── Case grid (admin sagsoversigt) ─────────────────────────────────────────── */
.cg-header,
.cg-row {
  display: grid;
  grid-template-columns: minmax(220px, 3fr) minmax(180px, 3fr) minmax(130px, 2fr) minmax(76px, .8fr) minmax(70px, .7fr) minmax(150px, 1.25fr);
  align-items: center;
  min-width: 700px;
}

.cg-header {
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
}

.cg-header .cg-cell {
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.cg-row {
  border-bottom: 1px solid var(--border);
  border-left: 5px solid transparent;
  cursor: pointer;
  transition: background var(--transition);
}

.cg-row:last-child { border-bottom: none; }
.cg-row:hover { background: var(--surface-alt); }

/* Status border colors (desktop) */
/* border-left color is now set per-row via inline style (technician color) */

.cg-row .cg-cell {
  padding: 13px 14px;
  font-size: 14px;
  overflow: hidden;
}
.cg-row .cg-cell.cg-status {
  overflow: visible;
  padding-left: 10px;
  padding-right: 16px;
}

.cg-title { font-weight: 600; color: var(--text); }
.cg-main  { font-size: 13.5px; color: var(--text); line-height: 1.3; }
.cg-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.3; }
.cg-time  { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cg-muted { font-size: 13px; color: var(--text-muted); }
.cg-code  { font-size: 11.5px; color: var(--text-muted); font-family: monospace; }

/* ─── Status badge ───────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  background: var(--badge-bg, #f1f5f9);
  color: var(--badge-color, #64748b);
  white-space: nowrap;
}

.overview-page .cg-status .status-badge {
  
  padding-inline: 8px;
}

.overview-page .cg-status .status-badge {
  font-size: 0;
}

.overview-page .cg-status .status-badge::after {
  content: attr(data-short);
  font-size: 12px;
}

.overview-page .case-row[data-status="Åbent"] .cg-status .status-badge::after { content: "Åbent"; }
.overview-page .case-row[data-status="Løst"] .cg-status .status-badge::after { content: "Løst"; }
.overview-page .case-row[data-status="Afventer"] .cg-status .status-badge::after { content: "Afventer"; }
.overview-page .case-row[data-status="Faktureret"] .cg-status .status-badge::after { content: "Faktureret"; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── Doc/message status badges ─────────────────────────────────────────────── */
.doc-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.doc-status--ok   { background: var(--success-bg); color: var(--success); }
.doc-status--wait { background: var(--warning-bg); color: var(--warning); }
.doc-status--recv { background: var(--info-bg); color: var(--info); }
.doc-status--rej  { background: var(--danger-bg); color: var(--danger); }

/* ─── Search / filter bar ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.filter-select {
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}

.filter-select:focus { outline: none; border-color: var(--brand); }

.filter-select--mobile { display: none; }

.mobile-status-filter {
  display: none !important;
  position: relative;
  flex-shrink: 0;
}

.mobile-filter-toggle {
  min-height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.mobile-filter-menu {
  display: none !important;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  width: 210px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.mobile-filter-menu.is-open { display: block !important; }

.mobile-filter-menu button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.mobile-filter-menu button:last-child { border-bottom: 0; }
.mobile-filter-menu button:hover { background: var(--surface-alt); }

.mobile-filter-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-filter-menu button.is-active .mobile-filter-check {
  border-color: var(--brand);
  background: var(--brand);
}

.mobile-filter-menu button.is-active .mobile-filter-check::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

/* ─── Status filter buttons ──────────────────────────────────────────────────── */
.filter-btn-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.filter-btn {
  min-width: 130px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.filter-btn:hover { background: var(--surface-alt); color: var(--text); }

.filter-btn.is-active {
  background: var(--brand-light, #e6faf7);
  border-color: var(--brand);
  color: var(--brand-dark, #0f5c4e);
  font-weight: 600;
}

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='tel'],
input[type='url'],
input[type='date'],
input[type='time'],
input[type='month'],
input[type='number'],
textarea,
select,
input[type='file'] {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

/* Extra right padding so native dropdown arrow doesn't crowd the border */
select { padding-right: 36px; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.upload-preview {
  margin-bottom: 10px;
}

.logo-preview,
.favicon-preview {
  display: block;
  max-width: 100%;
  max-height: 76px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.favicon-preview {
  width: auto;
  max-height: 48px;
}

textarea { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Alert ──────────────────────────────────────────────────────────────────── */
.alert {
  display: none !important;
  padding: 12px 16px;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border: 1px solid #93c5fd; }

/* ─── Toasts ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: grid;
  gap: 12px;
  width: min(480px, calc(100vw - 32px));
  pointer-events: none;
}

.app-toast {
  display: grid;
  grid-template-columns: 8px 1fr;
  min-height: 86px;
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: 0 22px 56px rgba(15,23,42,.28);
  color: var(--text);
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: auto;
  border-radius: 8px;
  overflow: hidden;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.app-toast-bar { background: var(--info); }
.app-toast--success .app-toast-bar { background: var(--success); }
.app-toast--error .app-toast-bar { background: var(--danger); }
.app-toast--warning .app-toast-bar { background: var(--warning); }
.app-toast--warning {
  border-color: color-mix(in srgb, var(--warning) 55%, var(--border));
}
.app-toast--success {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}

.app-toast-text {
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}

.app-toast-body {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px 18px;
}

.app-toast-body .app-toast-text {
  padding: 0;
}

.app-toast-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-toast-action {
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--border));
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  border-radius: 5px;
}

.app-toast-action:hover {
  filter: brightness(.92);
}

@media (max-width: 640px) {
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
  }
}

/* ─── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background-color: #eef2f6;
  background-image:
    linear-gradient(180deg, rgba(14,38,63,.32), rgba(14,38,63,.18)),
    url("https://images.unsplash.com/photo-1770321119305-f191c09c5801?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTR8fGRlbnRhbCUyMGNoYWlyfGVufDB8fDB8fHww");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.admin-login-link {
  font-size: 12px;
  color: var(--text-light);
  text-decoration: none;
  opacity: 0.65;
  transition: opacity .15s;
  text-align: center;
}

.admin-login-link:hover { opacity: 1; }

.auth-card {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.55);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-description {
  margin-top: 12px;
  color: var(--text-muted);
  padding: 0 14px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-logo .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.auth-logo .brand-mark img {
  max-height: 96px;
  max-width: 280px;
  width: auto;
}

.auth-header h1 { font-size: 22px; margin-bottom: 6px; }
.auth-header p  { color: var(--text-muted); font-size: 14px; }

.auth-form { display: flex; flex-direction: column; }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
}

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }

.setup-tabs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.setup-tab-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  overflow: visible;
  background: var(--surface);
}

.setup-tab-bar .tab-btn {
  padding: 14px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.setup-tab-bar .tab-btn:hover { color: var(--text); background: var(--surface-alt); }
.setup-tab-bar .tab-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -4px;
}
.setup-tab-bar .tab-btn.active,
.setup-tab-bar .tab-btn[aria-selected="true"] {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

.setup-tab-bar .tab-btn--advanced {
  margin-left: auto;
  color: var(--text-light);
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.setup-tab-bar .tab-btn--advanced::before {
  content: '';
  display: block;
  width: 1px;
  height: 16px;
  margin: 0;
  background: var(--border);
}

.setup-tab-bar .tab-btn--advanced.active,
.setup-tab-bar .tab-btn--advanced[aria-selected="true"] {
  color: var(--brand-dark);
}

.setup-tab-panels .tab-panel {
  display: none;
  padding: 28px;
}

.setup-tab-panels .tab-panel.active { display: block; }
.setup-tab-panels .tab-panel[hidden] { display: none; }

/* ─── Asset upload row ──────────────────────────────────────────────────────── */

.asset-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

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

.asset-slot > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.asset-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-height: 64px;
}

.asset-preview-wrap img {
  display: block;
  max-height: 38px;
  width: auto;
  max-width: 100%;
}

.asset-remove-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--surface);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.asset-preview-wrap:hover .asset-remove-btn { display: flex; }

/* ─── Messages / Correspondence ─────────────────────────────────────────────── */
.message-list { display: flex; flex-direction: column; gap: 16px; }

.message-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message-bubble--admin {
  background: var(--brand-light);
  color: var(--text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.message-bubble--customer {
  background: #e0f2fe;
  color: var(--text);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.message-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.message-meta--right { text-align: right; }

.message-item { display: flex; flex-direction: column; }
.message-item--right { align-items: flex-end; }

.message-compose {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.compose-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Document list ──────────────────────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 10px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: background var(--transition);
}

.doc-item:hover { background: var(--surface-alt); }

.doc-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brand-light);
  color: var(--brand-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.doc-icon--pdf  { background: #fee2e2; color: #dc2626; }
.doc-icon--word { background: #dbeafe; color: #1d4ed8; }
.doc-icon--excel{ background: #dcfce7; color: #16a34a; }
.doc-icon--img  { background: #f3e8ff; color: #7c3aed; }
.doc-icon--zip  { background: #fef3c7; color: #d97706; }
.doc-icon--dwg  { background: #f1f5f9; color: #475569; }

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.doc-delete-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.doc-delete-btn:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.doc-edit-btn:hover { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand); }

/* ─── Case detail header ─────────────────────────────────────────────────────── */
.case-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 24px;
}

.case-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.case-title-row h1 { font-size: 22px; }

.case-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.case-meta-item { display: flex; flex-direction: column; gap: 3px; }
.case-meta-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); }
.case-meta-value { font-size: 14px; font-weight: 500; color: var(--text); }
.case-meta-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.25;
}
.case-meta-item--contact,
.case-meta-item--mobile-title {
  display: none;
}
.case-meta-item--editable {
  position: relative;
  cursor: pointer;
}
.case-meta-item--editable:hover .case-meta-value,
.case-meta-item--editable:hover .status-badge {
  opacity: .82;
}
.case-inline-editor {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  z-index: 30;
  min-width: min(260px, 70vw);
  box-shadow: var(--shadow-lg);
}
.case-inline-editor.is-open {
  display: block;
}
.case-inline-planned.is-open {
  display: grid;
  grid-template-columns: 1fr 95px 80px auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: min(520px, 88vw);
}
.case-inline-planned input {
  min-height: 34px;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 { font-size: 18px; }

.modal-header--edit-case {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
  padding-bottom: 12px;
}

.edit-case-back-btn {
  margin-right: auto;
}

/* Modal size variants */
.modal--wide { max-width: 700px; }
.modal--xl   { max-width: 960px; border-radius: 0; max-height: 80vh; }

/* ─── Tag chips (sagstyper / ansvarlige) ─────────────────────────────────────── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  min-height: 48px;
  align-items: center;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

.tag-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
}
.tag-chip-remove:hover { color: var(--danger, #dc2626); background: var(--danger-bg, #fee2e2); }

.tag-empty { font-size: 13px; color: var(--text-light); }

.contact-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}
.contact-settings-row:last-child { border-bottom: none; }

.tag-add-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

/* ─── Contact repeater ───────────────────────────────────────────────────────── */
.repeater-section       { margin-top: 8px; }
.repeater-section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; }
.repeater-list          { display: flex; flex-direction: column; gap: 12px; }
.repeater-row           { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 12px 12px 38px; position: relative; }
.repeater-row-grid      { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.repeater-remove        { position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; border: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1; }
.repeater-add           { margin-top: 10px; }

/* ─── Inline field error ─────────────────────────────────────────────────────── */
.field-error { font-size: 11px; color: var(--danger); margin-top: 3px; display: none; }
.field-error.is-visible { display: block; }
input.is-invalid { border-color: var(--danger) !important; }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { font-size: 14px; margin-top: 8px; }

/* ─── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Notices / tags ─────────────────────────────────────────────────────────── */
.notice-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ─── Invite list ────────────────────────────────────────────────────────────── */
.customer-list { display: flex; flex-direction: column; gap: 10px; }

.customer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 10px;
  gap: 12px;
  border: 1px solid #f0f0f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.customer-row:hover {
  border-color: #e5e7eb;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.customer-info { flex: 1; }
.customer-name { font-size: 14px; font-weight: 600; }
.customer-contact { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Upload zone ────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface-alt);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}

.upload-zone p { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .navbar-inner { gap: 16px; }
  .user-info { display: none; }
  .navbar-links { display: none; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px; box-shadow: var(--shadow); }
  .navbar-links.is-open { display: flex; }
  .mobile-menu-toggle { display: flex; }
  .navbar { position: relative; }
  .main-content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .case-title-row { flex-direction: column; }
  .page-header { flex-direction: column; }
}

/* ─── Setup / Onboarding ─────────────────────────────────────────────────────── */
.setup-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.setup-progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.setup-progress-step + .setup-progress-step::before {
  content: '';
  width: 32px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.setup-progress-step.done + .setup-progress-step::before { background: var(--brand); }

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.setup-progress-step.active .step-circle {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.setup-progress-step.done .step-circle {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
}

.step-circle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.setup-progress-step.active .step-circle-label { color: var(--brand-dark); }
.setup-progress-step.done .step-circle-label  { color: var(--brand-dark); }

/* Setup card with numbered header */
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.setup-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.setup-number {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.setup-card-header h2 { font-size: 16px; }
.setup-card-header p  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.setup-card-body { padding: 24px; }

/* Collapsible guide */
.guide-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--brand-light);
  border: 1px solid rgba(37, 99, 235, .22);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-dark);
  text-align: left;
  margin-bottom: 20px;
  transition: background var(--transition);
}

.guide-toggle:hover { background: #d4ede9; }
.guide-toggle svg { flex-shrink: 0; transition: transform .2s; }
.guide-toggle.open svg { transform: rotate(180deg); }

.guide-body {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.guide-body h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

.guide-body h4:first-child { margin-top: 0; }

.guide-body ol, .guide-body ul {
  padding-left: 20px;
  margin: 0;
}

.guide-body li { margin-bottom: 6px; }

.guide-body strong { color: var(--text); }

/* Permission tags */
.perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.perm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
}

.perm-tag--app {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

.perm-tag--delegated {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.perm-badge {
  font-size: 10px;
  background: rgba(0,0,0,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Code blocks */
.cmd-block {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: 'Consolas', 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.cmd-block .cmd-comment { color: #64748b; }
.cmd-block .cmd-keyword { color: #7dd3fc; }
.cmd-block .cmd-string  { color: #86efac; }

code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--brand-dark);
}

/* Input with visibility toggle */
.input-secret-wrap {
  position: relative;
  display: flex;
}

.input-secret-wrap input {
  flex: 1;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}

.input-secret-wrap input:focus { z-index: 1; }

.input-secret-wrap .toggle-secret {
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background var(--transition);
}

.input-secret-wrap .toggle-secret:hover { background: var(--surface-hover); }

/* Test result banner */
.test-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-top: 10px;
}

.test-result--ok    { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.test-result--error { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.test-result--info  { background: var(--info-bg);    color: #1e3a8a; border: 1px solid #93c5fd; }

/* Setup section divider */
.setup-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Env status indicator */
.env-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.env-status--set   { background: var(--success-bg); color: var(--success); }
.env-status--unset { background: var(--warning-bg); color: var(--warning); }
.env-status--def   { background: var(--gray-bg);    color: var(--gray);   }

/* Save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -4px 16px rgba(15,23,42,.06);
  z-index: 50;
  margin: 0 -24px;
}

.save-bar p { font-size: 13px; color: var(--text-muted); }

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 20px; }
  .auth-card { padding: 28px 20px; }
  .message-bubble { max-width: 90%; }

  /* ── Case header on mobile ── */
  .case-header {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: var(--radius);
  }

  .case-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }

  .case-title-row h1 { font-size: 18px; }
  .eyebrow { font-size: 11px; }

  .case-meta-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .case-meta-label { font-size: 10px; }
  .case-meta-value { font-size: 13px; }

  /* ── Tabs on mobile ── */
  .tabs { margin-bottom: 12px; gap: 0; }
  .tab-btn { font-size: 13px; padding: 10px 14px; }

  /* ── Card on mobile ── */
  .card { border-radius: var(--radius); padding: 0; }
  .card-header { padding: 14px 14px 12px; }

  /* ── Chat compose on mobile ── */
  .chat-editor { min-height: 60px; padding: 10px 12px; font-size: 14px; }
  .chat-footer { padding: 7px 10px; }
  .chat-send-hint { display: none; }
  .chat-toolbar-btn { min-width: 28px; height: 26px; }

  /* ── Chat thread on mobile ── */
  .chat-thread { padding: 12px; gap: 10px; }
  .chat-bubble { max-width: 90%; font-size: 13px; padding: 9px 12px; }
  .chat-meta { font-size: 11px; }
  .chat-section-label { font-size: 11px; padding: 8px 14px; }
}

/* ─── Admin sidebar shell ────────────────────────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sb-border);
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-logo .brand-mark img {
  height: 6rem;
  width: auto;
}


.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--sb-muted);
  padding: 16px 12px 6px;
  flex-shrink: 0;
}

.sidebar-add-btn {
  background: none;
  border: none;
  color: var(--sb-accent);
  border-radius: 4px;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .13s, color .13s, border-color .13s;
  flex-shrink: 0;
}

.sidebar-add-btn:hover { background: var(--sb-hover); color: var(--sb-text); border-color: var(--sb-text); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-item:hover { background: var(--sb-hover); color: var(--sb-text); }
.sidebar-item.is-active { background: var(--sb-active); color: var(--sb-accent); font-weight: 600; }

.sidebar-item svg { flex-shrink: 0; opacity: 0.65; }
.sidebar-item.is-active svg { opacity: 1; }

.sidebar-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-count {
  font-size: 11px;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.12);
  color: var(--brand-dark);
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item.is-active .sidebar-count {
  background: #dbeafe;
  color: var(--brand-dark);
}

.sidebar-customer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sb-muted);
  flex-shrink: 0;
  margin-left: 1px;
}

.sidebar-item.is-active .sidebar-customer-dot { background: var(--sb-accent); }

.sidebar-calendar-alerts {
  margin: 8px 10px 4px;
  padding: 9px;
  border: 1px solid rgba(217, 119, 6, .42);
  background: #fff7ed;
  color: #7c2d12;
  border-radius: 7px;
  flex-shrink: 0;
}

.sidebar-calendar-alert {
  display: none;
  min-height: 142px;
}

.sidebar-calendar-alert.is-active {
  display: flex;
  flex-direction: column;
}

.sidebar-calendar-alert.is-loading {
  opacity: .62;
  pointer-events: none;
}

.sidebar-calendar-alert__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.sidebar-calendar-alert__kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-calendar-alert__count {
  font-size: 11px;
  font-weight: 800;
  color: #9a3412;
  white-space: nowrap;
}

.sidebar-calendar-alert__title {
  color: #7c2d12;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-calendar-alert__title:hover { text-decoration: underline; }

.sidebar-calendar-alert__meta {
  font-size: 12px;
  line-height: 1.3;
  margin-top: 6px;
  color: #9a3412;
}

.sidebar-calendar-alert__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
}

.sidebar-calendar-alert__btn {
  border: 1px solid rgba(154, 52, 18, .28);
  background: #ffffff;
  color: #7c2d12;
  border-radius: 6px;
  padding: 6px 7px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.sidebar-calendar-alert__btn:hover {
  border-color: rgba(154, 52, 18, .52);
  background: #ffedd5;
}

.sidebar-calendar-alert__btn--danger {
  background: #9f1239;
  border-color: #9f1239;
  color: #fff;
}

.sidebar-calendar-alert__btn--danger:hover {
  background: #881337;
  border-color: #881337;
}

.sidebar-calendar-alert__pager {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 7px;
}

.sidebar-calendar-alert__pager button {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(154, 52, 18, .25);
  background: #fff;
  color: #7c2d12;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  font-size: 15px;
  font-weight: 800;
}

.sidebar-calendar-alert__dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-calendar-alert__dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(154, 52, 18, .28);
}

.sidebar-calendar-alert__dots span.is-active { background: #9a3412; }

.sidebar-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 12px;
  flex-shrink: 0;
}

.sidebar-tech-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 12px 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--sb-border);
}
.sidebar-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--sb-muted);
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-footer-nav {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.sidebar-item--create {
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sb-accent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
  background: var(--sb-active);
  color: var(--sb-accent);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sb-text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role { font-size: 11px; color: var(--sb-muted); display: block; }

.sidebar-logout-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--sb-border);
  background: transparent;
  color: var(--sb-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
  flex-shrink: 0;
}

.sidebar-logout-btn:hover { background: var(--sb-hover); color: var(--sb-text); border-color: var(--sb-text); }

/* ─── Admin main area ────────────────────────────────────────────────────────── */
.main-area {
  min-height: 100vh;
  background: oklch(94.5% 0.012 245);
}

.main-area .main-content {
  max-width: none;
  padding: 32px 36px;
  min-height: calc(100vh - 64px);
}

/* ─── Customer shell (sidebar layout) ───────────────────────────────────────── */
.customer-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Case grid ─────────────────────────────────────────────────────────────── */
.case-grid {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

/* Inside a cases-panel the grid inherits the panel's border/radius */
.cases-panel .case-grid {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.case-grid-header {
  display: grid;
  grid-template-columns: 2fr 4fr 3fr 2fr 1fr;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.cg-col {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.cg-col:hover { color: var(--text); }

.sort-arrow { opacity: .8; }

.case-grid-row {
  display: grid;
  grid-template-columns: 2fr 4fr 3fr 2fr 1fr;
  align-items: center;
  border-bottom: 1px solid var(--border);
  border-left: 5px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}

.case-grid-row:last-of-type { border-bottom: none; }
.case-grid-row:hover { background: var(--surface-alt); }

/* Status border colors */
.case-grid-row[data-status="Ny"]                { border-left-color: #2563eb; }
.case-grid-row[data-status="Åben"]              { border-left-color: #16a34a; }
.case-grid-row[data-status="Åbent"]             { border-left-color: #2563eb; }
.case-grid-row[data-status="Løst"]              { border-left-color: #16a34a; }
.case-grid-row[data-status="Afventer"]          { border-left-color: #d97706; }
.case-grid-row[data-status="Afventer mægler"]   { border-left-color: #d97706; }
.case-grid-row[data-status="Afventer kommunen"] { border-left-color: #7c3aed; }
.case-grid-row[data-status="Lukket"]            { border-left-color: #94a3b8; }
/* Legacy statuses */
.case-grid-row[data-status="Afventer"]          { border-left-color: #d97706; }
.case-grid-row[data-status="Igang"]             { border-left-color: #2563eb; }

.cg-cell {
  padding: 13px 14px;
}

.cg-title-main {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.cg-title-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cg-addr-main {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.cg-addr-sub {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.cg-cell.cg-responsible {
  font-size: 13px;
  color: var(--text-muted);
}

.cg-cell.cg-id code {
  font-size: 11px;
  color: var(--text-light);
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
}

.case-grid-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Magic link section ─────────────────────────────────────────────────────── */
.magic-link-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.magic-link-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}


.magic-link-feedback {
  font-size: 13px;
  color: #16a34a;
  background: #dcfce7;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 8px;
}

/* ─── Mobile-only filter strip (hidden on desktop) ─────────────────────────── */
.context-strip--mobile-filter { display: none; }

/* ─── Context heading strip ─────────────────────────────────────────────────── */
.context-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.context-strip h1 { font-size: 22px; font-weight: 700; }
.context-strip .context-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ─── Mobile topbar ──────────────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--sb-bg);
  z-index: 100;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--sb-border);
  border-radius: 0;
  flex-shrink: 0;
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.mobile-topbar-brand .brand-mark { max-height: 44px; }
.mobile-topbar-brand .brand-mark img { max-height: 44px; width: auto; height: auto; }
.mobile-topbar-brand .brand-mark-primary { font-size: 13px; font-weight: 700; color: var(--sb-text); display: block; white-space: nowrap; }
.mobile-topbar-brand .brand-mark-secondary { font-size: 10px; color: var(--sb-muted); display: block; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }

.mobile-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.mobile-hamburger span {
  display: block;
  width: 26px;
  height: 2.5px;
  background: var(--brand);
  border-radius: 2px;
  transition: all 0.2s;
}

.mobile-hamburger:hover span { background: #fff; }

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  z-index: 150;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}

.sidebar-overlay.is-visible { display: block; }

/* ─── Sidebar close button (mobile) ─────────────────────────────────────────── */
.sidebar-mobile-close {
  display: none;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: var(--sb-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-mobile-close:hover { background: rgba(255,255,255,0.18); color: #fff; }

.mobile-sticky-nav {
  display: none;
}

.pull-refresh-indicator {
  position: fixed;
  top: -52px;
  left: 50%;
  z-index: 1700;
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, 0);
  transition: transform .18s ease, color .18s ease;
}

.pull-refresh-indicator span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
}

.pull-refresh-indicator.is-ready {
  color: var(--brand);
}

.pull-refresh-indicator.is-refreshing span {
  animation: pull-refresh-spin .75s linear infinite;
}

@keyframes pull-refresh-spin {
  to { transform: rotate(360deg); }
}

/* ─── Mobile breakpoint ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }

  .mobile-topbar { display: flex; }
  .admin-shell > .mobile-topbar { display: none !important; }
  .mobile-topbar-brand {
    margin-left: auto;
    justify-content: flex-end;
  }

  .admin-shell, .customer-shell {
    grid-template-columns: 1fr;
    padding-top: 64px;
  }

  .admin-shell {
    padding-top: 0;
    padding-bottom: var(--mobile-nav-h);
  }

  .mobile-sticky-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 140;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    min-height: 62px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 26px rgba(15,23,42,.12);
  }

  .mobile-sticky-nav--case {
    grid-template-columns: repeat(3, 1fr);
  }

  .mobile-sticky-nav__item {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 50px;
    font: inherit;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    cursor: pointer;
  }

  .mobile-sticky-nav__item svg {
    flex-shrink: 0;
  }

  .mobile-sticky-nav__item.is-active {
    color: var(--brand);
  }

  .pull-refresh-indicator {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    height: calc(100vh - var(--mobile-nav-h));
    height: calc(100dvh - var(--mobile-nav-h));
    width: 82vw;
    max-width: 320px;
    z-index: 200;
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }

  .admin-shell .sidebar .sidebar-item[href="/admin/calendar.php"],
  .admin-shell .sidebar .sidebar-item[href="/cases"] {
    display: none;
  }

  .sidebar-logo .brand-mark img { height: auto; max-height: 38px; }

  .sidebar.is-open {
    transform: none;
    box-shadow: 6px 0 40px rgba(0,0,0,0.35);
  }

  body.sidebar-open { overflow: hidden; }

  .sidebar-overlay {
    bottom: var(--mobile-nav-h);
    background: rgba(0,0,0,0.38);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .sidebar-mobile-close { display: flex; }

  .main-area .main-content { padding: 20px 16px; }
  .context-strip { flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
  .context-strip > div:first-child { min-width: 0; }
  .context-strip h1 { font-size: 19px; }
  .case-grid-header, .case-grid-row { grid-template-columns: 1fr 2fr 1fr; }
  .cg-col.cg-responsible, .cg-cell.cg-responsible,
  .cg-col.cg-id, .cg-cell.cg-id { display: none; }
  .cg-header, .cg-row { min-width: 0; grid-template-columns: 2fr 3fr 2fr 1fr 0 1fr; }
  .company-manager { grid-template-columns: 1fr; }
  .filter-btn-group { display: flex; flex-wrap: wrap; gap: 6px; }
  .cases-panel .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-bar .search-input-wrap { flex: 1 1 100%; }
  .filter-select--mobile { display: block !important; width: 100%; }
  .context-strip--mobile-filter { display: flex; margin-bottom: 16px; }
  .filter-bar-mobile { flex: 1; }
  .filter-bar-mobile .search-input-wrap { width: 100%; }

  body.overview-page .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .overview-page .stat-card[data-status="Løst"] {
    display: none;
  }

  .overview-page .stat-card {
    padding: 14px 12px;
  }

  .overview-page .stat-card__label {
    font-size: 10px;
    line-height: 1.15;
  }

  .overview-page .stat-card__value {
    font-size: 24px;
  }

  .overview-page .cg-header { display: none; }
  .overview-page .cg-hide-mobile { display: none !important; }

  .overview-page .cg-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title title"
      "co    resp";
    row-gap: 0;
    column-gap: 8px;
    align-items: start;
    min-width: 0 !important;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid transparent;
    box-shadow: none;
    margin-bottom: 0;
    padding: 13px 13px 13px 14px;
    position: relative;
  }

  .overview-page .cg-row.is-filter-hidden {
    display: none !important;
  }

  .overview-page .cg-row .cg-cell { padding: 0; overflow: visible; }
  .overview-page .cg-row .cg-cell.cg-title {
    grid-area: title;
    padding-right: 132px;
    padding-bottom: 8px;
    font-size: 15px;
    line-height: 1.3;
  }
  .overview-page .cg-row .cg-cell.td-kunde {
    grid-area: co;
    display: flex !important;
    flex-direction: column;
    gap: 1px;
    padding-top: 8px;
  }
  .overview-page .cg-row .cg-cell.cg-id {
    grid-area: resp;
    display: block !important;
    padding-top: 8px;
    justify-self: end;
    text-align: right;
  }
  .overview-page .cg-row .cg-cell.cg-id::before {
    content: 'Sagsnr.';
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-light);
    margin-bottom: 2px;
  }
  .overview-page .cg-row .cg-cell.cg-time { display: none !important; }
  .overview-page .cg-row .cg-cell.cg-status {
    position: absolute;
    top: 13px;
    right: 13px;
    max-width: 126px;
    overflow: visible;
  }

  .overview-page .filter-btn-group {
    display: none;
  }

  .overview-page .mobile-status-filter {
    display: block !important;
    margin-left: auto;
  }

  .overview-page .cases-panel .filter-bar {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
  }

  .overview-page .filter-bar > .button {
    width: max-content;
  }

  .overview-page .filter-bar .search-input-wrap {
    grid-column: 1 / -1;
    width: 100%;
  }

  body.overview-page .admin-shell,
  body.overview-page .main-area,
  body.overview-page .main-area .main-content {
    min-height: 0;
  }

  body.overview-page .admin-shell {
    padding-bottom: 0;
  }

  body.overview-page .main-area .main-content {
    padding-bottom: 16px;
  }

  body.overview-page.overview-has-scroll .main-area .main-content {
    padding-bottom: calc(var(--mobile-nav-h) + 16px);
  }
}

/* ─── Mobile case cards (≤ 600 px) ──────────────────────────────────────────── */
@media (max-width: 600px) {
  body.overview-page .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* ── Shared card container strip ── */
  .case-grid {
    border: none; border-radius: 0;
    background: transparent; box-shadow: none; overflow: visible;
  }

  /* Inside cases-panel: rows are flat list items, not cards */
  .cases-panel .case-grid { overflow: hidden; }

  /* ─── Customer case rows inside panel ────────────────────────────────────── */
  .case-grid-header { display: none; }

  .case-grid-row {
    display: grid !important;
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "resp";
    row-gap: 5px;
    align-items: start;
    border: none;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid transparent;
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    margin-bottom: 0;
    padding: 13px 13px 13px 14px;
    position: relative;
    transition: background .15s;
  }

  .cases-panel .case-grid-row:last-of-type { border-bottom: none; }
  .case-grid-row:hover { background: var(--surface-hover); box-shadow: none; }

  /* Status border colors (left accent) */
  .case-grid-row[data-status="Ny"]                { border-left-color: #2563eb; }
  .case-grid-row[data-status="Åben"]              { border-left-color: #16a34a; }
  .case-grid-row[data-status="Afventer mægler"]   { border-left-color: #d97706; }
  .case-grid-row[data-status="Afventer kommunen"] { border-left-color: #7c3aed; }
  .case-grid-row[data-status="Lukket"]            { border-left-color: #94a3b8; }

  /* Status badge – absolute top-right */
  .case-grid-row .cg-cell.cg-status {
    position: absolute;
    top: 12px; right: 12px;
    grid-area: unset;
  }

  /* Title */
  .case-grid-row .cg-cell.cg-title {
    grid-area: title;
    padding-right: 100px;
    padding-bottom: 0;
  }

  .case-grid-row .cg-cell.cg-title .cg-title-main { font-size: 15px; font-weight: 600; display: block; }
  .case-grid-row .cg-cell.cg-title .cg-title-sub  { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }

  /* Address – hidden on mobile */
  .case-grid-row .cg-cell.cg-address { display: none !important; }

  /* Ansvarlig */
  .case-grid-row .cg-cell.cg-responsible {
    grid-area: resp;
    display: block !important;
    font-size: 13px;
    color: var(--text-muted);
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 3px;
  }

  .case-grid-row .cg-cell.cg-responsible::before {
    content: 'Ansvarlig';
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-light);
    margin-bottom: 2px;
  }

  /* Sagsnr – hidden */
  .case-grid-row .cg-cell.cg-id { display: none !important; }

  /* ─── Cases panel: ét hvidt kort der indeholder filter + rækker ── */
  .cases-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .cases-panel .filter-bar {
    background: var(--surface-alt);
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 0;
    padding: 12px;
  }

  /* ─── Admin case rækker inde i panel ─────────────────────────────────────── */
  .cg-header { display: none; }
  .cg-hide-mobile { display: none !important; }

  .cg-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title title"
      "co    resp";
    row-gap: 0;
    column-gap: 8px;
    align-items: start;
    min-width: 0 !important;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid transparent;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    padding: 13px 13px 13px 14px;
    position: relative;
    cursor: pointer;
    transition: background .15s;
  }

  .cg-row:last-child { border-bottom: none; }
  .cg-row:hover { background: var(--surface-hover); }

  /* Status border colors */
  .cg-row[data-status="Ny"]                { border-left-color: #2563eb; }
  .cg-row[data-status="Åben"]              { border-left-color: #16a34a; }
  .cg-row[data-status="Afventer mægler"]   { border-left-color: #d97706; }
  .cg-row[data-status="Afventer kommunen"] { border-left-color: #7c3aed; }
  .cg-row[data-status="Lukket"]            { border-left-color: #94a3b8; }

  .cg-row .cg-cell { padding: 0; overflow: visible; }

  /* Title – fuld bredde øverst */
  .cg-row .cg-cell.cg-title {
    grid-area: title;
    padding-right: 90px;
    padding-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
  }

  /* Firma / kontaktperson – venstre kolonne i bunden */
  .cg-row .cg-cell.td-kunde {
    grid-area: co;
    display: flex !important;
    flex-direction: column;
    gap: 1px;
    padding-top: 8px;
  }

  .cg-row .cg-cell.td-kunde .cg-main { font-size: 12px; color: var(--text-muted); }
  .cg-row .cg-cell.td-kunde .cg-sub  { font-size: 11px; color: var(--text-light); }

  /* Ansvarlig – højre kolonne i bunden, samme linje som firma */
  .cg-row .cg-cell.cg-responsible-cell {
    grid-area: resp;
    display: block !important;
    font-size: 12px;
    color: var(--text-muted);
    text-align: left;
    padding-top: 8px;
  }

  .overview-page .cg-row .cg-cell.cg-id {
    display: block !important;
    justify-self: end;
    text-align: right;
  }

  .cg-row .cg-cell.cg-responsible-cell::before {
    content: 'Ansvarlig';
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-light);
    margin-bottom: 2px;
  }

  /* Sagsnr / tid – hidden */
  .cg-row .cg-cell.cg-id,
  .cg-row .cg-cell.cg-time {
    display: none !important;
  }

  /* Status badge – absolut øverst til højre */
  .cg-row .cg-cell.cg-status {
    position: absolute;
    top: 13px; right: 13px;
  }

  /* Company-manager two-panel becomes single column */
  .company-manager { grid-template-columns: 1fr; min-height: auto; }
  .co-list-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .co-detail-inner { padding: 16px; }
}

/* ── Sidebar notification badge ──────────────────────────────────────────── */
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand, #10b981);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Upload drop zone ────────────────────────────────────────────────────── */
.upload-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}
.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--brand, #10b981);
  background: #f0fdf8;
}
.upload-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px;
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}
.upload-drop-inner svg { opacity: .5; }
.upload-drop-inner small { font-size: 11px; color: var(--text-light); opacity: .8; }

.upload-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.upload-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.upload-file-item:last-child { border-bottom: none; }
.upload-file-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.upload-file-size { font-size: 12px; color: var(--text-light); flex-shrink: 0; }
.upload-file-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color .1s;
}
.upload-file-remove:hover { color: var(--danger, #dc2626); }

/* ─── Microsoft SSO button ───────────────────────────────────────────────────── */
.button-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}

.button-microsoft:hover { background: #f6f8fa; box-shadow: var(--shadow-md); }

/* ─── Auth divider ───────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  font-size: 12px;
  color: var(--text-light);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Auth fallback details ──────────────────────────────────────────────────── */
.auth-fallback {
  margin-top: 12px;
}

.auth-fallback summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.auth-fallback summary:hover { color: var(--text); }

/* ─── Setup page form elements ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-group--full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.label-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-light);
  margin-left: 4px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
}

.field-delete {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.field-delete input {
  width: auto;
  margin: 0;
}

.upload-preview {
  margin-bottom: 10px;
}

.logo-preview,
.favicon-preview {
  display: block;
  max-width: 100%;
  max-height: 76px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.favicon-preview {
  width: auto;
  max-height: 48px;
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-field input { flex: 1; font-family: 'Consolas', 'JetBrains Mono', monospace; font-size: 13px; }

/* ─── Setup info / steps ─────────────────────────────────────────────────────── */
.setup-info {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.setup-info p { margin-bottom: 10px; }

.setup-steps {
  padding-left: 20px;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-steps li { font-size: 13px; }

/* ─── Status badge variants for SSO state ────────────────────────────────────── */
.status-badge--active   { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.status-badge--inactive { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group--full { grid-column: auto; }
}

/* ─── Company manager (shared: admin/customers.php + settings.php) ────────── */
.company-manager { display: grid; grid-template-columns: 300px 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); min-height: 560px; }
.co-list-panel { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.co-list-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.co-list-header h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0; }
.co-list-scroll { flex: 1; overflow-y: auto; }
.co-card { display: block; padding: 14px 20px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; transition: background var(--transition); cursor: pointer; }
.co-card:hover { background: var(--surface-alt); }
.co-card.is-active { background: var(--brand-light); border-left: 3px solid var(--brand); padding-left: 17px; }
.co-card-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.co-card-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; }
.co-empty { padding: 32px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.co-detail-panel { background: var(--surface-alt); display: flex; flex-direction: column; }
.co-detail-empty { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--text-muted); }
.co-detail-inner { padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.co-info-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.co-info-name { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.co-info-addr { font-size: 14px; color: var(--text-muted); }

/* ─── Contact table (shared) ─────────────────────────────────────────────── */
.contacts-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.contacts-card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.contacts-card-header h4 { margin: 0; font-size: 14px; font-weight: 700; }
.contact-table { width: 100%; border-collapse: collapse; }
.contact-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 9px 16px; border-bottom: 1px solid var(--border); text-align: left; background: var(--surface-alt); }
.contact-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.contact-table tr:last-child td { border-bottom: none; }
.contact-table tr:hover td { background: var(--surface-alt); }
.contact-inv { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; }
.contact-inv.sent { color: var(--success); background: var(--success-bg); }
.contact-inv.pending { color: var(--text-muted); background: var(--gray-bg); }

/* ─── Changelog / Opdatering tab ─────────────────────────────────────────────── */
.cl-version-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.cl-version-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.cl-version-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.cl-release {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--surface);
}

.cl-release--latest {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 4px 16px rgba(37, 99, 235, .12);
}

.cl-release-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  gap: 12px;
}

.cl-release--latest .cl-release-header {
  background: linear-gradient(90deg, rgba(37, 99, 235, .08) 0%, transparent 100%);
  border-bottom-color: var(--border);
}

.cl-release-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cl-badge-latest {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--brand);
  color: #0f2b26;
}

.cl-release-version {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.cl-release-date {
  font-size: 13px;
  color: var(--text-muted);
}

.cl-release-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cl-section {}

.cl-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand);
  margin-bottom: 8px;
}

.cl-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cl-list li {
  font-size: 13.5px;
  color: var(--text-muted);
  padding-left: 16px;
  position: relative;
  line-height: 1.55;
}

.cl-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
}

.cl-release--latest .cl-list li::before {
  background: var(--brand);
  opacity: .6;
}

.cl-markdown {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-muted);
}

/* ── Chat bubbles & compose ──────────────────────────────────────────────── */
.desc-block {
  padding: 16px 18px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 80px;
  margin-bottom: 24px;
}
.desc-block p { margin: 0; line-height: 1.75; color: var(--text-muted); white-space: pre-wrap; }
.desc-empty   { color: var(--text-light); font-style: italic; }

.chat-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 500px;
  overflow-y: auto;
  padding: 4px 2px 16px;
  scroll-behavior: smooth;
}
.chat-thread::-webkit-scrollbar { width: 4px; }
.chat-thread::-webkit-scrollbar-track { background: transparent; }
.chat-thread::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-msg        { display: flex; flex-direction: column; max-width: 80%; }
.chat-msg--own   { align-self: flex-end;   align-items: flex-end; }
.chat-msg--other { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-bubble p  { margin: 0 0 5px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul,
.chat-bubble ol { margin: 4px 0 4px 18px; padding: 0; }
.chat-bubble li { margin-bottom: 2px; }
.chat-bubble div { margin: 0; }

.chat-msg--other .chat-bubble {
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg--own .chat-bubble {
  background: var(--brand-light);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.chat-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 5px;
  padding: 0 4px;
}

.chat-bubble-files {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-bubble-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(0,0,0,.07);
  color: inherit;
  text-decoration: none;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-bubble-file:hover { background: rgba(0,0,0,.12); }

.chat-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}

/* Compose */
.chat-compose {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 16px;
  position: relative; /* needed for send-menu positioning */
}
.chat-compose--locked {
  opacity: .55;
  pointer-events: none;
  user-select: none;
}
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
}
.chat-toolbar-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, border-color .1s, color .1s;
  line-height: 1;
}
.chat-toolbar-btn:hover    { background: var(--surface); border-color: var(--border); color: var(--text); }
.chat-toolbar-btn.is-active { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); }
.chat-toolbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

.chat-editor {
  min-height: 80px;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  outline: none;
}
.chat-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  pointer-events: none;
  display: block;
  font-size: 13px;
  font-weight: 400;
}
.chat-editor ul, .chat-editor ol { margin-left: 20px; }

.chat-pending-files {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.chat-pending-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  max-width: 220px;
}
.chat-pending-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.chat-pending-file button { background: none; border: none; cursor: pointer; color: var(--text-light); font-size: 16px; line-height: 1; padding: 0; margin: 0; flex-shrink: 0; }
.chat-pending-file button:hover { color: var(--danger, #dc2626); }

.chat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 8px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-footer-left  { display: flex; align-items: center; gap: 6px; }
.chat-footer-right { display: flex; align-items: center; gap: 8px; }
.chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background .1s, border-color .1s, color .1s;
}
.chat-attach-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }

.chat-autoclose-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s, border-color .1s, color .1s;
}
.chat-autoclose-btn:hover { background: var(--surface); color: var(--text); }
.chat-autoclose-btn.is-active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

/* ── Inline image in chat ──────────────────────────────────────────────── */
.chat-inline-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
  margin: 6px 0;
  box-shadow: var(--shadow-sm);
}

/* ── Lightbox ──────────────────────────────────────────────────────────── */
.chat-lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  animation: lb-in .15s ease;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.chat-lightbox img {
  max-width: min(92vw, 1200px);
  max-height: 78vh;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  cursor: default;
}
.chat-lightbox-actions {
  display: flex;
  gap: 10px;
}
.chat-lightbox-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: white;
  color: #1a2332;
}
.chat-lightbox-btn.close-btn {
  background: rgba(255,255,255,.15);
  color: white;
}
.chat-lightbox-btn:hover { opacity: .85; }

/* ── Split send button (admin) ─────────────────────────────────────────── */
.chat-send-split {
  position: relative;
  display: inline-flex;
}
.chat-send-split .btn-main {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: 1px solid rgba(255,255,255,.25);
}
.chat-send-split .btn-caret {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0 8px;
  min-width: 0;
  display: flex;
  align-items: center;
}
.chat-send-split .btn-caret svg { display: block; }
.chat-send-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
  display: none;
}
.chat-send-menu.is-open { display: block; }
.chat-send-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.chat-send-menu-item:last-child { border-bottom: none; }
.chat-send-menu-item:hover { background: var(--surface-hover); }

/* ── Quick status change in header ─────────────────────────────────────── */
.status-quick-wrap {
  position: relative;
  display: inline-flex;
}
.status-quick-wrap .status-badge { cursor: pointer; }
.status-quick-wrap .status-badge:hover { opacity: .8; }
.status-quick-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
  display: none;
}
.status-quick-menu.is-open { display: block; }
.status-quick-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
}
.status-quick-item:last-child { border-bottom: none; }
.status-quick-item:hover { background: var(--surface-hover); }

/* ── Toast notification ────────────────────────────────────────────────── */
.chat-toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  max-width: 320px;
  background: var(--sb-bg);
  color: var(--sb-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 1900;
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.chat-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.chat-toast-sender {
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 12px;
  color: var(--brand);
}
.chat-toast-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-send-hint { font-size: 11px; color: var(--text-light); }

/* ── Overview page: square status-accented cards and rows ───────────────── */
.overview-page .card,
.overview-page .stat-card,
.overview-page .cases-panel,
.overview-page .case-grid,
.overview-page .case-grid-row,
.overview-page .cg-row,
.overview-page .filter-bar,
.overview-page .filter-btn,
.overview-page .search-input,
.overview-page .search-input-wrap {
  border-radius: 0 !important;
}

.overview-page .stat-card {
  border-left: 5px solid transparent;
}

.overview-page .stat-card[data-status="Åbent"] {
  border-left-color: #2563eb;
}

.overview-page .stat-card[data-status="Løst"] {
  border-left-color: #16a34a;
}

.overview-page .stat-card[data-status="Afventer"] {
  border-left-color: #d97706;
}

/* ── Tight case page layout ─────────────────────────────────────────────── */
.case-page * {
  border-radius: 0 !important;
}

.case-page .admin-shell,
.case-page .main-area {
  min-height: 100vh;
  height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
}

.case-page .main-area {
  overflow: hidden;
}

.case-page .main-area .main-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 24px;
  overflow: hidden;
}

.case-page .main-content > div:first-child,
.case-page .case-header,
.case-page .tabs,
.case-page #feedback {
  flex-shrink: 0;
}

.case-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.case-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.case-top-tabs {
  margin: 0;
  border-bottom: 0;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}

.case-top-tabs .tab-btn {
  min-height: 34px;
  padding: 7px 16px;
  margin-bottom: 0;
  border-bottom: 0;
  border-left: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.case-top-tabs .tab-btn:first-child {
  border-left: 0;
}

.case-top-tabs .tab-btn.active {
  background: var(--brand);
  color: #fff;
}

.case-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.doc-upload-btn:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: var(--brand);
}

.visually-hidden-file {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.case-page .case-header,
.case-page .card,
.case-panel,
.case-side-panel,
.quick-section {
  box-shadow: none;
}

.case-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.case-page #panel-documents {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}

.case-primary,
.case-side-panel {
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.case-primary {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.case-side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
}

.case-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.case-panel:first-child {
  flex: 1 1 56%;
}

.case-panel:last-child {
  flex: 1 1 44%;
}

.case-panel + .case-panel {
  border-top: 1px solid var(--border);
}

.case-serial-strip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.case-serial-input {
  width: 100%;
  max-width: 360px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.case-serial-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.case-panel-head,
.quick-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.case-panel-head h3,
.quick-section-head h3 {
  font-size: 14px;
}

.case-textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  line-height: 1.55;
}

.autosave-status {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
}

.rich-toolbar {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: var(--surface-alt);
}

.rich-toolbar button {
  width: 34px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.rich-toolbar button:hover,
.rich-toolbar button:focus-visible {
  background: var(--surface);
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

.rich-editor {
  flex: 1;
  min-height: 0;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.rich-editor:focus {
  border-color: var(--brand-primary);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
}

.rich-editor--short {
  min-height: 0;
}

.rich-editor p,
.rich-editor ul,
.rich-editor ol {
  margin: 0 0 10px;
}

.case-location-details {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.case-location-detail {
  display: grid;
  gap: 3px;
}

.case-location-detail strong {
  color: var(--text);
  font-weight: 700;
}

.case-side-panel {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  overflow-y: auto;
}

.quick-section {
  padding: 0;
}

.quick-section + .quick-section {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.quick-section-head span {
  min-width: 24px;
  padding: 2px 7px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

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

.quick-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quick-form input,
.quick-form select,
.case-textarea {
  padding: 8px 10px;
  font-size: 13px;
}

.quick-form input,
.quick-form select,
.quick-form button {
  min-height: 38px;
}

.quick-grid {
  display: grid;
  gap: 8px;
  align-items: end;
}

.quick-grid--2 { grid-template-columns: 1fr 1fr; }
.quick-grid--1 { grid-template-columns: 1fr; }
.quick-grid--3 { grid-template-columns: 1fr 1fr auto; }

.quick-material-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px auto;
  gap: 8px;
  align-items: end;
}

.quick-list {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.quick-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 26px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.quick-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-row strong {
  color: var(--text);
  white-space: nowrap;
}

.quick-delete-btn {
  width: 24px;
  height: 24px;
}

@media (max-width: 1100px) {
  .case-page .admin-shell,
  .case-page .main-area {
    height: auto;
    min-height: 100vh;
  }

  .case-page .main-area {
    overflow: visible;
  }

  .case-page .main-area .main-content {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .case-workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .case-side-panel {
    position: static;
    min-height: 0;
    overflow: visible;
  }

  .case-primary,
  .case-side-panel {
    height: auto;
  }
}

@media (max-width: 768px) {
  .case-page {
    overflow-x: hidden;
  }

  .case-page .admin-shell,
  .case-page .main-area {
    background: var(--surface);
  }

  .case-page .main-area .main-content {
    width: 100%;
    max-width: none;
    padding: 0 0 28px;
    overflow-x: hidden;
  }

  .case-page .mobile-topbar {
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }

  .case-page .button {
    min-height: 42px;
    padding: 9px 14px;
  }

  .case-page .button-sm {
    min-height: 38px;
    padding: 8px 12px;
  }

  .case-page .main-content > div:first-child {
    margin-bottom: 8px !important;
  }

  .case-page .case-header {
    width: 100%;
    padding: 12px;
    margin: 0 0 10px;
    border: 0;
  }

  .case-title-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
  }

  .case-title-row > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .case-title-row h1 {
    display: block;
    margin-top: 3px;
    font-size: 18px;
    line-height: 1.18;
  }

  .case-title-row .eyebrow {
    margin-bottom: 0;
    font-size: 10px;
  }

  .case-title-row .doc-edit-btn {
    width: 32px;
    height: 32px;
  }

  .case-meta-contact-inline,
  .case-scheduled-time,
  .case-meta-item--hours,
  #meta-created-item {
    display: none !important;
  }

  .case-meta-item--contact,
  .case-meta-item--mobile-title {
    display: flex;
  }

  .case-meta-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    border-top: 0;
  }

  .case-meta-item:nth-child(1) { order: 1; }
  .case-meta-item--contact { order: 2; }
  .case-meta-item:nth-child(3) { order: 3; }
  .case-meta-item:nth-child(4) { order: 4; }
  .case-meta-item--location,
  .case-meta-item--mobile-title {
    display: none !important;
  }
  .case-meta-item--planned { order: 5; grid-column: 1 / -1; }
  .case-meta-item--span2-mobile { grid-column: 1 / -1; }

  .case-meta-item {
    min-width: 0;
    padding: 9px 10px;
    border-top: 0;
    border-bottom: 0;
  }

  .case-meta-item:nth-child(odd) {
    border-right: 0;
  }

  .case-meta-item--planned,
  .case-meta-item--span2-mobile {
    border-right: 0 !important;
    border-bottom: 0 !important;
  }

  .case-meta-label {
    font-size: 9px;
    line-height: 1.1;
  }

  .case-meta-value {
    font-size: 13px;
    line-height: 1.18;
    overflow-wrap: anywhere;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    display: block;
    max-width: 100%;
  }

  .case-inline-editor {
    position: static;
    min-width: 0;
    margin-top: 6px;
    box-shadow: none;
  }

  .case-inline-planned.is-open {
    display: none;
  }

  .case-inline-planned .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .case-page .tabs {
    position: sticky;
    top: 56px;
    z-index: 60;
    background: var(--surface);
    margin: 0 0 10px;
    padding: 0;
    overflow-x: auto;
    border-bottom-width: 1px;
    scrollbar-width: none;
  }

  .case-page .tabs::-webkit-scrollbar {
    display: none;
  }

  .case-page .tab-btn {
    min-height: 44px;
    padding: 11px 14px;
    white-space: nowrap;
    font-size: 14px;
  }

  .case-topbar {
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }

  .case-topbar-left {
    width: 100%;
  }

  .case-desktop-action {
    display: none;
  }

  .case-page .case-top-tabs {
    position: static;
    top: auto;
    z-index: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: var(--surface);
    border: 1px solid var(--border);
  }

  .case-page .case-top-tabs .tab-btn {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .case-workspace {
    gap: 0;
    width: 100%;
  }

  .case-side-panel {
    order: -1;
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
    padding: 0;
    align-items: stretch;
  }

  .quick-section {
    width: 100%;
    padding: 12px;
  }

  .quick-section + .quick-section {
    padding-top: 12px;
    border-top: 0;
  }

  .quick-section-head {
    margin-bottom: 8px;
    justify-content: flex-start;
    text-align: left;
  }

  .quick-section-head h3 {
    font-size: 15px;
  }

  .quick-section-head span {
    display: none;
  }

  .quick-grid {
    gap: 7px;
    min-width: 0;
  }

  .quick-grid--2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .quick-grid--1 {
    grid-template-columns: minmax(0, 1fr);
  }

  .quick-grid--3 {
    grid-template-columns: 1fr 1fr;
  }

  .quick-grid--3 button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .quick-form {
    gap: 9px;
  }

  .quick-form label {
    font-size: 11px;
  }

  .quick-form input,
  .quick-form select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 9px 10px;
  }

  .quick-row {
    padding: 9px 0;
    font-size: 12px;
    border-bottom: 0;
  }

  .case-page .time-row-date {
    display: none;
  }

  .quick-list {
    border-top: 0;
  }

  .case-primary {
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .case-panel {
    padding: 12px;
  }

  .case-page #panel-documents {
    height: auto;
    min-height: 0;
    flex: none;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .case-panel-head {
    margin-bottom: 8px;
  }

  .case-textarea {
    min-height: 180px;
    padding: 11px 10px;
    line-height: 1.5;
  }

  .rich-editor {
    min-height: 190px;
    padding: 11px 10px;
    line-height: 1.5;
  }

  #resolution-text {
    min-height: 140px;
  }

  .case-page .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .case-page .modal {
    max-width: none;
    max-height: none;
    min-height: 100vh;
    padding: 18px 14px 28px;
  }

  .case-page .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    margin: -18px -14px 16px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 430px) {
  .case-meta-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .quick-grid--2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .case-page .quick-time-duration-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .quick-material-line {
    grid-template-columns: 1fr 80px;
  }

  .quick-material-line button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* ── iOS: prevent auto-zoom on focus (min 16px on all inputs) ───────────── */
@media (max-width: 768px) {
  input, textarea, select, [contenteditable] {
    font-size: 16px !important;
  }
}

/* ── Sidebar mini calendar ── */
.sidebar-mini-cal {
  padding: 10px 10px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.smc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.smc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}
.smc-nav {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  display: flex;
  align-items: center;
  line-height: 1;
}
.smc-nav:hover { color: var(--text); background: var(--surface-alt); }
.smc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  text-align: center;
}
.smc-grid--wk {
  grid-template-columns: 22px repeat(7, 1fr);
}
.smc-wday {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-light);
  padding: 3px 0 2px;
  text-transform: uppercase;
}
.smc-wday--wk {
  font-size: 8px;
}
.smc-wk {
  font-size: 9px;
  color: var(--text-light);
  padding: 2px 1px;
  line-height: 1.7;
  text-align: center;
}
.smc-day {
  font-size: 11px;
  padding: 2px 1px;
  color: var(--text);
  text-decoration: none;
  display: block;
  line-height: 1.7;
}
.smc-day:hover { background: var(--surface-alt); }
.smc-day--out { color: var(--text-light); }
.smc-day--today {
  background: var(--brand);
  color: #fff !important;
  font-weight: 800;
}
.smc-day--events { font-weight: 800; }
