/* ============================================
   TheraPlan — Modern Design System
   ============================================ */

:root {
  --bg: #f7f8fc;
  --bg-sidebar: #1a1d2e;
  --bg-sidebar-hover: #252840;
  --bg-sidebar-active: #2d3152;
  --sidebar-text: #a0a4b8;
  --sidebar-text-active: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f4f5f9;
  --ink: #1e2139;
  --ink-secondary: #6b7086;
  --ink-muted: #9498ae;
  --line: #e8eaf0;
  --line-hover: #d0d3de;
  --accent: #4f86db;
  --accent-hover: #3f75cb;
  --accent-light: #eaf2ff;
  --accent-text: #ffffff;
  --danger: #d64550;
  --danger-hover: #c03a44;
  --success: #2ea66a;
  --warning: #e6a817;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --transition: 0.18s ease;
  --sidebar-width: 230px;
  --topbar-height: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --session-type-badge-width: 8ch;
}

html:lang(en) {
  --session-type-badge-width: 11ch;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.booting #login-view,
body.booting #register-view,
body.booting #app-view {
  display: none !important;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

p { margin: 0; }
a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; }
img { max-width: 100%; }

/* Form Elements */
input, select, textarea {
  font: inherit;
  font-family: var(--font);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  background: var(--bg-card);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 134, 219, 0.15);
}
textarea { resize: vertical; min-height: 70px; }
select { cursor: pointer; }

/* Safari can render native dropdown entries with a serif fallback unless option
   fonts are explicitly declared. Keep all select-related controls consistent. */
select,
option,
optgroup {
  font-family: var(--font);
}

button { font: inherit; cursor: pointer; border: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Button Variants ---- */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition), transform 0.1s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-accent {
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background var(--transition);
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--line-hover); background: var(--bg-input); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background var(--transition);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }

.btn-icon {
  background: transparent;
  color: var(--ink-secondary);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 1.1rem;
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--bg-input); }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #edf4ff 0%, #e5f0ff 50%, #f3f8ff 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-brand { margin-bottom: 1.8rem; }
.brand-icon {
  width: 56px;
  height: 56px;
  position: relative;
  display: inline-block;
  margin-bottom: 0.8rem;
}
.brand-icon::before,
.brand-icon::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  box-sizing: border-box;
}
.brand-icon::before {
  width: 31px;
  height: 31px;
  left: 7px;
  top: 9px;
  border: 7px solid #7ea6e8;
}
.brand-icon::after {
  width: 31px;
  height: 31px;
  left: 18px;
  top: 18px;
  border: 7px solid #4f86db;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; font-weight: 500; color: var(--ink-secondary); }
.register-back-link { margin-top: 1.1rem; }
.login-hint { font-size: 0.82rem; color: var(--ink-muted); margin-top: 1rem; }
.auth-link-block { margin-top: 0.45rem; margin-bottom: 0; text-align: left; }
.auth-link-block-last { margin-top: 0.2rem; }
.auth-divider {
  width: 100%;
  border-top: 2px solid #d6e2f5;
  height: 0;
  margin: 0.9rem 0 0.75rem;
}
.error { color: var(--danger); font-size: 0.88rem; min-height: 1.2rem; }
.success-message { color: #1f7a45; font-size: 0.85rem; min-height: 1.2rem; text-align: left; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  padding: 1.2rem 1.2rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-icon-sm {
  width: 34px;
  height: 34px;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.brand-icon-sm::before,
.brand-icon-sm::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  box-sizing: border-box;
}
.brand-icon-sm::before {
  width: 18px;
  height: 18px;
  left: 3px;
  top: 6px;
  border: 4px solid #7ea6e8;
}
.brand-icon-sm::after {
  width: 18px;
  height: 18px;
  left: 11px;
  top: 11px;
  border: 4px solid #4f86db;
}
.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sidebar-text-active);
  letter-spacing: -0.2px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.7rem;
  overflow-y: auto;
}

.nav-mobile-account {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 0.9rem;
  background: transparent;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-text-active);
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--sidebar-text-active);
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.5rem 0.7rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.nav-item-sm { font-size: 0.85rem; padding: 0.45rem 0.75rem; }

/* ---- Main Area ---- */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.sidebar-toggle {
  display: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
  padding: 0.3rem;
  border-radius: var(--radius);
}
.sidebar-toggle:hover { background: var(--bg-input); }

.view-loading-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(79, 134, 219, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.inline-spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}

