*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal: #1e6f6f;
  --teal-dark: #164f4f;
  --teal-light: #e8f4f4;
  --bg: #f2f2ed;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --status-done-bg: #e8f5e9;
  --status-done: #2e7d32;
  --status-planned-bg: #fff8e1;
  --status-planned: #f57c00;
  --status-active-bg: #e3f2fd;
  --status-active: #1565c0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* ── HEADER ── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  width: 36px;
  height: 36px;
  background: var(--teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-logo svg { color: #fff; }
.header-title h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.header-title p { font-size: 12px; color: var(--muted); }
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-email { font-size: 13px; color: var(--muted); }
.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 4px;
}
.btn-logout:hover { color: var(--text); }

/* ── LOGIN PAGE ── */
#page-login {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  box-sizing: border-box;
}
.login-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.08);
  margin: auto;
}

/* Desktop specific adjustments for login */
@media (min-width: 768px) {
  #page-login {
    padding: 40px;
  }
  .login-box {
    padding: 48px 40px;
    max-width: 420px;
  }
}

@media (min-width: 1024px) {
  .login-box {
    max-width: 450px;
    padding: 56px 48px;
  }
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand .logo {
  width: 56px;
  height: 56px;
  background: var(--teal);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.login-brand h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-brand p { font-size: 14px; color: var(--muted); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--teal); background: #fff; }
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  color: #c0392b;
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 18px;
}

/* ── CASES LIST PAGE ── */
#page-list { display: none; }
.list-header {
  padding: 24px 20px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.list-header h2 { font-size: 26px; font-weight: 700; }
.list-count { font-size: 13px; color: var(--muted); margin-top: 2px; }
.search-bar {
  padding: 0 20px 16px;
}
.search-wrap {
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search-wrap input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--card);
  outline: none;
}
.search-wrap input:focus { border-color: var(--teal); }
.cases-list {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.case-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.case-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.case-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.case-num { font-size: 13px; color: var(--muted); font-weight: 500; }
.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.status-Nytt { background: #e8eaf6; color: #283593; }
.status-Planerat { background: var(--status-planned-bg); color: var(--status-planned); }
.status-Planeratåterbesök { background: var(--status-planned-bg); color: var(--status-planned); }
.status-Utförd { background: var(--status-done-bg); color: var(--status-done); }
.status-Kräveråterbesök { background: #fce4ec; color: #c62828; }
.status-Fakturerad\/avslutad { background: #ede7f6; color: #4527a0; }
.status-Avbokad { background: #f5f5f5; color: #757575; }
.case-date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.case-name { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.case-product { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.case-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.case-info {
  display: flex;
  align-items: center;
  gap: 16px;
}
.case-info-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.technician-badge {
  font-size: 12px;
  background: var(--teal-light);
  color: var(--teal-dark);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ── FAB new case ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 20;
}
.fab:hover { background: var(--teal-dark); }

/* ── DETAIL / EDIT PAGE ── */
#page-detail { display: none; }
.detail-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--teal);
  font-weight: 500;
  padding: 0;
}
.detail-content { padding: 0 20px 100px; }
.detail-title-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.detail-title-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.detail-case-num { font-size: 14px; color: var(--muted); }
.detail-name { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.detail-product { font-size: 14px; color: var(--muted); }
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-icon { color: var(--teal); flex-shrink: 0; margin-top: 1px; }
.detail-row-content { flex: 1; }
.detail-row-label { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* Edit mode inputs */
.edit-input, .edit-select, .edit-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s;
}
.edit-input:focus, .edit-select:focus, .edit-textarea:focus {
  border-color: var(--teal);
  background: #fff;
}
.edit-textarea { resize: vertical; min-height: 80px; }

/* View mode value */
.detail-value { font-size: 15px; color: var(--teal); }
.detail-value.plain { color: var(--text); }
.detail-link {
  display: inline-block;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.detail-link:hover { text-decoration: underline; }

.detail-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  z-index: 10;
}
.btn-edit {
  flex: 1;
  padding: 13px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-edit:hover { background: var(--teal-dark); }
.btn-cancel {
  padding: 13px 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
}
.btn-cancel:hover { background: var(--bg); }

.btn-delete {
  padding: 13px 20px;
  background: none;
  border: 1px solid #e53935;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  color: #e53935;
}
.btn-delete:hover { background: #fdecea; }

/* Loading / empty states */
.loading { text-align: center; padding: 40px 20px; color: var(--muted); }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* New case modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.btn-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

/* Form sections */
.form-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 20px;
}
.form-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.form-row .form-group.half {
  flex: 1;
}

/* Checkbox groups */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  appearance: none;
  background: #fafafa;
  position: relative;
  flex-shrink: 0;
}
.checkbox-item input[type="checkbox"]:checked {
  background: var(--teal);
  border-color: var(--teal);
}
.checkbox-item input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  font-weight: bold;
}
.checkbox-item label {
  flex: 1;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
}

.modal-form .form-group label { font-size: 13px; }
.modal-form .form-group input,
.modal-form .form-group select,
.modal-form .form-group textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  outline: none;
}
.modal-form .form-group textarea { resize: vertical; min-height: 70px; }
.modal-form .form-group input:focus,
.modal-form .form-group select:focus,
.modal-form .form-group textarea:focus { border-color: var(--teal); background: #fff; }

@media (max-width: 480px) {
  .header-email { display: none; }
  .form-row { flex-direction: column; gap: 0; }
}

/* ── VISIT CARDS ── */
.visit-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.15s;
  margin-bottom: 8px;
}
.visit-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.visit-card:last-of-type { margin-bottom: 0; }
.visit-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.visit-card-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.visit-card-preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

/* ── NEW VISIT BUTTON ── */
.btn-new-visit {
  width: 100%;
  padding: 10px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px dashed var(--teal);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 12px;
}
.btn-new-visit:hover { background: var(--teal); color: #fff; }

/* ── VISIT MODAL (fullscreen, scrollable) ── */
#modal-visit {
  align-items: flex-start;
  overflow-y: auto;
}
#modal-visit .modal {
  border-radius: var(--radius);
  max-height: none;
  margin: 20px auto;
  width: calc(100% - 40px);
  max-width: 700px;
}

/* ══════════════════════════════════════════ */
/* ── HEADER NAV TABS ───────────────────── */
/* ══════════════════════════════════════════ */
.header-nav {
  display: flex;
  gap: 4px;
}
.nav-tab {
  padding: 6px 18px;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-tab-icon { flex-shrink: 0; }
.nav-tab:hover { background: var(--bg); color: var(--text); }
.nav-tab.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 600;
}

/* ══════════════════════════════════════════ */
/* ── ÖVERSIKT ───────────────────────────── */
/* ══════════════════════════════════════════ */
#oversikt-view {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 40px;
}
.oversikt-tech-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  align-self: center;
}
.oversikt-list {
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.oversikt-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}
.oversikt-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.oversikt-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.09);
  transform: translateY(-1px);
}
.oversikt-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 14px;
  background: var(--teal-light);
  min-width: 90px;
  flex-shrink: 0;
  text-align: center;
}
.oversikt-order {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.oversikt-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.oversikt-tech-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal-dark);
  background: rgba(30,111,111,0.12);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oversikt-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.oversikt-body {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}
