@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700;800&display=swap');

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

:root {
  --teal: #165C66;
  --teal-alt: #136B6B;
  --bg: #FCFAF5;
  --surface: #FFFFFF;
  --text: #1E1E1E;
  --gold: #CBB469;
  --muted: #6B7280;
  --border: #E5E0D8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07);
  --font: 'Montserrat', Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.clinic-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--teal);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.top-bar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.top-bar-nav {
  display: flex;
  gap: 4px;
}

.top-bar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}

.top-bar-nav a:hover { background: var(--bg); color: var(--text); }
.top-bar-nav a.active { background: var(--bg); color: var(--teal); font-weight: 700; }

.top-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.save-indicator {
  font-size: 12px;
  color: var(--muted);
  min-width: 120px;
  text-align: right;
}

.save-indicator.saving { color: var(--gold); }
.save-indicator.saved  { color: #22863a; }

.main {
  padding: 24px 28px;
  max-width: 1600px;
}

/* ── Controls bar ───────────────────────────────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.controls h2 {
  font-size: 20px;
  font-weight: 800;
  margin-right: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-primary:hover { background: var(--teal-alt); }

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

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

.btn-sm { padding: 4px 10px; font-size: 12px; }

.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.toggle-group .btn {
  border-radius: 0;
  border: none;
  color: var(--muted);
}
.toggle-group .btn.active {
  background: var(--teal);
  color: #fff;
}
.toggle-group .btn:not(.active):hover { background: var(--bg); color: var(--text); }

.filter-select {
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--teal); }

/* ── Legend ─────────────────────────────────────────────────────────────── */

.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--gold);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
}

.legend-item .badge { flex-shrink: 0; margin-top: 1px; }

.legend-item strong { font-weight: 700; }
.legend-item span { color: var(--muted); }

/* ── Category badges ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-Leaf   { background: #E8F5E9; color: #2E7D32; }
.badge-Branch { background: #E3F2FD; color: #1565C0; }
.badge-Trunk  { background: #FFF3E0; color: #E65100; }
.badge-Root   { background: #FCE4EC; color: #880E4F; }

/* ── Today view: column grid ────────────────────────────────────────────── */

.grid-container {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 12px;
}

.staff-column {
  flex: 0 0 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.staff-column-header {
  padding: 14px 16px 12px;
  border-bottom: 2px solid var(--teal);
}

.staff-column-header h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--teal);
}

.staff-column-header .role-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.staff-column-body {
  padding: 8px 0;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid transparent;
}

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

.task-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--teal);
  cursor: pointer;
}

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

.task-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}

.task-row.completed .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.freq-label {
  font-size: 11px;
  color: var(--muted);
}

.column-empty {
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Weekly grid view ───────────────────────────────────────────────────── */

.weekly-grid {
  overflow-x: auto;
}

.weekly-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.weekly-table th,
.weekly-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.weekly-table thead th {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.weekly-table thead th:first-child { text-align: left; border-radius: var(--radius) 0 0 0; min-width: 280px; }
.weekly-table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

.weekly-table .section-header td {
  background: var(--bg);
  font-weight: 800;
  color: var(--teal);
  font-size: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.weekly-table td.task-cell { font-size: 13px; font-weight: 500; cursor: pointer; }
.weekly-table td.task-cell:hover { color: var(--teal); }
.weekly-table td.check-cell { text-align: center; }
.weekly-table td.check-cell input[type="checkbox"] { accent-color: var(--teal); cursor: pointer; }
.weekly-table tr:last-child td { border-bottom: none; }
.weekly-table tr.completed-row .task-cell { color: var(--muted); text-decoration: line-through; }

/* ── Summary bar ────────────────────────────────────────────────────────── */

.summary-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.summary-bar h3 {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}

.summary-name { font-size: 11px; color: var(--muted); font-weight: 600; }
.summary-pct  { font-size: 18px; font-weight: 800; color: var(--teal); }

.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width .3s;
}

/* ── Task detail panel ──────────────────────────────────────────────────── */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 440px;
  max-width: 95vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .2s ease;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.drawer-header-text { flex: 1; min-width: 0; }

.drawer-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 6px;
}

.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.drawer-close:hover { background: var(--bg); color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field-value { font-size: 13px; font-weight: 500; }

.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

textarea.notes-field,
input.link-field {
  font-family: var(--font);
  font-size: 13px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 80px;
  transition: border-color .15s;
}
input.link-field { min-height: unset; resize: none; }
textarea.notes-field:focus,
input.link-field:focus {
  outline: none;
  border-color: var(--teal);
}

.drawer-divider {
  height: 1px;
  background: var(--border);
}

/* ── Comments ───────────────────────────────────────────────────────────── */

.comments-section { display: flex; flex-direction: column; gap: 12px; }
.comments-section h4 { font-size: 13px; font-weight: 700; }

.comment-list { display: flex; flex-direction: column; gap: 10px; }

.comment {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author { font-size: 12px; font-weight: 700; color: var(--teal); }
.comment-time   { font-size: 11px; color: var(--muted); }
.comment-text   { font-size: 13px; }

.comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

textarea.comment-input {
  font-family: var(--font);
  font-size: 13px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 64px;
  transition: border-color .15s;
}
textarea.comment-input:focus { outline: none; border-color: var(--teal); }

/* ── Add task modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal h3 { font-size: 16px; font-weight: 800; }

.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

input.form-input,
select.form-select,
textarea.form-textarea {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color .15s;
}
textarea.form-textarea { resize: vertical; min-height: 64px; }
input.form-input:focus,
select.form-select:focus,
textarea.form-textarea:focus { outline: none; border-color: var(--teal); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ── Roster screen ──────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 800; }
.page-header p  { color: var(--muted); font-size: 13px; margin-top: 4px; }

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

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

table.roster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.roster-table th,
.roster-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.roster-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
}
.roster-table tr:last-child td { border-bottom: none; }
.roster-table tr:hover td { background: var(--bg); }
.roster-table .inactive-row td { opacity: 0.5; }

.badge-active   { background: #E8F5E9; color: #2E7D32; }
.badge-inactive { background: #F5F5F5; color: #9E9E9E; }

.inline-edit input,
.inline-edit select {
  font-family: var(--font);
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  width: 100%;
}
.inline-edit input:focus,
.inline-edit select:focus { outline: none; border-color: var(--teal); }

/* ── Loading state ──────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--muted);
  font-size: 13px;
  gap: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .top-bar { padding: 0 16px; }
  .main    { padding: 16px; }
  .clinic-name { font-size: 15px; }
  .drawer { width: 100%; }
}