.inline-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(79, 134, 219, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.lang-select select {
  width: auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 6px;
  min-width: 55px;
}

.bell-btn {
  position: relative;
  background: transparent;
  color: var(--ink-secondary);
  padding: 0.4rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.bell-btn:hover { background: var(--bg-input); }
.notif-badge {
  position: absolute;
  top: 0;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.user-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* ---- Content ---- */
.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
}

.view { display: flex; flex-direction: column; gap: 1rem; }
.view > * { animation: fadeUp 0.2s ease; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 1.55rem;
}

.view-header-spacer {
  visibility: hidden;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
}

.view-header-select {
  visibility: visible;
  max-width: 360px;
}

.view-header-select select {
  font-family: var(--font);
  font-size: 0.88rem;
}

#progress-content {
  font-family: var(--font);
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
}

/* ---- Item List ---- */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.list-item:hover {
  border-color: var(--line-hover);
  box-shadow: var(--shadow-sm);
}

.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.list-item-main { flex: 1; min-width: 0; }
.list-item-main strong { font-size: 0.92rem; }
.list-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.admin-pending-invite-row {
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
}

.admin-pending-invite-row:first-child {
  border-top: none;
  padding-top: 0;
}

.admin-todo-item {
  cursor: grab;
}

.admin-todo-item:active {
  cursor: grabbing;
}

.admin-todo-item.is-dragging {
  opacity: 0.6;
  border-style: dashed;
}

.admin-todo-item.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 134, 219, 0.15);
}

.admin-todo-order {
  min-width: 2.2rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.admin-todo-drag-handle {
  font-size: 1rem;
  color: var(--ink-muted);
  user-select: none;
}

.admin-todo-edit-form {
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
}

.admin-todo-edit-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: span 2;
}

.participant-main {
  min-width: 0;
}

.participant-actions {
  align-items: center;
  flex-wrap: nowrap;
}

/* ---- Groups Grid ---- */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  cursor: pointer;
  transition: all var(--transition);
}
.group-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.group-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.group-card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.group-card-meta .badge {
  max-width: 100%;
  min-width: 0;
}

.badge-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-card-meta .badge-truncate {
  flex: 1 1 100%;
}