.oversikt-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.oversikt-brand {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.oversikt-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.oversikt-details {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}
.oversikt-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.oversikt-phone {
  color: var(--teal);
  font-weight: 500;
}
.oversikt-phone:hover { text-decoration: underline; }
@media (max-width: 600px) {
  .oversikt-left { min-width: 72px; padding: 12px 10px; }
  .oversikt-body { padding: 12px; }
  .oversikt-name { font-size: 15px; }
}


/* ══════════════════════════════════════════ */
/* ── PLANNING PAGE ─────────────────────── */
/* ══════════════════════════════════════════ */
#plan-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.plan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.plan-heading {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.plan-counter {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.plan-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-week-nav {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s;
}
.btn-week-nav:hover { background: var(--bg); }
.btn-week-today {
  padding: 6px 14px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid var(--teal);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.btn-week-today:hover { background: var(--teal); color: #fff; }
.plan-week-range {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 190px;
  text-align: center;
}

/* ── Plan body: sidebar + calendar ── */
.plan-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.plan-sidebar {
  width: 296px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.plan-sidebar-header {
  padding: 14px 14px 0;
}
.plan-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}
.plan-sidebar-filters {
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}
.plan-filter-row {
  display: flex;
  gap: 6px;
}
.plan-filter-select {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg);
  outline: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.plan-filter-select:focus { border-color: var(--teal); }
.plan-sidebar-cases {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.plan-case-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: grab;
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
}
.plan-case-item:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); border-color: var(--teal); }
.plan-case-item:hover .plan-case-open { opacity: 1; }
.plan-case-item.is-dragging { opacity: 0.45; cursor: grabbing; }
.plan-case-open {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.plan-case-open:hover { background: var(--teal-light); color: var(--teal-dark); }
.plan-case-drag {
  font-size: 16px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1;
}
.plan-case-body { flex: 1; min-width: 0; }
.plan-case-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.plan-case-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-case-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-empty {
  text-align: center;
  padding: 40px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ── Calendar outer ── */
.plan-cal-outer {
  flex: 1;
  overflow: auto;
  background: var(--bg);
}
#plan-calendar {
  background: var(--card);
  min-height: 100%;
}

/* ── Calendar grid ── */
.cal-layout {
  display: flex;
  min-width: 740px;
}
.cal-time-gutter {
  width: 56px;
  flex-shrink: 0;
  background: var(--card);
  position: sticky;
  left: 0;
  z-index: 3;
}
.cal-corner {
  height: 52px;
  border-bottom: 2px solid var(--border);
}
.cal-time-label {
  height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4px 8px 0 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}

/* Days area */
.cal-days-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cal-day-headers {
  display: flex;
  height: 52px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.cal-day-header {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-left: 1px solid var(--border);
}
.cal-day-header.is-today { background: rgba(30,111,111,0.04); }
.cal-day-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-day-header.is-today .cal-day-name { color: var(--teal); }
.cal-day-num {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.cal-day-num.is-today {
  background: var(--teal);
  color: #fff;
}

.cal-days-body {
  display: flex;
  flex: 1;
}
.cal-day-col {
  flex: 1;
  position: relative;
  border-left: 1px solid var(--border);
  min-width: 96px;
}
.cal-day-col.is-today { background: rgba(30,111,111,0.025); }
.cal-hour-cell {
  height: 60px;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  transition: background 0.1s;
}
.cal-hour-cell.drag-over {
  background: var(--teal-light);
  outline: 2px dashed var(--teal);
  outline-offset: -2px;
}

/* ── Calendar event blocks ── */
.cal-event {
  position: absolute;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: box-shadow 0.15s, transform 0.1s;
  z-index: 1;
  box-sizing: border-box;
}
.cal-event:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.18);
  transform: translateY(-1px);
  z-index: 2;
}
.cal-event.is-dragging {
  opacity: 0.4;
}
/* Drop indicator line */
.cal-drop-indicator {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 3px;
  background: var(--teal);
  border-radius: 2px;
  z-index: 10;
  pointer-events: none;
}
.cal-drop-indicator::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}
.cal-event.is-resizing {
  opacity: 0.85;
  cursor: ns-resize;
}
.cal-event-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  border-radius: 0 0 6px 6px;
  background: rgba(0,0,0,0.15);
  opacity: 0;
  transition: opacity 0.15s;
}
.cal-event:hover .cal-event-resize-handle {
  opacity: 1;
}
.plan-sidebar-cases.drag-over-sidebar {
  background: #e8f5f5;
  outline: 2px dashed var(--teal);
  outline-offset: -4px;
  border-radius: 8px;
}
.cal-event-time {
  font-size: 10px;
  opacity: 0.75;
  margin-bottom: 1px;
  font-weight: 500;
}
.cal-event-name {
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.cal-event-sub {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Event color variants */
.evt-new      { background: #e8eaf6; color: #283593;        border-left: 3px solid #3949ab; }
.evt-planned  { background: var(--status-planned-bg);  color: var(--status-planned);  border-left: 3px solid var(--status-planned); }
.evt-done     { background: var(--status-done-bg);     color: var(--status-done);     border-left: 3px solid var(--status-done); }
.evt-revisit  { background: #fce4ec; color: #c62828;   border-left: 3px solid #c62828; }
.evt-invoiced { background: #ede7f6; color: #4527a0;   border-left: 3px solid #4527a0; }
.evt-default  { background: var(--teal-light); color: var(--teal-dark); border-left: 3px solid var(--teal); }
.evt-cancelled { background: #f5f5f5; color: #757575;  border-left: 3px solid #bdbdbd; }

@media (max-width: 768px) {
  /* Nav: only icons on mobile */
  .nav-tab { padding: 6px 10px; }
  .nav-tab-label { display: none; }

  /* Hide Planering tab entirely on mobile */
  #nav-planering { display: none; }

  /* Planning toolbar: stack */
  .plan-toolbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .plan-heading { font-size: 16px; }
  .plan-week-range { min-width: 0; font-size: 12px; }

  /* Planning body: sidebar on top, calendar below */
  .plan-body {
    flex-direction: column;
    overflow-y: auto;
  }
  .plan-sidebar {
    width: 100%;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .plan-sidebar-cases {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 8px 12px;
  }
  .plan-case-item {
    min-width: 160px;
    flex-shrink: 0;
  }
  .plan-sidebar-filters {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 4px;
  }

  /* Calendar: horizontal scroll */
  #plan-calendar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal-layout {
    min-width: 700px;
  }
}