@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ─── Tokens ─────────────────────────────────────────────── */
/*
  IMPORTANT: Token NAMES are unchanged — safe to drop in.
  Values have been updated for a softer, warmer visual language.
  All var() references in JS view files continue to resolve correctly.
*/
:root {
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Teal scale — unchanged hues, slightly warmer midtones */
  --teal-50:  #e6f4ef;
  --teal-100: #b3dfd0;
  --teal-400: #1d9e75;
  --teal-600: #0f6e56;
  --teal-800: #085041;
  --teal-900: #04342c;

  /* Neutral scale — slightly warm undertone */
  --gray-50:  #f7f6f3;
  --gray-100: #edece8;
  --gray-200: #d5d4cf;
  --gray-400: #8e8e89;
  --gray-600: #5c5c58;
  --gray-800: #2e2e2b;
  --gray-900: #1a1a17;

  /* Coral scale */
  --coral-50:  #faede9;
  --coral-400: #d85a30;
  --coral-600: #993c1d;

  /* Surfaces — warm off-white instead of pure white */
  --bg:         #ffffff;
  --bg-surface: oklch(97.5% 0.009 158);
  --bg-raised:  #ffffff;

  /* Borders — softer */
  --border:    rgba(0, 0, 0, 0.07);
  --border-md: rgba(0, 0, 0, 0.12);

  /* Text */
  --text:       #1a1a17;
  --text-muted: #5c5c58;
  --text-hint:  #9e9e99;

  /* Accent */
  --accent:       var(--teal-400);
  --accent-hover: var(--teal-600);
  --danger:       var(--coral-400);

  /* Radius — softened throughout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadows — lighter, more organic */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);

  /* Layout */
  --sidebar-w: 60px;
  --topbar-h:  54px;

  --transition: 150ms ease;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 99px; }

/* ─── App shell ──────────────────────────────────────────── */
#app { height: 100vh; display: flex; overflow: hidden; }

/* ─── Screens ────────────────────────────────────────────── */
.screen { display: none; width: 100%; }
.screen.active { display: flex; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
}
.sidebar-logo {
  width: 36px;
  height: auto;
  margin-bottom: 12px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.10));
}
.sb-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sb-btn:hover  { background: var(--gray-100); color: var(--text); }
.sb-btn.active { background: var(--teal-50);  color: var(--teal-600); }
.sb-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sb-spacer { flex: 1; }
.sb-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-100), var(--teal-50));
  border: 1.5px solid var(--teal-100);
  color: var(--teal-800);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg-raised);
}
.sb-tooltip {
  position: absolute;
  left: calc(var(--sidebar-w) + 8px);
  background: var(--gray-800);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 100;
}
.sb-btn:hover .sb-tooltip { opacity: 1; transform: translateX(0); }

/* ─── Main area ──────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--bg-raised);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 12px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}
.topbar-brand img { height: 26px; object-fit: contain; flex-shrink: 0; }
.topbar-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-600);
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 99px;
  background: var(--teal-50);
  color: var(--teal-800);
  border: 0.5px solid var(--teal-100);
  white-space: nowrap;
}
.topbar-user { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.btn-ghost {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-md);
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition);
}
.btn-ghost:hover { background: var(--gray-100); }

/* ─── Content area ───────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background var(--transition), transform 80ms;
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-md);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--gray-100); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius-md);
  border: 1px solid var(--coral-50);
  background: var(--coral-50);
  color: var(--coral-600);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition);
}
.btn-danger:hover { background: #f5c4b3; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
}
.card-sm { padding: 13px 16px; }

/* ─── Section label ──────────────────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-hint);
  margin-bottom: 11px;
}

/* ─── Form elements ──────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  background: var(--bg-raised);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.field input[type="date"] { color-scheme: light; }
.field input[type="radio"] { width: auto; accent-color: var(--accent); }
.input-error { border-color: var(--danger) !important; }
.field-error  { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ─── Badges & tags ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: .03em;
}
.badge-teal  { background: var(--teal-50);  color: var(--teal-800);  border: 0.5px solid var(--teal-100); }
.badge-gray  { background: var(--gray-100); color: var(--gray-600);  border: 0.5px solid var(--gray-200); }
.badge-coral { background: var(--coral-50); color: var(--coral-600); border: 0.5px solid #f5c4b3; }
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ─── Divider ────────────────────────────────────────────── */
.divider { height: 0.5px; background: var(--border); margin: 18px 0; }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-hint);
  text-align: center;
  gap: 8px;
}
.empty-state svg { width: 36px; height: 36px; opacity: 0.35; }
.empty-state p   { font-size: 13px; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-raised);
  border-radius: var(--radius-xl);
  border: 0.5px solid var(--border-md);
  padding: 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.modal-title  { font-size: 17px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.01em; }
.modal-body   { font-size: 13px; color: var(--text-muted); line-height: 1.65; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--gray-800);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: toastIn 200ms ease forwards;
}
.toast.success { background: var(--teal-600); }
.toast.error   { background: var(--coral-600); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ─── Notification dot ───────────────────────────────────── */
.notif-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-active   { background: var(--teal-400); }
.dot-inactive { background: var(--gray-200); }

/* ─── Programme card ─────────────────────────────────────── */
.program-card {
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform 120ms;
}
.program-card:hover {
  border-color: var(--teal-100);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.program-card-hero {
  height: 88px;
  background: var(--teal-50);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.program-card-body  { padding: 13px 15px; }
.program-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; line-height: 1.35; }
.program-card-sub   { font-size: 11px; color: var(--text-muted); }

/* ─── Goal item ──────────────────────────────────────────── */
.goal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  border: 1px solid var(--border);
  cursor: default;
}
.goal-item[draggable="true"] { cursor: grab; }
.goal-item[draggable="true"]:active { cursor: grabbing; }

/* ─── Upload dropzone ────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius-md);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-surface);
  transition: border-color var(--transition), background var(--transition);
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal-400);
  background: var(--teal-50);
}

/* ─── Colour / icon swatches (programme form) ────────────── */
.colour-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform 100ms;
  outline: none;
}
.colour-swatch:hover    { transform: scale(1.1); }
.colour-swatch.selected { border-color: var(--teal-600); transform: scale(1.1); }

.icon-swatch {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-md);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
.icon-swatch:hover    { background: var(--gray-100); }
.icon-swatch.selected { border-color: var(--teal-600); background: var(--teal-50); }
.icon-swatch svg      { width: 18px; height: 18px; stroke: var(--text-muted); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-swatch.selected svg { stroke: var(--teal-600); }

/* ─── Edit / split panel ─────────────────────────────────── */
.edit-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(1px);
}
.edit-panel-overlay.open { display: flex; align-items: stretch; justify-content: flex-end; }
.edit-panel {
  width: 420px;
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.12);
  animation: panelIn 200ms ease;
}
@keyframes panelIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.edit-panel-head {
  background: linear-gradient(135deg, var(--teal-800), var(--teal-600));
  padding: 18px 22px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.edit-panel-head-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.edit-panel-close {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff;
  transition: background var(--transition);
}
.edit-panel-close:hover { background: rgba(255,255,255,0.25); }
.edit-panel-close svg   { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.edit-panel-body { flex: 1; overflow-y: auto; padding: 22px; }

/* ─── Utilities ──────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-4        { gap: 4px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.gap-20       { gap: 20px; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.text-muted   { color: var(--text-muted); }
.text-hint    { color: var(--text-hint); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.font-500     { font-weight: 500; }
.font-600     { font-weight: 600; }
.grid-2       { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3       { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-auto    { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.w-full       { width: 100%; }