.group-card-target {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.group-status-updated {
  color: var(--danger) !important;
  font-weight: 700;
  animation: group-status-highlight 1.2s ease;
}

@keyframes group-status-highlight {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  35% {
    transform: scale(1.04);
    opacity: 0.95;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-default { background: var(--bg-input); color: var(--ink-secondary); }
.badge-planning, .badge-open, .badge-interested { background: #fef3cd; color: #856404; }
.badge-ongoing, .badge-active, .badge-assigned, .badge-planned { background: #d1ecf1; color: #0c5460; }
.badge-completed, .badge-paid { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-partial { background: #fff3cd; color: #856404; }
.badge-session-group { background: #d7f4e1; color: #116341; }
.badge-session-individual { background: #d9e9ff; color: #1c4e96; }
.badge-session-group,
.badge-session-individual {
  inline-size: var(--session-type-badge-width);
  justify-content: center;
}
.badge-account { background: var(--accent-light); color: var(--accent); }
.badge-no-account { background: var(--bg-input); color: var(--ink-muted); }
.badge-group { background: #e8eaf0; color: #3d4061; font-size: 0.7rem; }

/* Inline remove button inside badges */
.btn-badge-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.65rem;
  color: #3d4061;
  opacity: 0.6;
  line-height: 1;
}
.btn-badge-remove:hover { opacity: 1; }

.task-upload-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.task-upload-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
  background: #f8fbff;
  max-width: 100%;
}

.task-upload-name {
  font-size: 0.82rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 250px;
}

.task-upload-size {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.task-title-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.task-title-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Lighter "as per" annotation on conflicting phone numbers */
.phone-source {
  color: var(--ink-muted);
  font-size: 0.75em;
  font-weight: 400;
}

/* ---- Dashboard ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 1rem;
}
.dash-calendar { grid-column: 1; grid-row: 1 / 3; }
.dash-upcoming { grid-column: 2; grid-row: 1; }
.dash-urgent { grid-column: 2; grid-row: 2; }

.dash-sessions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.dash-sessions-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.cal-weekday {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.4rem 0;
}
.cal-day {
  padding: 0.45rem 0.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
}
.cal-day:hover { background: var(--bg-input); }
.cal-day.today {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}
.cal-day.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.cal-day.today.selected {
  background: var(--accent);
  color: #fff;
}
.cal-day.other-month { color: var(--ink-muted); opacity: 0.4; }
.cal-day.has-session::after {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  bottom: 4px;
}
.cal-day.today.has-session::after { background: var(--accent); }
.cal-day.selected.has-session::after { background: #fff; }
.cal-day.has-past-session::after {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--ink-muted);
  border-radius: 50%;
  opacity: 0.4;
  position: absolute;
  bottom: 4px;
}
.cal-day.selected.has-past-session::after { background: rgba(255,255,255,0.6); opacity: 1; }
.cal-day.empty { cursor: default; }

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-secondary);
}
.span-2 { grid-column: span 2; }

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}
.form-row input, .form-row select { width: auto; flex: 1; min-width: 100px; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.8rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 80px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-container {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.2s ease;
}
.modal-container.modal-lg { max-width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.modal-close-btn {
  font-size: 1.4rem;
  color: var(--ink-muted);
}
.modal-body {
  padding: 1.2rem 1.5rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  font-weight: 600;
  color: var(--ink-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table tbody tr:hover { background: var(--bg-input); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  background: var(--bg-sidebar);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  max-width: min(400px, calc(100vw - 2rem));
  box-shadow: var(--shadow-lg);
  z-index: 999;
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideUp 0.2s ease;
}
.toast.is-error { background: var(--danger); }

/* Inline loading for action buttons */
button.is-loading {
  position: relative;
  pointer-events: none;
}
button.is-loading > * {
  opacity: 0;
}
button.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}
button.btn-ghost.is-loading::after,
button.btn-icon.is-loading::after {
  border-color: rgba(30, 33, 57, 0.2);
  border-top-color: var(--ink-secondary);
}

/* ---- Utilities ---- */
.muted { color: var(--ink-muted); font-size: 0.88rem; }
.text-sm { font-size: 0.82rem; }
.text-secondary { color: var(--ink-secondary); }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gap-sm { gap: 0.4rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* Detail section inside modals */
.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 1rem;
}
.detail-section h4 {
  margin-bottom: 0.6rem;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.session-delete-section .btn-danger {
  margin-top: 0.35rem;
}
.session-delete-confirm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.session-delete-summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  background: var(--bg-input);
  box-shadow: var(--shadow-sm);
}
.session-delete-note-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-secondary);
}
.session-delete-note-label textarea {
  resize: vertical;
  min-height: 84px;
}
.session-delete-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* Session filter tabs */
.filter-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.filter-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 3px;
}
.filter-tab {
  padding: 0.35rem 0.9rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-secondary);
  background: transparent;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
}
.filter-tab:hover { color: var(--ink); }
.filter-tab.active {
  background: var(--bg-card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.smart-search {
  position: relative;
  display: flex;
  align-items: center;
}

.smart-search-icon {
  position: absolute;
  left: 0.72rem;
  top: 50%;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--ink-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.smart-search-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.smart-search-input {
  padding-left: 2.15rem;
  padding-right: 2.15rem;
}

.smart-search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-secondary);
  border: none;
  font-size: 1.05rem;
  line-height: 1;
  transform: translateY(-50%);
  transition: background var(--transition), color var(--transition);
}

.smart-search-clear:hover {
  background: var(--bg-input);
  color: var(--ink);
}

.smart-search-clear.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.session-filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 0.55rem;
  align-items: end;
}

.session-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.session-filter-field span {
  font-size: 0.76rem;
  color: var(--ink-secondary);
  font-weight: 500;
}

.progress-filter-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(180px, 280px) auto;
  gap: 0.55rem;
  align-items: end;
}

.progress-filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.progress-filter-label span {
  font-size: 0.76rem;
  color: var(--ink-secondary);
  font-weight: 500;
}

/* Session type toggle */
.session-type-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}
.session-type-btn {
  flex: 1;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: 2px solid var(--line);
  background: var(--bg-card);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.session-type-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.session-type-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.session-type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.task-assignment-pane {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-hint {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* Series preview list */
.series-preview {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem;
}
.series-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.series-preview-item:last-child { border-bottom: none; }

/* Multi-select checkboxes */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem;
}
.checkbox-list label {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding: 0.2rem 0;
  cursor: pointer;
}
.checkbox-list label input[type="checkbox"] { width: auto; flex-shrink: 0; }

/* Back button style */
.btn-back {
  background: transparent;
  color: var(--ink-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.btn-back:hover { border-color: var(--line-hover); background: var(--bg-input); }

/* Membership status select */
.membership-status-select {
  font-size: 0.72rem;
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
  width: auto;
  min-width: 90px;
}

/* ---- Animations ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-footer {
    display: none;
  }
  .nav-mobile-account {
    display: flex;
  }
  .main-area {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dash-calendar { grid-row: auto; }
  .dash-upcoming { grid-column: 1; grid-row: auto; }
  .dash-urgent { grid-column: 1; grid-row: auto; }
  .content { padding: 1rem; }
  .groups-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .modal-container { width: 95%; }
  .session-filters-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  .session-filters-grid .btn-sm {
    width: 100%;
  }
  .progress-filter-row {
    grid-template-columns: 1fr;
  }
  .progress-filter-row .btn-sm {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .topbar { padding: 0 0.8rem; }
  .user-name { display: none; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

@media (max-width: 720px) {
  .participant-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .participant-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .participant-actions .btn-sm {
    flex: 1 1 140px;
    text-align: center;
  }

  .participant-actions .btn-icon {
    margin-left: auto;
    flex: 0 0 auto;
  }
}

/* Star Rating */
.star-rating {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 0.15rem;
  font-size: 1.6rem;
  line-height: 1;
}
.star-rating input { display: none; }
.star-rating label {
  cursor: pointer;
  color: #ccc;
  transition: color 0.15s;
  display: inline-block !important;
  flex-direction: row !important;
}
.star-rating label::before { content: '★'; }
.star-rating input:checked ~ label { color: var(--accent); }
.star-rating label:hover,
.star-rating label:hover ~ label { color: var(--accent); opacity: 0.85; }
