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

:root {
  --accent:        #E2001A;
  --accent-dark:   #b80015;
  --accent-light:  #fce8ea;

  --sidebar-w:     240px;

  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --surface-2:     #f8f9fa;

  --border:        #e2e5e9;
  --border-light:  #eef0f3;

  --text:          #0f1117;
  --text-2:        #5c6370;
  --text-3:        #9ba3ae;

  --success:       #16a34a;
  --success-light: #dcfce7;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #2563eb;
  --info-light:    #dbeafe;
  --purple:        #7c3aed;
  --purple-light:  #ede9fe;

  --radius:        8px;
  --radius-sm:     6px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 2px 6px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:     0 8px 28px rgba(0,0,0,.10), 0 2px 10px rgba(0,0,0,.06);
}

body {
  font-family: 'Exo 2', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

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

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
#page-content { padding: 28px 32px; flex: 1; }

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
#topbar {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}
#topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
#topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.login-logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-logo-icon svg { width: 18px; height: 18px; }
.sidebar-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav-section {
  padding: 16px 4px 5px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }

.logout-btn {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; padding: 5px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.logout-btn:hover { background: var(--danger-light); color: var(--danger); }
.logout-btn svg { width: 16px; height: 16px; }

/* ── Login ───────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.login-logo span { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-2); margin-bottom: 28px; font-size: 13.5px; }

/* ── Page headers ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.page-subtitle { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body { padding: 18px; }
.card-title { font-size: 13.5px; font-weight: 600; }

/* ── Stat cards ──────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card.accent {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: white;
}
.stat-card.accent .stat-label  { color: rgba(255,255,255,.65); }
.stat-card.accent .stat-sub    { color: rgba(255,255,255,.65); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.stat-value { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -1.5px; margin-bottom: 6px; }
.stat-sub { font-size: 12px; color: var(--text-3); }

/* ── Overview panels ─────────────────────────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.overview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.overview-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.overview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.overview-title svg { width: 16px; height: 16px; color: var(--text-3); }
.overview-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-light);
}
.overview-stat {
  background: var(--surface);
  padding: 16px 18px;
}
.overview-stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.overview-stat-label svg { width: 13px; height: 13px; opacity: .6; }
.overview-stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.8px; line-height: 1; }
.overview-stat-value.ok      { color: var(--text); }
.overview-stat-value.warn    { color: var(--warning); }
.overview-stat-value.success { color: var(--success); }
.overview-stat-value.danger  { color: var(--accent); }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.status-badge-ok      { background: var(--success-light); color: var(--success); }
.status-badge-warn    { background: var(--warning-light); color: var(--warning); }
.status-badge-danger  { background: var(--accent-light);  color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Exo 2', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.1px;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

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

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: #ccd0d5; }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-ghost     { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-sm  { padding: 5px 11px; font-size: 12.5px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  color: var(--text-2); transition: background .1s, color .1s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 15px; height: 15px; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"],
input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: 'Exo 2', sans-serif;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.1s, box-shadow 0.1s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226,0,26,.10);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

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

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody tr.clickable { cursor: pointer; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ny        { background: var(--info-light);    color: var(--info); }
.badge-planerad  { background: var(--purple-light);  color: var(--purple); }
.badge-pagaende  { background: var(--warning-light); color: var(--warning); }
.badge-klar      { background: var(--success-light); color: var(--success); }
.badge-fakturerad{ background: var(--border);        color: var(--text-2); }

.badge-admin     { background: var(--accent-light);  color: var(--accent); }
.badge-chef      { background: var(--info-light);    color: var(--info); }
.badge-mekaniker { background: var(--success-light); color: var(--success); }
.badge-lager     { background: var(--warning-light); color: var(--warning); }

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}
.search-wrap input { padding-left: 32px; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid;
}
.alert-error   { background: var(--danger-light);  color: #991b1b; border-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.alert-success { background: var(--success-light); color: #15803d; border-color: var(--success); }
.alert-info    { background: var(--info-light);    color: #1e40af; border-color: var(--info); }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.30);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp .15s ease;
}
.modal-box.modal-lg { max-width: 700px; }
@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px; border-radius: 4px;
  display: flex; align-items: center;
  transition: background .1s, color .1s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 2000;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 500;
  min-width: 240px; max-width: 340px;
  animation: toastIn .15s ease;
}
@keyframes toastIn {
  from { transform: translateX(12px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast-icon { width: 15px; height: 15px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error   { border-left: 3px solid var(--accent); }
.toast-error .toast-icon { color: var(--accent); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-info .toast-icon { color: var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 18px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .1s, border-color .1s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Work Order detail ───────────────────────────────────────────────────────── */
.order-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.meta-group h3 {
  font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-3);
  font-weight: 700; margin-bottom: 10px;
}
.meta-row { display: flex; gap: 8px; font-size: 13.5px; margin-bottom: 5px; }
.meta-label { color: var(--text-2); min-width: 110px; font-weight: 500; }

.order-header-bar {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.order-number { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.order-desc { color: var(--text-2); margin-top: 3px; font-size: 14px; }
.order-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Scanner ─────────────────────────────────────────────────────────────────── */
.scanner-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.scanner-header {
  background: var(--accent);
  padding: 16px 22px;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}
.scanner-header svg { opacity: .85; }

.scanner-active-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  margin-left: auto;
}
.scanner-active-indicator span {
  width: 7px; height: 7px; border-radius: 50%;
  background: white;
  animation: pulse 1.2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

.scan-input {
  width: 100%;
  font-size: 20px !important;
  font-weight: 700 !important;
  letter-spacing: 4px;
  text-align: center;
  padding: 16px !important;
  border-radius: var(--radius) !important;
  border: 2px solid var(--border) !important;
  background: var(--surface-2) !important;
  transition: border-color .15s, box-shadow .15s !important;
}
.scan-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(226,0,26,.10) !important;
  background: var(--surface) !important;
  outline: none !important;
}
.scan-input::placeholder { letter-spacing: 1px; font-weight: 400; color: var(--text-3); font-size: 14px; }
.scan-input[readonly] { opacity: 0.55; cursor: not-allowed; }

.scan-feedback {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  margin-top: 14px;
}
.scan-feedback-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.scan-feedback-error   { background: var(--accent-light);  color: var(--accent);  border-left: 3px solid var(--accent); }
.scan-feedback-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid var(--warning); }

/* ── Timer ───────────────────────────────────────────────────────────────────── */
.timer-card {
  background: var(--text);
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.timer-label { color: rgba(255,255,255,.5); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.timer-display {
  font-size: 40px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px; line-height: 1;
  margin-bottom: 16px;
}

/* ── Calendar ────────────────────────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-head {
  background: var(--surface-2);
  text-align: center;
  padding: 8px 4px;
  font-size: 11px; font-weight: 700;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px;
}
.cal-day {
  background: var(--surface);
  min-height: 86px;
  padding: 6px;
}
.cal-day.other-month { background: #fafbfc; }
.cal-day.today { background: #fff9f9; }
.cal-day-num {
  font-size: 12px; font-weight: 700;
  color: var(--text-2); margin-bottom: 4px;
}
.cal-day.today .cal-day-num {
  background: var(--accent); color: white;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cal-event {
  font-size: 11px; padding: 2px 6px;
  border-radius: 3px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; font-weight: 600;
}
.cal-event.ny        { background: var(--info-light);    color: var(--info); }
.cal-event.planerad  { background: var(--purple-light);  color: var(--purple); }
.cal-event.pagaende  { background: var(--warning-light); color: var(--warning); }
.cal-event.klar      { background: var(--success-light); color: var(--success); }

/* ── Misc ────────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state svg { width: 36px; height: 36px; margin: 0 auto 12px; opacity: 0.25; display: block; }
.empty-state p { font-size: 14px; font-weight: 500; }

.loading { text-align: center; padding: 48px; color: var(--text-3); font-size: 14px; font-weight: 500; }

.text-muted   { color: var(--text-2); }
.text-small   { font-size: 12px; }
.text-right   { text-align: right; }
.text-danger  { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-mono    { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12.5px; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-2        { margin-top: 8px; }
.mt-3        { margin-top: 12px; }
.mt-4        { margin-top: 16px; }
.mb-3        { margin-bottom: 12px; }
.mb-4        { margin-bottom: 16px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.stock-low    { color: var(--accent); font-weight: 700; }
.quantity-cell{ font-weight: 700; font-variant-numeric: tabular-nums; }
.price-cell   { text-align: right; font-variant-numeric: tabular-nums; }
.total-row td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); }
.card-accent  { border-top: 3px solid var(--accent); }

/* ── Toggle group ────────────────────────────────────────────────────────────── */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.toggle-btn {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Exo 2', sans-serif;
  border: none;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .1s, color .1s;
  border-right: 1px solid var(--border);
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn:hover { background: var(--bg); color: var(--text); }
.toggle-btn.active { background: var(--accent); color: white; }

/* ── Setting row ─────────────────────────────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* ── Timeline ────────────────────────────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline-item {
  display: flex;
  gap: 14px;
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  position: relative;
  z-index: 1;
}
.timeline-dot-samtal    { background: var(--info-light);    color: var(--info); }
.timeline-dot-händelse  { background: var(--warning-light); color: var(--warning); }
.timeline-dot-anteckning{ background: var(--surface-2);     color: var(--text-3); border: 1px solid var(--border); }
.timeline-line {
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--border-light);
}
.timeline-item:last-child .timeline-line { display: none; }
.timeline-content {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 2px;
}
.timeline-meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ── Task list ───────────────────────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s, border-color .1s;
}
.task-check.done { background: var(--success); border-color: var(--success); }
.task-check.done::after { content: '✓'; color: white; font-size: 11px; font-weight: 700; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 600; }
.task-title.done { text-decoration: line-through; color: var(--text-3); }
.task-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── Gantt chart ─────────────────────────────────────────────────────────────── */
.gantt-wrap { overflow-x: auto; }
.gantt-row {
  display: grid;
  gap: 0;
  align-items: center;
}
.gantt-label {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px 8px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid var(--border);
}
.gantt-bar-wrap {
  position: relative;
  height: 28px;
  padding: 0 8px;
}
.gantt-bar {
  position: absolute;
  height: 20px;
  top: 4px;
  border-radius: 4px;
  min-width: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-today {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: .6;
  z-index: 2;
}
.gantt-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.gantt-month-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 0;
  text-align: center;
  border-right: 1px dashed var(--border-light);
}

/* ── Photo grid ──────────────────────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  background: var(--surface-2);
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s;
}
.photo-thumb:hover img { transform: scale(1.05); }
.photo-delete {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: none;
  align-items: center; justify-content: center;
}
.photo-thumb:hover .photo-delete { display: flex; }

/* ── File upload area ────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.upload-area svg { width: 28px; height: 28px; margin: 0 auto 8px; display: block; opacity: .5; }
.upload-area p { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.upload-area small { font-size: 12px; }

/* ── Fullscreen image viewer ─────────────────────────────────────────────────── */
#img-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 3000;
  display: flex; align-items: center; justify-content: center;
}
#img-viewer img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
#img-viewer-close {
  position: absolute; top: 20px; right: 24px;
  background: none; border: none; color: white; font-size: 28px; cursor: pointer;
}

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

/* ── Photo name caption ──────────────────────────────────────────────────────── */
.photo-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: white;
  font-size: 11px;
  padding: 12px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0 0 var(--radius) var(--radius);
  opacity: 0;
  transition: opacity .2s;
}
.photo-thumb:hover .photo-name { opacity: 1; }

/* ── Task item padding inside card ──────────────────────────────────────────── */
.card-body .task-item { padding: 12px 16px; }
