:root {
  --blue-dark: #003366;
  --blue-mid: #0055a5;
  --blue-light: #e8f0fa;
  --green: #1a7a4a;
  --green-light: #e6f4ed;
  --orange: #c87000;
  --orange-light: #fff3e0;
  --red: #b00020;
  --red-light: #fdecea;
  --grey: #f4f5f7;
  --border: #d0d7e0;
  --text: #1a1a2e;
  --text-muted: #5a6880;
  --white: #ffffff;
}

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

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

/* HEADER */
.topbar {
  background: var(--blue-dark);
  color: white;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.topbar .logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: white;
  text-decoration: none;
}
.topbar .logo span { color: #7db8f7; }
.topbar nav { margin-left: auto; display: flex; gap: 4px; }
.topbar nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.15s;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,0.15); color: white; }

/* MAIN LAYOUT */
.page { max-width: 1300px; margin: 0 auto; padding: 24px; }

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--blue-dark); }

/* CONTROLS BAR */
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
}
.controls label { font-weight: 600; font-size: 13px; color: var(--text-muted); }

select, input[type="date"], input[type="time"], input[type="text"], input[type="tel"], textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(0,85,165,0.12);
}
textarea { resize: vertical; min-height: 70px; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: filter 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.92); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue-mid); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-danger  { background: var(--red); color: white; }
.btn-outline { background: white; color: var(--blue-mid); border: 1.5px solid var(--blue-mid); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* STATUS BADGES */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-booket   { background: #e3ecfa; color: #1a4a8a; }
.badge-ankommet { background: var(--orange-light); color: var(--orange); }
.badge-startet  { background: #fff0b3; color: #7a5c00; }
.badge-afsluttet{ background: var(--green-light); color: var(--green); }

/* PRIORITET BADGES */
.prio-akut    { background: var(--red-light); color: var(--red); }
.prio-indlagt { background: #ede7f6; color: #5e35b1; }
.prio-ambulant{ background: var(--grey); color: var(--text-muted); }

/* SCHEDULE TABLE */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.schedule-table thead tr {
  background: var(--blue-dark);
  color: white;
}
.schedule-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.schedule-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.schedule-table tbody tr:last-child td { border-bottom: none; }
.schedule-table tbody tr { transition: background 0.1s; }
.schedule-table tbody tr:hover { background: var(--blue-light); }

.time-cell {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-mid);
  white-space: nowrap;
  min-width: 70px;
}
.patient-name { font-weight: 700; font-size: 15px; }
.patient-cpr  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.cave-flag {
  display: inline-block;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  letter-spacing: 0.5px;
}

/* STATUS FLOW BUTTONS */
.status-flow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.status-flow .btn { font-size: 12px; padding: 5px 12px; }

/* CARDS */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--blue-mid);
  border-bottom: 2px solid var(--blue-light);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.field-group input, .field-group select, .field-group textarea { width: 100%; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* PATIENT INFO HEADER (on referral page) */
.patient-banner {
  background: var(--blue-dark);
  color: white;
  padding: 16px 24px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  gap: 32px;
  align-items: center;
  flex-wrap: wrap;
}
.patient-banner .pname { font-size: 22px; font-weight: 700; }
.patient-banner .pinfo { font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 2px; }
.patient-banner .status-area { margin-left: auto; text-align: right; }

.cave-box {
  background: var(--red-light);
  border: 2px solid var(--red);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.cave-box .cave-title {
  font-weight: 700;
  color: var(--red);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.cave-box .cave-content { color: var(--red); font-weight: 600; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; color: var(--blue-dark); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

/* TABS */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--blue-mid); border-bottom-color: var(--blue-mid); }

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--blue-dark);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 2000;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.toast.info { background: #2563eb; }

/* ADMIN SIDEBAR LAYOUT */
.admin-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }

.sidebar {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 72px;
}
.sidebar-header {
  background: var(--blue-dark);
  color: white;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.patient-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.patient-list-item:hover { background: var(--blue-light); }
.patient-list-item.selected { background: var(--blue-light); border-left: 3px solid var(--blue-mid); }
.patient-list-item .pli-name { font-weight: 600; }
.patient-list-item .pli-cpr  { font-size: 12px; color: var(--text-muted); }

.search-box { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-box input { width: 100%; font-size: 13px; }

.tag-badge {
  display: inline-block;
  background: #e8f0fe;
  color: #1a56db;
  border: 1px solid #c3d4f9;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

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

/* TOOLTIP */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #6b7280;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}
.tip-popup {
  display: none;
  position: fixed;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
}
