/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --bg: #f1f5f9;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid #1e293b;
}

.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.logo-mark svg { width: 18px; height: 18px; color: white; }

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: .5px;
}

.sidebar-nav {
  padding: 16px 12px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--accent); color: #ffffff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Modulväljare (F0-07) — visas när fler än en modul är påslagen */
.module-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
}
.module-switch {
  /* Ikon över namnet, så att tre eller fler moduler (CRM, Freja, Planering) får plats */
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 7px;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-switch:hover { color: #e2e8f0; }
.module-switch.active { background: rgba(255,255,255,0.12); color: #ffffff; }
.module-switch svg { width: 14px; height: 14px; }

/* ── Main ──────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

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

.content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Alerts ────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); color: white; }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ghost { background: transparent; color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

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

.card-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

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

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

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}

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

.stat-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
}

.stat-card.accent { border-top: 3px solid var(--accent); }
.stat-card.success { border-top: 3px solid var(--success); }
.stat-card.warning { border-top: 3px solid var(--warning); }
.stat-card.danger  { border-top: 3px solid var(--danger); }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.td-actions { text-align: right; white-space: nowrap; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-width: 640px;
}

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

.form-grid .span-2 { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.form-group textarea { resize: vertical; min-height: 90px; }
.form-group select { cursor: pointer; }

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

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
}

.badge-active   { background: #d1fae5; color: #065f46; }
.badge-completed { background: #e0e7ff; color: #3730a3; }
.badge-on-hold  { background: #fef3c7; color: #92400e; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-won      { background: #d1fae5; color: #065f46; }
.badge-lost     { background: #fee2e2; color: #991b1b; }
.badge-overdue  { background: #fee2e2; color: #991b1b; }

/* Gemensamt kundregister (F0-08): aktiv kund i Fortnox + privatkund */
.fortnox-badge  { display: inline-flex; vertical-align: middle; color: #16a34a; }
.badge-private  { background: #fef3c7; color: #92400e; margin-left: 4px; }

/* Freja: orderstatus och jobbstatus (F1-04, F1-05) */
.badge-order-draft     { background: #f1f5f9; color: #475569; }
.badge-stock-in_stock  { background: #d1fae5; color: #065f46; }
.badge-stock-reorder   { background: #fef3c7; color: #92400e; }
.badge-stock-out       { background: #fee2e2; color: #991b1b; }
.badge-purchase-draft     { background: #f1f5f9; color: #475569; }
.badge-purchase-ordered   { background: #dbeafe; color: #1d4ed8; }
.badge-purchase-partial   { background: #fef3c7; color: #92400e; }
.badge-purchase-received  { background: #d1fae5; color: #065f46; }
.badge-purchase-cancelled { background: #fee2e2; color: #991b1b; }
.badge-unsaved         { background: #fef3c7; color: #92400e; margin-right: auto; margin-left: 10px; }
.badge-unsaved[hidden] { display: none; }
.alert[hidden] { display: none; }
.badge-order-prebooked { background: #e0e7ff; color: #3730a3; }
.badge-order-planned   { background: #dbeafe; color: #1d4ed8; }
.badge-order-done      { background: #d1fae5; color: #065f46; }
.badge-order-invoiced  { background: #ede9fe; color: #6d28d9; }
.badge-order-cancelled { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.badge-job-ordered     { background: #dbeafe; color: #1d4ed8; }
.badge-job-proposed    { background: #fef3c7; color: #92400e; }
.badge-job-approved    { background: #d1fae5; color: #065f46; }
.badge-job-declined    { background: #fee2e2; color: #991b1b; }

/* ── Dashboard ─────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.week-header {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 2px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #f8fafc; }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }

.task-check form { margin: 0; }

.task-check input[type="checkbox"] {
  width: 17px; height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 11.5px; color: var(--text-2); margin-top: 1px; }
.task-due { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.task-due.overdue { color: var(--danger); font-weight: 600; }

/* ── Assignee Counter ──────────────────────────────────────────────── */
.assignee-list { display: flex; flex-direction: column; gap: 10px; }

.assignee-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.assignee-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.assignee-name { flex: 1; font-weight: 500; font-size: 13px; }
.assignee-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: #eef2ff;
  padding: 2px 9px;
  border-radius: 20px;
}

/* ── Search ────────────────────────────────────────────────────────── */
.search-form { display: flex; gap: 8px; }
.search-input {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  width: 280px;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

/* ── Filters ───────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
  text-decoration: none;
}

.filter-tab:hover { color: var(--text); background: var(--card); }
.filter-tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

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

.empty-state svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--border); }

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Detail sections ───────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  font-size: 13.5px;
}

.detail-label { color: var(--text-2); font-weight: 500; font-size: 12px; }
.detail-value { color: var(--text); }

/* ── Value highlight ───────────────────────────────────────────────── */
.value-large {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

/* ── Misc ──────────────────────────────────────────────────────────── */
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 12.5px; }
.font-medium { font-weight: 500; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Calendar ──────────────────────────────────────────────────────── */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-period-title {
  font-size: 18px;
  font-weight: 700;
  min-width: 200px;
  text-align: center;
}

.cal-actions { display: flex; gap: 8px; }

/* Month grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-day-header {
  background: #f8fafc;
  text-align: center;
  padding: 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-2);
}

.cal-day {
  background: var(--card);
  min-height: 110px;
  padding: 7px 8px;
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.cal-day:hover { background: #f0f4ff; color: inherit; }
.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .cal-day-num { color: #cbd5e1; }
.cal-day.is-today { background: #eef2ff; }

.cal-day-num {
  font-size: 13px;
  font-weight: 500;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-bottom: 5px;
}

.cal-day.is-today .cal-day-num {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.cal-event {
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.cal-event.type-task {
  background: #eef2ff;
  color: #3730a3;
}

.cal-event.type-task.done {
  background: #f0fdf4;
  color: #166534;
  text-decoration: line-through;
  opacity: .7;
}

.cal-event.type-note {
  background: #fef3c7;
  color: #92400e;
}

.cal-more {
  font-size: 11px;
  color: var(--text-2);
  padding: 1px 6px;
  cursor: pointer;
}

/* Week grid */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.week-col {
  background: var(--card);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.week-col-header {
  padding: 12px 10px 10px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  text-align: center;
}

.week-col-name {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--text-2);
}

.week-col-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 2px;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.week-col.is-today .week-col-num { color: var(--accent); }
.week-col.is-today .week-col-header { background: #eef2ff; }

.week-col-events {
  padding: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-event {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-event.type-task { background: #eef2ff; color: #3730a3; }
.week-event.type-task.done { background: #f0fdf4; color: #166534; text-decoration: line-through; }
.week-event.type-note { background: #fef3c7; color: #92400e; }

.week-col-add {
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 4px;
}

.week-col-add a {
  font-size: 11px;
  color: var(--text-2);
  padding: 3px 6px;
  border-radius: 5px;
  text-decoration: none;
  transition: background .1s;
}

.week-col-add a:hover { background: var(--bg); color: var(--accent); }

/* Day view */
.day-view-header {
  margin-bottom: 24px;
}

.day-view-date {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.day-view-weekday {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 2px;
}

.day-section { margin-bottom: 20px; }

.day-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.day-event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.day-event-card .color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.day-event-info { flex: 1; }
.day-event-title { font-weight: 600; font-size: 14px; }
.day-event-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.day-event-actions { display: flex; gap: 6px; align-items: center; }

/* ── Settings ──────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.member-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.member-card:last-child { border-bottom: none; }
.member-card:hover { background: #f8fafc; }

.member-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 14px; }
.member-role { font-size: 12px; color: var(--text-2); }

.member-inactive { opacity: .45; }

.color-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1.5px var(--border);
  display: inline-block;
  vertical-align: middle;
}

.ics-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  font-family: monospace;
  word-break: break-all;
  color: var(--text-2);
}

.sync-steps { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sync-steps li {
  display: flex;
  gap: 10px;
  font-size: 13px;
}

.step-num {
  width: 22px; height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Timeline ───────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.timeline-icon svg { width: 15px; height: 15px; }

.timeline-icon.kind-activity  { background: #ede9fe; color: #7c3aed; }
.timeline-icon.kind-task       { background: #dbeafe; color: #2563eb; }
.timeline-icon.kind-task.done  { background: #dcfce7; color: #16a34a; }

.timeline-card { flex: 1; min-width: 0; }

.timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.timeline-title { font-weight: 600; font-size: 13.5px; }
.timeline-date  { font-size: 12px; color: var(--text-2); margin-left: auto; white-space: nowrap; }

.timeline-body {
  font-size: 13px;
  color: var(--text);
  margin: 4px 0;
  white-space: pre-line;
}

.timeline-meta {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.timeline-meta span { display: flex; align-items: center; gap: 4px; }

.timeline-actions { display: flex; gap: 6px; margin-top: 6px; }

/* Activity type badges */
.act-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.act-badge.visit        { background:#ede9fe; color:#6d28d9; }
.act-badge.phone-call   { background:#d1fae5; color:#065f46; }
.act-badge.email        { background:#dbeafe; color:#1d4ed8; }
.act-badge.meeting      { background:#fef3c7; color:#92400e; }
.act-badge.quote-sent   { background:#fce7f3; color:#9d174d; }
.act-badge.other        { background:#f1f5f9; color:#475569; }

/* New-contact indicator */
.new-contact-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

/* ── Quick-Log Panel (Dashboard) ────────────────────────────────────── */
.quick-log-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  overflow: hidden;
}

.quick-log-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.quick-log-toggle:hover { background: #f8fafc; }
.quick-log-toggle svg   { width: 16px; height: 16px; color: var(--accent); }
.quick-log-toggle .chevron { margin-left: auto; transition: transform .2s; }
.quick-log-toggle.open .chevron { transform: rotate(180deg); }

.quick-log-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
  display: none;
}
.quick-log-body.open { display: block; }

.quick-log-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  margin-top: 14px;
  align-items: end;
}

.quick-log-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.quick-log-summary { margin-top: 10px; }
.quick-log-summary textarea { resize: vertical; min-height: 60px; }

/* ── Sidebar user block ─────────────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 0 12px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-logout {
  font-size: 11px;
  color: #64748b;
}
.sidebar-user-logout:hover { color: #94a3b8; }

/* ── Auth pages (login / setup) ─────────────────────────────────────── */
.auth-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

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

/* ── Calendar day view grid ─────────────────────────────────────────── */
.day-view-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

/* ── Mobile bottom nav ──────────────────────────────────────────────── */
.mobile-nav {
  display: none;  /* hidden on desktop */
}

/* ── Responsive — tablet and phone ─────────────────────────────────── */
@media (max-width: 768px) {

  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Main takes full width, prevent horizontal overflow */
  .main {
    margin-left: 0;
    padding-bottom: 64px;  /* room for bottom nav */
    min-width: 0;
    overflow-x: hidden;
  }

  html, body { overflow-x: hidden; max-width: 100%; }

  .content { max-width: 100%; overflow-x: hidden; }

  /* Topbar: icon-only buttons on mobile — hide text, keep icons */
  .topbar-actions .btn { font-size: 0 !important; padding: 8px 10px; gap: 0; }
  .topbar-actions .btn svg { width: 18px; height: 18px; flex-shrink: 0; }

  /* Arne button clears mobile nav (60px) */
  #agent-toggle { bottom: 80px !important; right: 16px !important; }
  #agent-panel  { bottom: 152px !important; right: 8px !important;
                  width: calc(100vw - 16px) !important; }

  .topbar { padding: 0 16px; }

  .content { padding: 16px; }

  /* Show mobile bottom nav */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--sidebar-bg);
    height: 60px;
    z-index: 200;
    border-top: 1px solid #1e293b;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #64748b;
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    transition: color .15s;
  }

  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item:hover { color: #94a3b8; }
  .mobile-nav-item.active { color: var(--accent); }

  /* Calendar day view: single column, sidebar (mini cal) first */
  .day-view-grid  { grid-template-columns: 1fr; }
  .day-sidebar    { order: -1; }

  /* Single-column grids */
  .stats-grid         { grid-template-columns: 1fr 1fr; }
  .dashboard-grid     { grid-template-columns: 1fr; }
  .form-grid          { grid-template-columns: 1fr !important; }
  .detail-grid        { grid-template-columns: 1fr 1fr; }
  .settings-grid      { grid-template-columns: 1fr; }
  .quick-log-grid     { grid-template-columns: 1fr 1fr; }
  .quick-log-grid-2   { grid-template-columns: 1fr; }

  /* span-2 has no effect on single-column grid */
  .form-group.span-2  { grid-column: span 1; }

  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Page header stacks vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header-actions { flex-wrap: wrap; }

  /* Topbar actions wrap */
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* Auth card full width on small screens */
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 15px; }
}

/* ── Planering (F2-01–F2-03) ─────────────────────────────────────────── */
.plan-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.plan-legend span { display: inline-flex; align-items: center; gap: 5px; }
.plan-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.plan-scroll { overflow-x: auto; }
.plan-board { min-width: 860px; }
.plan-row { display: grid; grid-template-columns: 170px 1fr; border-bottom: 1px solid var(--border); min-height: 64px; }
.plan-row:last-child { border-bottom: none; }
.plan-label { padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; border-right: 1px solid var(--border); }
.plan-label small { display: block; font-weight: 400; color: var(--text-2); font-size: 11px; }
.plan-avatar { width: 28px; height: 28px; border-radius: 50%; color: white; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.plan-axis { position: relative; height: 26px; font-size: 11px; color: var(--text-2); }
.plan-axis span { position: absolute; top: 6px; transform: translateX(-50%); }
.plan-track { position: relative; background-image: linear-gradient(to right, var(--border) 1px, transparent 1px); background-size: var(--hour-width) 100%; }
.plan-track.drop-target { background-color: #eef2ff; }
.plan-work { position: absolute; top: 0; bottom: 0; background: rgba(99, 102, 241, .04); pointer-events: none; }
.plan-entry { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; padding: 4px 6px; font-size: 11.5px; line-height: 1.3; overflow: hidden; color: var(--text); text-decoration: none; border-left: 4px solid; cursor: grab; background: white; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.plan-entry:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 2; }
.plan-entry strong { font-size: 11.5px; }
.plan-entry .plan-meta { color: var(--text-2); }
.plan-status-draft     { border-color: #94a3b8; background: #f8fafc; }
.plan-status-prebooked { border-color: #6366f1; background: #eef2ff; }
.plan-status-planned   { border-color: #2563eb; background: #eff6ff; }
.plan-status-done      { border-color: #059669; background: #ecfdf5; }
.plan-status-invoiced  { border-color: #7c3aed; background: #f5f3ff; }
.plan-status-cancelled { border-color: #dc2626; background: #fef2f2; }
.plan-todo { display: block; padding: 8px 10px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; margin-bottom: 8px; font-size: 12.5px; cursor: grab; background: white; }
.plan-week td { vertical-align: top; min-width: 130px; }
.plan-week .plan-chip { display: block; border-left: 4px solid; border-radius: 5px; padding: 4px 6px; margin-bottom: 4px; font-size: 11.5px; text-decoration: none; color: var(--text); }
.plan-job { border-left: 4px solid; }
@media (max-width: 1024px) { .plan-layout { grid-template-columns: 1fr; } }

/* ── Arbetsordern enligt skiss A (F1-17) ─────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ao { --ao-line: #eef0f6; --ao-tile: #f3f4ff; --ao-tile-border: #c7c9fb; --ao-yellow: #fef3c7; --ao-yellow-text: #92400e; }
.ao .num { text-align: right; }
.ao-head { margin-bottom: 14px; }
.ao-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ao-title h1 { margin: 0; font-size: 20px; }
.ao-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.ao-inline-label { font-weight: 600; color: var(--text-2); }
.ao-compact { height: 30px; padding: 2px 8px; font-size: 12.5px; width: auto; }
.ao-label { display: block; color: var(--text-2); font-size: 11.5px; font-weight: 500; }
.ao-label-warn { color: var(--ao-yellow-text); font-weight: 600; }
.ao-ok { color: #0f7a52; }
.ao-alert { margin: -4px 0 12px; }

.ao-info { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; }
.ao-tile { font: inherit; text-align: left; background: var(--ao-tile); border: 1px solid var(--ao-tile-border); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text); min-width: 0; }
.ao-tile:hover { border-color: var(--accent); }
.ao-tile[aria-expanded="true"] { background: #e0e7ff; border-color: var(--accent); }
.ao-tile-label { display: flex; align-items: center; gap: 6px; color: var(--accent-hover); font-size: 11.5px; }
.ao-chevron::before { content: '\25BE'; }
.ao-tile[aria-expanded="true"] .ao-chevron::before { content: '\25B4'; }
.ao-tile-value { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ao-note { margin-left: auto; display: inline-flex; padding: 2px; border-radius: 4px; color: #c3c6d6; }
.ao-note svg { width: 14px; height: 14px; }
.ao-note.on { background: var(--ao-yellow); color: #b45309; }

.ao-panel { background: #fff; border: 1px solid var(--ao-tile-border); border-radius: 10px; padding: 14px 16px; margin: -6px 0 14px; }
.ao-panel[hidden] { display: none; }
.ao-panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 260px; gap: 10px 20px; font-size: 13px; }
.ao-panel-grid.ao-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.ao-side { grid-column: 4; grid-row: 1 / span 3; }
.ao-full, .ao-links, .ao-docs { grid-column: 1 / -1; }
.ao-yellow { background: var(--ao-yellow); color: var(--ao-yellow-text); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.ao-yellow-input { border-color: #fcd34d !important; background: #fffbeb !important; }
.ao-field { display: flex; flex-direction: column; gap: 4px; }
.ao-static { padding: 7px 0; }
.ao-hint { padding-bottom: 9px; }
.ao-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ao-links { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--ao-line); padding-top: 10px; color: var(--text-2); }
.ao-push { margin-left: auto; }
.ao-docs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ao-add { font: inherit; font-size: 12px; padding: 3px 8px; border: 1px dashed #c9cbe0; background: #fff; border-radius: 6px; color: var(--accent-hover); cursor: pointer; list-style: none; white-space: nowrap; }
.ao-add:disabled { opacity: .55; cursor: not-allowed; }
.ao-change { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--ao-line); margin-top: 12px; padding-top: 12px; }
.ao-inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ao-inline-form select, .ao-inline-form input[type=text] { width: auto; min-width: 200px; }
.ao-summary { cursor: pointer; font-weight: 600; font-size: 12.5px; }

/* Radtabellen: tät, samma kolumner för rubrik, rader och inmatningsraden */
.ao-lines { background: #fff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.ao-row { display: grid; grid-template-columns: 48px 96px minmax(0, 1fr) 64px 48px 96px 68px 104px 36px; gap: 8px; padding: 6px 14px; align-items: center; border-bottom: 1px solid #f1f2f7; font-size: 13px; }
.ao-row-head { background: #f8f9fc; color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; }
.ao-handle { color: #b5b8c9; cursor: grab; user-select: none; letter-spacing: -2px; }
.ao-artnr { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.ao-kind { color: #b5b8c9; font-size: 11.5px; }
.ao-text { min-width: 0; overflow-wrap: anywhere; }
.ao-sub { display: block; color: var(--text-2); font-size: 11.5px; }
.ao-mobile-meta { display: none; }
.ao-unit { color: var(--text-2); }
.ao-amount { font-weight: 600; white-space: nowrap; }
.ao-price { white-space: nowrap; }
.ao-disc-form { display: inline-flex; align-items: center; gap: 2px; margin: 0; }
.ao-disc-form input { width: 44px; padding: 1px 4px; height: 24px; text-align: right; border: 1px dashed #d6d8e4; border-radius: 4px; font-size: 12.5px; background: transparent; }
.ao-disc-form input:focus { border-style: solid; background: #fff; }
.ao-qty-form { margin: 0; }
.ao-qty-form input { width: 100%; max-width: 60px; padding: 1px 4px; height: 24px; text-align: right; border: 1px dashed #d6d8e4; border-radius: 4px; font-size: 13px; background: transparent; }
.ao-qty-form input:focus { border-style: solid; background: #fff; }
.ao-new-nr { position: relative; min-width: 0; }
.ao-suggest { position: absolute; left: 0; top: 30px; z-index: 30; width: 420px; max-width: calc(100vw - 32px); max-height: 320px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.ao-suggest li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 13px; }
.ao-suggest li strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ao-suggest li small { color: var(--text-2); white-space: nowrap; }
.ao-suggest li[aria-selected="true"], .ao-suggest li:hover { background: var(--ao-tile); }
.ao-line.ao-dragging { opacity: .4; }
.ao-drop { box-shadow: inset 0 2px 0 var(--accent); }

.ao-job-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px 6px; border-bottom: 1px solid var(--ao-line); flex-wrap: wrap; }
.ao-job-form { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 240px; margin: 0; }
.ao-job-no, .ao-job-title { font-weight: 700; font-size: 13.5px; white-space: nowrap; margin: 0; }
.ao-job-input { font-weight: 700; font-size: 13.5px; border: 1px solid transparent; background: transparent; padding: 3px 6px; flex: 1; min-width: 120px; max-width: 420px; }
.ao-job-input:hover, .ao-job-input:focus { border-color: var(--border); background: #fff; }
.ao-job-status-ordered { color: #1d4ed8; }
.ao-job-status-proposed { color: #92400e; }
.ao-job-status-approved { color: #0f7a52; }
.ao-job-status-declined { color: #991b1b; }
.ao-when-edited { display: none; }
.ao-job-form:focus-within .ao-when-edited { display: inline-flex; }
.ao-job-tools { display: flex; align-items: center; gap: 10px; }
.ao-job-sum { color: var(--text-2); white-space: nowrap; }
.ao-docicon { display: inline-flex; padding: 3px; color: #c3c6d6; }
.ao-docicon svg { width: 16px; height: 16px; }
.ao-camera { display: none; }

.ao-menu { position: relative; }
.ao-menu > summary { list-style: none; }
.ao-menu > summary::-webkit-details-marker { display: none; }
.ao-more { cursor: pointer; color: #8a8ea6; padding: 2px 8px; border-radius: 6px; font-size: 16px; line-height: 1; }
.ao-more:hover { background: var(--bg); color: var(--text); }
.ao-menu-list { position: absolute; right: 0; top: 28px; z-index: 20; min-width: 230px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; }
.ao-menu-list form { margin: 0; }
.ao-menu-list a, .ao-menu-list button { display: block; width: 100%; font: inherit; font-size: 13px; text-align: left; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; color: var(--text); cursor: pointer; text-decoration: none; }
.ao-menu-list a:hover, .ao-menu-list button:hover:not(:disabled) { background: var(--ao-tile); }
.ao-menu-list button:disabled { color: #8a8ea6; cursor: not-allowed; }
.ao-menu-sep { color: #8a8ea6; font-size: 11px; padding: 6px 10px 2px; border-top: 1px solid var(--ao-line); margin-top: 4px; }
.ao-danger { color: var(--danger) !important; }

.ao-new { background: #fbfbfd; color: #8a8ea6; margin: 0; border-bottom: 1px solid var(--border); }
.ao-new input, .ao-new select { height: 28px; padding: 2px 6px; font-size: 12.5px; width: 100%; min-width: 0; }
.ao-new-text { position: relative; display: flex; align-items: center; }
.ao-new-text input { padding-right: 58px; }
.ao-counter { position: absolute; right: 6px; font-size: 11px; color: #8a8ea6; pointer-events: none; }
.ao-new-add { padding: 4px 6px; }
.ao-new-add-text { display: none; }

.ao-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.ao-new-job input[type=text] { min-width: 260px; }
.ao-sum { display: flex; gap: 18px; align-items: baseline; flex-wrap: wrap; margin-left: auto; }
.ao-sum strong { margin-left: 6px; }
.ao-orderdocs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.ao-bar { display: none; }

@media (max-width: 768px) {
  .ao-info { grid-template-columns: 1fr; padding: 0; background: transparent; border: none; gap: 8px; }
  .ao-tile { min-height: 52px; padding: 10px 14px; border-radius: 12px; background: #fff; border-color: var(--border); }
  .ao-tile-label { font-size: 12px; color: var(--text-2); }
  .ao-tile-value { white-space: normal; font-size: 14px; }
  .ao-note svg { width: 18px; height: 18px; }
  .ao-panel { margin-top: -4px; border-radius: 12px; }
  .ao-panel-grid, .ao-panel-grid.ao-cols-3 { grid-template-columns: 1fr; }
  .ao-side { grid-column: auto; grid-row: auto; order: -1; }
  .ao-push { margin-left: 0; }
  .ao-inline-form select, .ao-inline-form input[type=text] { min-width: 0; width: 100%; }
  .ao-panel .btn, .ao-change .btn { min-height: 44px; }

  .ao-lines { background: transparent; border: none; }
  .ao-row-head { display: none; }
  .ao-job { background: #fff; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; }
  .ao-job-head { padding: 12px 14px; }
  .ao-job-form { min-width: 0; flex-wrap: wrap; }
  .ao-job-tools { width: 100%; justify-content: flex-end; }
  .ao-camera { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--ao-tile-border); background: var(--ao-tile); color: var(--accent-hover); border-radius: 10px; }
  .ao-camera:disabled { opacity: .55; }
  .ao-camera svg { width: 22px; height: 22px; }
  .ao-add, .ao-more { min-height: 44px; display: inline-flex; align-items: center; }
  /* Två rader per orderrad: text och belopp överst, typ · antal × pris under */
  .ao-line { grid-template-columns: minmax(0, 1fr) auto auto 44px; grid-template-areas: "text text amount menu" "text qty disc menu"; padding: 10px 14px; gap: 2px 10px; }
  .ao-line .ao-handle, .ao-line .ao-artnr, .ao-line .ao-unit, .ao-line .ao-price { display: none; }
  .ao-line .ao-qty { grid-area: qty; }
  .ao-qty-form input { height: 32px; width: 56px; }
  .ao-line .ao-text { grid-area: text; }
  .ao-line .ao-amount { grid-area: amount; }
  .ao-line .ao-disc { grid-area: disc; }
  .ao-line .ao-line-menu { grid-area: menu; }
  .ao-mobile-meta { display: block; color: #8a8ea6; font-size: 12.5px; }
  .ao-disc-form input { height: 32px; width: 52px; }
  .ao-new { grid-template-columns: 64px minmax(0, 1fr) 72px 64px; grid-template-areas: "kind nr nr nr" "text text text text" "qty unit price add"; gap: 8px; padding: 10px 14px; border-radius: 0 0 14px 14px; }
  .ao-new input, .ao-new select, .ao-new .btn { height: 44px; font-size: 15px; }
  .ao-new .ao-new-kind { grid-area: kind; }
  .ao-new .ao-new-nr { grid-area: nr; }
  .ao-suggest { top: 48px; }
  .ao-new .ao-new-text { grid-area: text; }
  .ao-new input[name=quantity] { grid-area: qty; }
  .ao-new select[name=unit] { grid-area: unit; }
  .ao-new input[name=unit_price] { grid-area: price; }
  .ao-new input[name=discount_percent] { display: none; }
  .ao-new-add { grid-area: add; justify-content: center; }
  .ao-foot { flex-direction: column; align-items: stretch; padding: 0; }
  .ao-new-job { flex-wrap: nowrap; }
  .ao-new-job input[type=text] { min-width: 0; height: 44px; }
  .ao-new-job .btn { min-height: 44px; white-space: nowrap; }
  .ao-sum { display: none; }
  .ao-orderdocs { border-radius: 14px; }
  .ao-orderdocs .ao-add { min-height: 44px; }
  /* Fast nederlist ovanför menyn: summa exkl./inkl. moms och Spara */
  .ao-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 60px; z-index: 150; align-items: center; gap: 12px; background: #fff; border-top: 1px solid var(--border); padding: 10px 16px; font-size: 13px; }
  .ao-bar-sums { flex: 1; }
  .ao-bar-save { min-height: 48px; padding: 0 22px; font-size: 15px; }
  .main:has(.ao-bar) { padding-bottom: 140px; }
  body:has(.ao-bar) #agent-toggle { bottom: 140px !important; }
}

/* Operationsregistret: tidskolumnerna centrerade över sina fält */
.op-table th.op-hours, .op-table td.op-hours { text-align: center; }
.op-table td.op-hours input { width: 70px; text-align: center; }

/* Rabatt på jobbet eller ordern (F1-20) */
.ao-discount-all { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.ao-menu-list .ao-discount-all { padding: 8px 10px; border-top: 1px solid var(--ao-line); margin-top: 4px; }
.ao-discount-all input[name=discount_percent] { width: 56px; height: 28px; padding: 2px 6px; text-align: right; }
.ao-discount-all select { width: auto; height: 28px; padding: 2px 6px; font-size: 12.5px; }
.ao-menu-list .ao-discount-all button { width: auto; display: inline-flex; padding: 4px 10px; background: var(--bg); border: 1px solid var(--border); }

/* Makulera (F1-22) */
.ao-linkbtn { font: inherit; background: none; border: none; padding: 0; color: var(--danger); cursor: pointer; text-decoration: underline; }
.ao-panel-danger { border-color: #fca5a5; }
.ao-cancelled { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ao-cancelled form { margin: 0; }

/* Orderlistans sök och filter (F1-23) */
.ao-orders-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ao-orders-filter input[type=search] { flex: 1; min-width: 200px; max-width: 360px; height: 38px; }
.ao-orders-filter select { width: auto; height: 38px; }
.ao-mine { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; }
.ao-mine input { width: auto; }

/* Planeringen: tydligare Förbokad (F2-09), linje mellan dagarna (F2-10), dra i kanten (F2-11),
   klick på ledig tid (F2-12), kundförslag (F2-13) */
.plan-status-prebooked { border-style: dashed; border-color: #6366f1;
  background: repeating-linear-gradient(135deg, #eef2ff 0 6px, #ffffff 6px 12px); }
.plan-entry.plan-status-prebooked, .plan-todo.plan-status-prebooked, .plan-chip.plan-status-prebooked {
  border-top: 1px dashed #6366f1; border-right: 1px dashed #6366f1; border-bottom: 1px dashed #6366f1; border-left: 4px dashed #6366f1; }
.plan-week th + th, .plan-week td + td { border-left: 1px solid var(--border); }
.plan-week td.drop-target { background: #eef2ff; }
.plan-entry { position: absolute; }
.plan-resize { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.plan-resize-start { left: -3px; }
.plan-resize-end { right: -3px; }
.plan-entry:hover .plan-resize { background: rgba(99, 102, 241, .25); }
.plan-chip { position: relative; }
.plan-chip-resize { position: absolute; right: 2px; bottom: 2px; font-size: 12px; color: var(--text-2); cursor: ew-resize; padding: 0 3px; border-radius: 3px; }
.plan-chip-resize:hover { background: #e0e7ff; color: var(--accent-hover); }
.plan-board { position: relative; }
.plan-slot-menu { position: absolute; z-index: 40; min-width: 200px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; }
.plan-slot-menu[hidden] { display: none; }
.plan-slot-menu [data-slot-label] { padding: 4px 10px; }
.plan-slot-menu button, .plan-slot-menu a { font: inherit; font-size: 13px; text-align: left; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; color: var(--text); cursor: pointer; text-decoration: none; }
.plan-slot-menu button:hover, .plan-slot-menu a:hover { background: #eef2ff; }
.plan-track { cursor: copy; }
.suggest-wrap { position: relative; display: block; }

/* Ny order: fordonsträffar (F1-32) */
.nv-hits { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.nv-hit { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.nv-hit:hover { border-color: var(--accent); background: #f5f6ff; }

/* Fordonsformuläret: ny kund som ägare (testlistan 2026-10-13) */
.nc-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: #fafbff; }
.nc-summary { cursor: pointer; font-weight: 600; font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nc-summary svg { width: 16px; height: 16px; }
.owner-chosen { margin-top: 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
/* Teckenräknaren: under fältet när texten blir lång (F1-31) */
.ao-new-text.ao-long .ao-counter { position: static; display: block; margin-top: 2px; text-align: right; }
.ao-new-text.ao-long { flex-direction: column; align-items: stretch; }
.ao-new-text.ao-long input { padding-right: 6px; }

.plan-chip.plan-resizing { outline: 2px solid var(--accent); }
.plan-chip-resize { user-select: none; }
.plan-chip { padding-right: 22px; }
.plan-chip-resize { right: 0; bottom: 0; top: 0; width: 18px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 2px; font-size: 14px; border-radius: 0 5px 5px 0; }
#agent-toggle[hidden], #agent-panel[hidden] { display: none !important; }

/* HR-modulen (H-01) */
.hr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.hr-stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.hr-stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.hr-stat span { color: var(--text-2); font-size: 13px; }
.hr-stat-bad { border-left: 4px solid var(--danger); }
.hr-stat-warn { border-left: 4px solid var(--warning); }
.hr-badge-expired { background: #fee2e2; color: #991b1b; }
.hr-badge-expiring { background: #fef3c7; color: #92400e; }
.hr-badge-valid { background: #d1fae5; color: #065f46; }
.hr-badge-ended { background: #f1f5f9; color: #475569; }
.hr-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.hr-filter input[type=search] { flex: 1; min-width: 220px; max-width: 380px; }
.hr-filter select, .hr-filter input[type=date] { width: auto; }
.hr-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hr-head h1 { margin: 0; font-size: 20px; }
.hr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.hr-facts { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.hr-facts > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.hr-facts > div > span:first-child { color: var(--text-2); font-size: 12px; }
.hr-inline { display: inline-flex; gap: 6px; align-items: center; margin: 4px 0 0; flex-wrap: wrap; }
.hr-inline select, .hr-inline input { width: auto; height: 30px; padding: 2px 6px; font-size: 12.5px; }
.hr-addrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); margin: 0; }
.hr-addrow input, .hr-addrow select { width: auto; min-width: 0; }
.hr-addrow label { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-2); margin: 0; font-weight: normal; }
.hr-h3 { font-size: 14px; margin: 18px 0 6px; }
.hr-mini { width: 100%; font-size: 13px; }
.hr-mini td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.hr-cost { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.hr-cost > div { background: var(--bg); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.hr-cost span { color: var(--text-2); font-size: 12px; }
.hr-cost b { font-size: 15px; font-variant-numeric: tabular-nums; }
.hr-cost small { color: var(--text-2); font-size: 11px; }
.hr-cost-total { background: #eef2ff !important; }
.hr-holders { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.hr-holder { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #d1fae5; color: #065f46; text-decoration: none; margin-right: 4px; }
.hr-holder-expiring { background: #fef3c7; color: #92400e; }
.hr-holder-expired { background: #fee2e2; color: #991b1b; }

/* ── Dev-markering (dev.pureenergy.site) ─────────────────────────────────────── */
.env-banner { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; text-align: center;
  font-size: 12.5px; font-weight: 600; padding: 4px 12px; letter-spacing: .02em; }
.env-banner-fixed { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; }

/* ── Microsoft-inloggning (F0-02) ───────────────────────────────────────────── */
.btn-microsoft { width: 100%; justify-content: center; gap: 10px; margin-bottom: 16px; }
.auth-local summary { cursor: pointer; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.auth-local[open] summary { margin-bottom: 16px; }
.ms-link-form { display: flex; gap: 6px; margin-top: 6px; max-width: 420px; }
.ms-link-form input { flex: 1; min-width: 0; font-size: 12.5px; padding: 5px 8px; }
.badge-ms-ok { background: #dcfce7; color: #166534; }
.badge-ms-wait { background: #fef9c3; color: #854d0e; }
