/* =============================================
   BASE
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
/* font-display:swap is set in the URL above — text shows immediately in fallback font */

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

body {
  margin: 0;
  font-family: 'Inter', Arial, sans-serif;
  background: #f1f5f9;
  min-height: 100vh;
}

body, div, h1, h2, h3, p, span {
  user-select: none;
  cursor: default;
}

input, select, textarea {
  user-select: text;
  cursor: text;
}

h2 { margin-top: 0; }

/* =============================================
   TOPBAR
   ============================================= */

.topbar {
  background: linear-gradient(135deg, #1a3faa 0%, #2563eb 50%, #3b82f6 100%);
  color: white;
  padding: 0 30px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 24px rgba(30,64,175,0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.topbar-brand {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.4px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand svg {
  width: 22px;
  height: 22px;
  opacity: 0.95;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.topbar-nav a:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.topbar-nav a.active {
  background: rgba(255,255,255,0.26);
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.15);
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 7px;
}

.topbar-user svg {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}

.logout {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.logout:hover { background: rgba(255,255,255,0.22); }

/* =============================================
   PAGE WRAPPER
   ============================================= */

.page {
  padding: 30px;
  max-width: 1400px;
  margin: 0 auto;
}

.back {
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #3b82f6;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: gap 0.15s;
  text-decoration: none;
}

.back:hover { gap: 10px; }

/* =============================================
   CARDS
   ============================================= */

.card {
  background: white;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  border: 1px solid #f1f5f9;
}

/* =============================================
   DASHBOARD
   ============================================= */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
}

.welcome-banner {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-radius: 18px;
  padding: 28px 32px;
  margin-bottom: 28px;
  color: white;
}

.welcome-banner h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 800;
}

.welcome-banner p {
  margin: 0;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

.dashboard-card {
  background: white;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid #f1f5f9;
  cursor: pointer;
}

.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(37,99,235,0.12), 0 2px 8px rgba(0,0,0,0.06);
  border-color: #dbeafe;
}

.dashboard-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.dashboard-card-icon svg {
  width: 24px;
  height: 24px;
}

.icon-blue   { background: #dbeafe; }
.icon-blue svg   { color: #2563eb; }
.icon-green  { background: #f0fdf4; }
.icon-green svg  { color: #16a34a; }
.icon-purple { background: #faf5ff; }
.icon-purple svg { color: #7c3aed; }
.icon-red    { background: #fff1f2; }
.icon-red svg    { color: #dc2626; }
.icon-amber  { background: #fffbeb; }
.icon-amber svg  { color: #d97706; }

.dashboard-card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.dashboard-card p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,0.35); }
.btn:active { transform: translateY(0); }

.btn.small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.filter-btn { background: #f8fafc; color: #64748b; border: 1.5px solid #e2e8f0; }
.filter-btn-active { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

/* =============================================
   LOG FORM
   ============================================= */

.log-form-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f1f5f9;
}

.log-form-header h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.log-form-header p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.log-date-row { margin-bottom: 20px; }

.log-date-row label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.log-date-row input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.log-date-row input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.log-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 32px;
}

.log-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-section-title svg {
  width: 14px;
  height: 14px;
  color: #94a3b8;
}

.form-field { margin-bottom: 16px; }

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}

.form-field input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fafafa;
}

.form-field input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  background: white;
}

.log-form-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 16px;
}

.save-success {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid #bbf7d0;
}

/* =============================================
   KPI CARDS
   ============================================= */

.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 10px;
}

.kpi-card {
  background: white;
  padding: 18px 20px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #f1f5f9;
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 22px; height: 22px; }

.kpi-text { display: flex; flex-direction: column; }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.kpi-card b {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  display: block;
  line-height: 1;
}

.kpi-card b.good  { color: #16a34a; }
.kpi-card b.warn  { color: #d97706; }
.kpi-card b.bad   { color: #dc2626; }

/* =============================================
   SKELETON LOADERS
   ============================================= */

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 10px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-kpi {
  height: 82px;
  border-radius: 16px;
  border: none;
  box-shadow: none;
}

.skeleton-chart {
  height: 340px;
  border-radius: 18px;
}

/* =============================================
   EMPTY STATE
   ============================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 280px;
  color: #94a3b8;
  text-align: center;
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.35;
}

.empty-state p {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  color: #94a3b8;
}

/* =============================================
   CHARTS
   ============================================= */

.reports-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.chart-card { padding: 26px; }

.chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

.chart-grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

.chart-grid-2 .chart-card canvas { width: 100%; height: 300px; }
.chart-card canvas { height: 300px; width: 100%; }

.section-title {
  margin-top: 36px;
  margin-bottom: 18px;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 10px;
}

.lead-ratio-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.lead-ratio-toggle {
  background: #f1f5f9;
  color: #475569;
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lead-ratio-toggle:hover { background: #e2e8f0; color: #1e293b; }
.lead-ratio-toggle.active { background: #3b82f6; color: white; }

/* =============================================
   HISTORY TABLE
   ============================================= */

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 14px;
}

.history-table th {
  text-align: left;
  padding: 12px;
  background: #f8fafc;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}

.history-table td {
  padding: 13px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.history-table tr:hover { background: #f8fafc; }

.data-row.delete-selected {
  background: #fff1f2 !important;
  border-left: 3px solid #ef4444;
}

.select-col { display: none; }

.delete-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.delete-controls .btn:first-child { background: #f59e0b; }
.delete-controls .btn:first-child:hover { background: #d97706; }

.delete-btn { background: #ef4444 !important; }
.delete-btn:hover { background: #dc2626 !important; }

.history-table input[type="checkbox"] {
  transform: scale(1.2);
  cursor: pointer;
}

/* =============================================
   AUTH PAGE
   ============================================= */

.center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo svg { width: 28px; height: 28px; color: #2563eb; }
.auth-logo span { font-size: 20px; font-weight: 800; color: #0f172a; }

.auth-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: #64748b;
  margin: 0 0 28px 0;
  text-align: center;
}

.auth-input-group { margin-bottom: 16px; }

.auth-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.auth-input-group input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 15px;
  margin-bottom: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-input-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.auth-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  border-radius: 10px;
  margin-top: 4px;
  justify-content: center;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px 0;
  cursor: pointer;
}

.remember-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: #3b82f6;
}

.remember-row span { font-size: 13px; color: #475569; cursor: pointer; }

.switch {
  margin-top: 20px;
  font-size: 13px;
  color: #3b82f6;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
}

.switch:hover { text-decoration: underline; }
#msg { margin-top: 12px; font-size: 13px; text-align: center; }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: slideInToast 0.3s ease, fadeOutToast 0.4s ease 2.6s forwards;
  min-width: 240px;
  max-width: 340px;
}

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: #2563eb; }

@keyframes slideInToast {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOutToast {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(120%); }
}

/* =============================================
   MOBILE BOTTOM NAV
   ============================================= */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  overflow-x: hidden;
  padding: 0;
  width: 100%;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 6px;
  cursor: pointer;
  text-decoration: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  transition: color 0.15s;
  flex: 1;
  white-space: nowrap;
}

.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: #3b82f6; }
.bottom-nav-item:hover  { color: #3b82f6; }

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {

  /* ── Prevent ALL horizontal overflow on every page ── */
  html, body {
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
  }

  /* ── Base layout ── */
  .bottom-nav { display: block; }
  .page { padding: 12px 12px 90px 12px; max-width: 100%; }
  .topbar-nav { display: none; }

  /* Topbar: fixed width = screen width, no overflow */
  .topbar {
    padding: 0 14px;
    height: 56px;
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
  }
  .topbar-left {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .topbar-brand {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-brand svg { width: 18px; height: 18px; }
  .topbar-right { flex-shrink: 0; gap: 8px; }
  .topbar-user { display: none; }
  .logout { display: none; }
  /* Show a slim page-title label next to the brand on mobile */
  .topbar-page-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Cards ── */
  .card { padding: 16px 14px; border-radius: 12px; }
  .card h2 { font-size: 16px; margin-bottom: 12px; }

  /* ── Back button ── */
  .back { font-size: 13px; margin-bottom: 12px; }

  /* ── Log form ── */
  .log-columns { grid-template-columns: 1fr; gap: 0; }
  .log-form-header p { font-size: 13px; }
  .log-form-footer { flex-wrap: wrap; gap: 10px; }

  /* ── Form fields — more breathing room on mobile ── */
  .form-field { margin-bottom: 18px; }
  .form-field label { font-size: 13px; margin-bottom: 6px; }
  .modal-body { padding: 16px 18px; }
  .modal-header { padding: 16px 18px 14px; }
  .modal-footer { padding: 14px 18px; }

  /* ── Reports / KPI ── */
  .kpi-grid-3 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px; gap: 10px; }
  .kpi-icon { width: 34px; height: 34px; border-radius: 8px; }
  .kpi-label { font-size: 10px; }
  .kpi-card b { font-size: 18px; }
  .chart-grid-2 { grid-template-columns: 1fr; }
  .chart-card canvas { height: 220px !important; }
  .section-title { font-size: 15px; }
  .reports-header { margin-bottom: 14px; }

  /* ── History table — horizontal scroll ── */
  .history-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px;
    /* Right-edge fade: tells users there's more to scroll */
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  }
  .history-table {
    min-width: 640px;
    font-size: 12px;
  }
  .history-table th, .history-table td {
    padding: 9px 8px;
  }

  /* ── Settings ── */
  .settings-card-header { gap: 10px; }
  .settings-card-header .settings-icon { display: none; }

  /* ── Planner header ── */
  .planner-header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  .planner-week-nav {
    flex: 1;
    min-width: 0;
  }
  .planner-week-label {
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #newApptBtn {
    width: 100%;
    justify-content: center;
    order: 3;
  }
  #todayBtn { order: 2; }

  /* ── Planner — horizontal scroll grid on mobile (same as desktop) ── */
  .planner-wrap {
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-y: visible;
  }
  .planner-grid { display: flex !important; min-width: 700px; }
  /* ── Modal — slide up from bottom like a native sheet ── */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    margin: 0;
    border-radius: 20px 20px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-sizing: border-box;
  }
  /* Drag handle pill — visual cue that this is a swipeable sheet */
  .modal-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
  .datetime-row { grid-template-columns: 1fr 1fr; }

  /* ── Bottom nav — scrollable on mobile, active item scrolls into view ── */
  .bottom-nav-item {
    font-size: 10px;
    gap: 3px;
    padding: 4px 2px;
    flex: 1;
    flex-shrink: 1;
    min-width: 0;
  }
  .bottom-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
  .bottom-nav-items { gap: 0; justify-content: space-around; overflow-x: hidden; padding: 0; }

  /* ── Toast — full width on mobile ── */
  #toast-container {
    bottom: 90px;
    right: 12px;
    left: 12px;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  /* ── Home page inline styles ── */
  .home-welcome h1 { font-size: 20px; }
  .home-welcome p { font-size: 13px; }
  .home-upcoming-card { padding: 14px; }
  .home-nav-btn { padding: 12px 10px; }
  .home-nav-btn-label { font-size: 13px; }
  .home-nav-btn-sub { font-size: 11px; }
  .home-stat-value { font-size: 20px !important; }
  .home-stat-card { padding: 14px 12px !important; gap: 10px !important; }
}

/* =============================================
   PASSWORD TOGGLE
   ============================================= */

.pw-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-field-wrap input {
  flex: 1;
  padding-right: 42px !important;
}

/* Hide browser's built-in password reveal button (Windows Edge/Chrome only) */
.pw-field-wrap input::-ms-reveal,
.pw-field-wrap input::-ms-clear {
  display: none;
}
/* Hide Chrome desktop autofill button — do NOT hide on iOS Safari as it
   breaks the entire input field rendering and prevents typing */
@supports not (-webkit-touch-callout: none) {
  .pw-field-wrap input::-webkit-credentials-auto-fill-button {
    display: none !important;
  }
}

.pw-toggle-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.pw-toggle-btn:hover { color: #2563eb; }

/* =============================================
   UTILITIES
   ============================================= */

.hidden { display: none !important; }
.export-btn { height: 40px; }
/* =============================================
   SETTINGS PAGE
   ============================================= */

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f1f5f9;
}

.settings-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-icon svg {
  width: 22px;
  height: 22px;
}

.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}

.settings-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-value {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
/* =============================================
   PLANNER PAGE
   ============================================= */

.planner-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.planner-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px 10px;
}

.planner-week-label {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  min-width: 200px;
  text-align: center;
}

.planner-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: #475569;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.planner-nav-btn:hover { background: #f1f5f9; color: #1e40af; }

/* ---- Grid Wrapper ---- */
.planner-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}

.planner-grid {
  display: flex;
  flex-direction: column;
  min-width: 780px;
}

/* ---- Header Row ---- */
.pg-header-row {
  display: grid;
  grid-template-columns: 68px repeat(7, 1fr);
  border-bottom: 2px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}

.pg-gutter-head {
  border-right: 1.5px solid #e2e8f0;
  background: #f8fafc;
}

.pg-day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-right: 1px solid #f1f5f9;
  gap: 2px;
}

.pg-day-head:last-child { border-right: none; }

.pg-day-head.pg-day-today {
  background: #eff6ff;
}

.pg-dow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.pg-dom {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

.pg-day-today .pg-dow { color: #2563eb; }
.pg-day-today .pg-dom {
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ---- Hour Rows ---- */
.pg-row {
  display: grid;
  grid-template-columns: 68px repeat(7, 1fr);
  border-bottom: 1px solid #f1f5f9;
  min-height: 60px;
}

.pg-row:last-child { border-bottom: none; }

.pg-gutter {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-align: right;
  padding: 8px 10px 0 0;
  border-right: 1.5px solid #e2e8f0;
  background: #f8fafc;
  white-space: nowrap;
}

.pg-cell {
  border-right: 1px solid #f1f5f9;
  padding: 4px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  min-height: 60px;
  overflow: hidden;
  min-width: 0;
}

.pg-cell:last-child { border-right: none; }
.pg-cell:hover { background: #f8fafc; }
.pg-cell.pg-cell-today { background: #fafcff; }
.pg-cell.pg-cell-today:hover { background: #eff6ff; }

/* ── Blocked day column ───────────────────────────────────── */
/* Blocked header cell */
/* ── Blocked Day — Header ──────────────────────────────── */
.pg-day-blocked-head {
  background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%) !important;
  position: relative;
  border-bottom: 2.5px solid #ef4444 !important;
}
.pg-day-blocked-head .pg-dow {
  color: #b91c1c !important;
  font-weight: 800 !important;
}
.pg-day-blocked-head .pg-dom {
  color: #dc2626 !important;
  opacity: 0.6;
}

/* Unavailable badge — elegant pill */
.pg-block-badge {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-top: 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #ef4444;
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.4;
}

/* ── Hover Popover for block/unblock (admin) ─────────── */
.pg-block-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
  padding: 10px 12px;
  min-width: 160px;
  animation: pgPopIn 0.12s ease-out;
}
.pg-block-popover::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;
}
@keyframes pgPopIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.pg-popover-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-align: center;
}
.pg-popover-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.pg-popover-block {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
}
.pg-popover-block:hover {
  background: #fee2e2;
  border-color: #f87171;
}
.pg-popover-unblock {
  background: #f0fdf4;
  color: #16a34a;
  border: 1.5px solid #bbf7d0;
}
.pg-popover-unblock:hover {
  background: #dcfce7;
  border-color: #4ade80;
}
.pg-popover-block-recurring {
  background: #fff7ed;
  color: #c2410c;
  border: 1.5px solid #fed7aa;
  margin-top: 6px;
}
.pg-popover-block-recurring:hover {
  background: #ffedd5;
  border-color: #fb923c;
}

/* ── Blocked Cell — subtle red tint + stripes ────────── */
.pg-cell-blocked {
  background: #fef2f2 !important;
  cursor: not-allowed !important;
  position: relative;
}
.pg-cell-blocked::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    rgba(239, 68, 68, 0.04) 6px,
    rgba(239, 68, 68, 0.04) 12px
  );
  pointer-events: none;
  z-index: 0;
}
.pg-cell-blocked:hover {
  background: #fee2e2 !important;
}
.pg-cell-blocked .pg-appt-block {
  cursor: pointer !important;
  opacity: 0.55;
  position: relative;
  z-index: 1;
}

/* ── Mini Calendar — blocked day highlights ──────────── */
.mc-dow-blocked {
  color: #dc2626 !important;
  font-weight: 800 !important;
}
.mc-blocked {
  background: #fee2e2 !important;
  color: #991b1b !important;
  cursor: not-allowed !important;
  text-decoration: line-through;
  opacity: 0.7;
}
.mc-blocked.mc-today {
  background: #dc2626 !important;
  color: #fff !important;
}

@media (max-width: 768px) {
  .pg-block-popover { min-width: 140px; padding: 8px 10px; }
  .pg-popover-btn { padding: 7px 10px; font-size: 11px; }
}

/* ---- Appointment Blocks ---- */
.pg-appt-block {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 3px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
  transition: transform 0.1s, box-shadow 0.1s;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.pg-appt-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.pg-appt-callback {
  background: linear-gradient(135deg, #d97706, #f59e0b) !important;
  box-shadow: 0 2px 6px rgba(245,158,11,0.3) !important;
}

.pg-appt-callback:hover {
  box-shadow: 0 4px 12px rgba(245,158,11,0.45) !important;
}

.pg-appt-type-badge {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.pg-appt-time {
  display: block;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pg-appt-name {
  display: block;
  font-weight: 700;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.pg-appt-booked {
  display: block;
  font-size: 10px;
  opacity: 0.75;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

/* =============================================
   MODAL
   ============================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.2);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 2px solid #f1f5f9;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.modal-close {
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: background 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: #0f172a; }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 2px solid #f1f5f9;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Appointment type selector — Safari/iOS compatible ── */
.appt-type-row {
  display: flex;
  gap: 10px;
}
.appt-type-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #fafafa;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
}
.appt-type-label.selected-appt {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}
.appt-type-label.selected-cb {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}
/* Hide the actual radio input — we style the label instead */
.appt-type-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-booked-at {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  margin-top: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
}

/* =============================================
   MINI CALENDAR
   ============================================= */

.mini-cal-wrap {
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  margin: 4px 0 14px 0;
  background: #f8fafc;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mini-cal-header span {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.mini-cal-header button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: #64748b;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.mini-cal-header button:hover { background: #e2e8f0; color: #1e40af; }

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mc-dow {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.04em;
}

.mc-blank { }

.mc-day {
  text-align: center;
  padding: 5px 2px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.mc-day:hover { background: #e2e8f0; }

.mc-today {
  background: #eff6ff;
  color: #2563eb;
}

.mc-selected {
  background: #2563eb !important;
  color: #fff !important;
  border-radius: 6px;
}

/* =============================================
   TOOLTIP
   ============================================= */

.appt-tooltip {
  position: fixed;
  z-index: 2000;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  width: 260px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.3);
  pointer-events: none;
}

.appt-tooltip.hidden { display: none; }

.tip-name {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
}

.tip-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.tip-row svg { flex-shrink: 0; margin-top: 1px; }

.tip-comments {
  color: #cbd5e1;
  font-style: italic;
  padding: 6px 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  margin: 4px 0;
}

.tip-meta { color: #64748b; font-size: 11px; }

/* modal textarea */
textarea {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #0f172a;
  background: #f8fafc;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}
/* =============================================
   #20 ONBOARDING EMPTY STATE
   ============================================= */

.onboarding-banner {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-radius: 16px;
  padding: 28px 24px;
  border: 1.5px dashed #bfdbfe;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.onboarding-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}

.onboarding-text { flex: 1; min-width: 200px; }
.onboarding-text h3 { font-size: 17px; font-weight: 800; color: #0f172a; margin: 0 0 4px 0; }
.onboarding-text p  { font-size: 13px; color: #64748b; margin: 0 0 14px 0; }

.onboarding-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2563eb;
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}
.onboarding-btn:hover { background: #1d4ed8; }

/* =============================================
   #21 NOTIFICATION BADGE on nav links
   ============================================= */

.nav-badge-wrap { position: relative; display: inline-flex; }

.nav-badge {
  position: absolute;
  top: -5px;
  right: -8px;
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  z-index: 10;
}

/* Bottom nav badge */
.bottom-nav-item { position: relative; }
.bottom-nav-item .nav-badge { top: 0; right: 4px; }

/* Topbar nav badge */
.topbar-nav a { position: relative; }
.topbar-nav a .nav-badge { top: -2px; right: -4px; }

/* =============================================
   #22 PLANNER SUMMARY BAR
   ============================================= */

.planner-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  flex-wrap: wrap;
  font-size: 13px;
}

.planner-summary-label { color: #94a3b8; margin-right: 4px; }

.planner-summary-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.planner-summary-badge.appt    { background: #eff6ff; color: #2563eb; }
.planner-summary-badge.cb      { background: #fffbeb; color: #d97706; }
.planner-summary-badge.today   { background: #dcfce7; color: #166534; }
.planner-summary-badge.today-cb { background: #fef3c7; color: #92400e; }
.planner-summary-badge.empty   { color: #94a3b8; font-weight: 500; }
.planner-summary-sep { width: 1px; height: 16px; background: #e2e8f0; margin: 0 4px; display: inline-block; vertical-align: middle; }

/* Quality row due-date highlighting */
/* Quality row due-date highlighting — must target td directly due to border-collapse */
.history-table tr.quality-row-green td,
.history-table tbody tr.quality-row-green td { background-color: #dcfce7 !important; border-bottom-color: #86efac !important; }
.history-table tr.quality-row-yellow td,
.history-table tbody tr.quality-row-yellow td { background-color: #fef9c3 !important; border-bottom-color: #fde047 !important; }
.history-table tr.quality-row-red td,
.history-table tbody tr.quality-row-red td { background-color: #fee2e2 !important; border-bottom-color: #fca5a5 !important; }

/* Hover: slightly deeper shade */
.history-table tr.quality-row-green:hover td { background-color: #bbf7d0 !important; }
.history-table tr.quality-row-yellow:hover td { background-color: #fef08a !important; }
.history-table tr.quality-row-red:hover td { background-color: #fecaca !important; }

/* Due date badge in quality table */
.due-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.due-badge.green  { background: #dcfce7; color: #166534; }
.due-badge.yellow { background: #fef9c3; color: #854d0e; }
.due-badge.red    { background: #fee2e2; color: #dc2626; }
.due-badge.none   { background: #f1f5f9; color: #94a3b8; }

/* Appointment outcome status badges on planner */
.pg-appt-status {
  display: inline-block;
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 4px; margin-left: 3px; text-transform: uppercase; letter-spacing: 0.03em;
}
.pg-appt-status.confirmed  { background: #dcfce7; color: #15803d; }
.pg-appt-status.rescheduled { background: #dbeafe; color: #1d4ed8; }
.pg-appt-status.no_show    { background: #f1f5f9; color: #64748b; }
.pg-appt-status.cancelled  { background: #fee2e2; color: #dc2626; }

/* Blocked hour cells */
.pg-cell-hour-blocked {
  background: repeating-linear-gradient(
    135deg,
    #f8fafc 0px, #f8fafc 6px,
    #f1f5f9 6px, #f1f5f9 12px
  ) !important;
  cursor: not-allowed;
  position: relative;
}
.pg-cell-hour-blocked::after {
  content: '';
  position: absolute; inset: 0;
  border-left: 2px solid #cbd5e1;
}
.pg-hour-block-label {
  position: absolute; top: 3px; left: 6px;
  font-size: 9px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.04em;
  pointer-events: none; z-index: 1;
}

/* Status dropdown in planner modal */
.appt-status-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px;
}
.appt-status-btn {
  flex: 1; min-width: 80px;
  padding: 7px 10px; border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc; color: #64748b;
  font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: center;
  transition: all 0.15s;
}
.appt-status-btn:hover { border-color: #94a3b8; }
.appt-status-btn.active-confirmed  { background: #dcfce7; color: #15803d; border-color: #86efac; }
.appt-status-btn.active-rescheduled { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.appt-status-btn.active-no_show    { background: #f1f5f9; color: #475569; border-color: #94a3b8; }
.appt-status-btn.active-cancelled  { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* =============================================
   #24 QUALITY ANALYTICS SUMMARY CARD
   ============================================= */

.quality-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.quality-stat {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px 18px;
  border: 1px solid #f1f5f9;
}

.quality-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.quality-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

.quality-stat-value.green { color: #16a34a; }
.quality-stat-value.amber { color: #d97706; }
.quality-stat-value.red   { color: #dc2626; }

@media (max-width: 768px) {
  .quality-summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quality-stat    { padding: 12px 14px; }
  .quality-stat-value { font-size: 18px; }
}

/* =============================================
   #28 CHART DATA LABELS (via plugin — no CSS needed)
   Styles for the datalabels are set in JS.
   This is a placeholder comment for reference.
   ============================================= */

/* =============================================
   #31 LONG-PRESS TOUCH FEEDBACK
   ============================================= */

.pg-appt-block.touch-active {
  transform: scale(0.96);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

/* =============================================
   #32 PULL-TO-REFRESH INDICATOR
   ============================================= */

.ptr-indicator {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #2563eb;
  color: #fff;
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 700;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.ptr-indicator.visible { opacity: 1; }

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ptr-spin { animation: ptr-spin 0.8s linear infinite; }

/* =============================================
   #33 iOS INPUT ZOOM FIX
   All inputs must be at least 16px font-size on
   iOS to prevent Safari auto-zoom on focus.
   ============================================= */

@media (max-width: 768px) {
  input,
  select,
  textarea,
  .form-field input,
  .log-date-row input,
  .auth-input-group input,
  .pw-field-wrap input,
  .mini-cal-wrap input,
  .planner-search-input-wrap input,
  .quality-search-input-wrap input {
    font-size: 16px !important;
  }

  /* Keep the visual size compact while meeting iOS requirement */
  .form-field input  { padding: 10px 12px; }
  .log-date-row input { padding: 10px 12px; }
  .auth-input-group input { padding: 13px 14px; }
}

/* =============================================
   #34 PWA INSTALL BANNER
   ============================================= */

.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: #1e293b;
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 400;
  align-items: center;
  gap: 12px;
}

.pwa-install-banner.visible { display: flex; }

.pwa-install-banner p  { flex: 1; font-size: 13px; font-weight: 600; margin: 0; }
.pwa-install-banner .pwa-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-banner .pwa-dismiss {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}
/* =============================================
   PAGE TRANSITIONS — fade-in only, no flash
   =============================================
   The key to no white flash:
   1. Set html background = body background so the browser
      paints slate-grey INSTANTLY before any CSS loads.
   2. Only fade IN — no fade out, no click interception.
      Navigation is instant; only the content fades in.
   3. No translateY — that causes a jump on fast machines.
   ============================================= */

html {
  background: #f1f5f9;
}

body {
  animation: kpi-page-in 0.13s ease-out both;
}

@keyframes kpi-page-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* =============================================
   COLD START OVERLAY
   ============================================= */

.cold-start-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}

.cold-start-overlay.visible { display: flex; }

.cold-start-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: cspin 0.9s linear infinite;
}

@keyframes cspin {
  to { transform: rotate(360deg); }
}

.cold-start-text {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

.cold-start-sub {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

/* =============================================
   QUALITY DUE / OVERDUE INDICATOR
   ============================================= */

tr.quality-overdue td { background: #fff7f7 !important; }
tr.quality-overdue td:first-child { border-left: 3px solid #dc2626; }

tr.quality-due-soon td { background: #fffbeb !important; }
tr.quality-due-soon td:first-child { border-left: 3px solid #f59e0b; }

.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.due-badge.overdue { background: #fee2e2; color: #dc2626; }
.due-badge.soon    { background: #fef3c7; color: #d97706; }
.due-badge.ok      { background: #dcfce7; color: #166534; }

/* =============================================
   DRAG AND DROP — PLANNER
   ============================================= */

.pg-appt-block {
  cursor: grab;
}

.pg-appt-block:active {
  cursor: grabbing;
}

.pg-appt-block.dragging {
  opacity: 0.45;
  transform: scale(0.97);
  box-shadow: none !important;
}

.pg-cell.drag-over {
  background: rgba(59, 130, 246, 0.12) !important;
  outline: 2px dashed #3b82f6;
  outline-offset: -2px;
}

.pg-cell.drag-over.callback-over {
  background: rgba(245, 158, 11, 0.12) !important;
  outline-color: #f59e0b;
}

/* Drop ghost — shows where block will land */
.drop-ghost {
  border-radius: 6px;
  margin: 2px 3px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.55;
  pointer-events: none;
}

.drop-ghost.appointment { background: #bfdbfe; color: #1e40af; }
.drop-ghost.callback    { background: #fde68a; color: #92400e; }

/* Undo toast button */
.toast-undo-btn {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  white-space: nowrap;
}

.toast-undo-btn:hover { background: rgba(255,255,255,0.15); }

/* =============================================
   CHART MOBILE DATA LABELS
   (line/pie chart value display on mobile)
   ============================================= */

.chart-mobile-values {
  display: none;
}

@media (max-width: 768px) {
  .chart-mobile-values {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 4px;
    border-top: 1px solid #f1f5f9;
  }

  .chart-mv-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #475569;
    font-weight: 600;
  }

  .chart-mv-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .chart-mv-val {
    font-weight: 800;
    color: #0f172a;
  }
}
/* =============================================
   PERFORMANCE OPTIMISATIONS
   ============================================= */

/* Faster perceived load: GPU-accelerate the topbar and bottom nav
   since they're always visible and fixed/sticky */
.topbar, .bottom-nav {
  will-change: transform;
  transform: translateZ(0);
}

/* content-visibility: auto tells the browser to skip rendering
   off-screen content until it scrolls into view.
   Huge win on long pages like history and quality. */
.history-table-wrap,
.chart-grid-2,
.chart-grid-1,
.kpi-grid-3 {
  content-visibility: auto;
  contain-intrinsic-size: 0 400px;
}

/* Prevent layout thrash on cards during load */
.kpi-card, .home-stat-card, .card {
  contain: layout style;
}

/* Faster tap response on mobile — removes 300ms click delay */
a, button, .btn, .bottom-nav-item, .home-nav-btn, .pg-appt-block {
  touch-action: manipulation;
}

/* Font loading: swap ensures text is visible during font load */
@font-face {
  font-display: swap;
}
/* =============================================
   PLANNER APPOINTMENT SEARCH
   ============================================= */

.planner-search-bar {
  position: relative;
  margin-bottom: 14px;
  max-width: 480px;
}

.planner-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.planner-search-input-wrap:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.10);
}

.planner-search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  background: transparent;
  font-family: inherit;
  min-width: 0;
}

.planner-search-input-wrap input::placeholder { color: #94a3b8; }

.search-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: none;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  width: 22px;
  height: 22px;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s;
}
.search-clear-btn:hover { background: #e2e8f0; }

/* Dropdown */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  z-index: 200;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f8fafc;
  transition: background 0.10s;
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover,
.search-result-row.search-result-active { background: #f1f5f9; }

.search-result-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.search-icon-appt { background: #eff6ff; color: #2563eb; }
.search-icon-cb   { background: #fffbeb; color: #d97706; }

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

.search-result-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-date {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.search-result-past { color: #94a3b8; }

.search-result-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}

/* Highlight pulse — applied when jumping to an appointment */
@keyframes search-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.7); transform: scale(1.04); }
  50%  { box-shadow: 0 0 0 8px rgba(59,130,246,0.15); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); transform: scale(1); }
}
.pg-appt-block.search-highlight {
  animation: search-pulse 0.6s ease-out 0s, search-pulse 0.6s ease-out 0.7s, search-pulse 0.6s ease-out 1.4s;
  outline: 2.5px solid #3b82f6;
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .planner-search-bar { max-width: 100%; }
}

/* =============================================
   QUALITY SEARCH BAR
   ============================================= */

.quality-search-bar {
  margin-bottom: 16px;
  max-width: 520px;
}

.quality-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.quality-search-input-wrap:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.10);
}

.quality-search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  background: transparent;
  font-family: inherit;
  min-width: 0;
}

.quality-search-input-wrap input::placeholder { color: #94a3b8; }

/* Highlight matched text in rows */
mark.q-highlight {
  background: #fef9c3;
  color: #713f12;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: inherit;
}

/* Row highlight when matched */
#qualityBody tr.q-match-row {
  background: #fafcff;
}

@media (max-width: 768px) {
  .quality-search-bar { max-width: 100%; }
}
/* ══════════════════════════════════════════════════════════════
   TIMESHEET PAGE
   ══════════════════════════════════════════════════════════════ */

/* ── Summary stat strip ─────────────────────────────────────── */
.ts-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.ts-summary-card {
  background: #fff;
  border: 1px solid #f1f5f9;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  text-align: center;
}
.ts-summary-label {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.ts-summary-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

/* ── Period toggle ──────────────────────────────────────────── */
.ts-period-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  width: fit-content;
}
.ts-period-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #64748b;
  transition: all 0.15s;
  font-family: inherit;
}
.ts-period-btn.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ── Week navigator ─────────────────────────────────────────── */
.ts-week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px 8px;
}
.ts-week-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  border-radius: 7px;
  cursor: pointer;
  color: #475569;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.ts-week-arrow:hover:not(:disabled) {
  background: #e2e8f0;
  color: #0f172a;
}
.ts-week-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}
.ts-week-label {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  min-width: 160px;
  text-align: center;
}

/* ── Assistant accordion (admin view) ───────────────────────── */
.ts-assistant-block {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  margin-bottom: 16px;
  overflow: hidden;
}
.ts-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.ts-assistant-header:hover { background: #f8fafc; }
.ts-assistant-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.ts-assistant-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.ts-assistant-stats {
  display: flex;
  gap: 20px;
  align-items: center;
}
.ts-assistant-stat {
  text-align: center;
  min-width: 52px;
}
.ts-assistant-stat-label {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ts-assistant-stat-val {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}
.ts-chevron {
  color: #94a3b8;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.ts-chevron.open { transform: rotate(180deg); }

.ts-assistant-body {
  border-top: 1.5px solid #f1f5f9;
  overflow-x: auto;
}

/* ── Timesheet table ────────────────────────────────────────── */
.ts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 580px;
}
.ts-table thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid #e2e8f0;
  white-space: nowrap;
}
.ts-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.ts-table tbody tr:last-child { border-bottom: none; }
.ts-table tbody tr:hover { background: #f8fafc; }
.ts-table td {
  padding: 11px 14px;
  color: #334155;
  vertical-align: middle;
}
.ts-table td.ts-date { font-weight: 700; color: #0f172a; white-space: nowrap; }
.ts-table td.ts-num  { font-weight: 700; color: #2563eb; text-align: center; }
.ts-table td.ts-hours { font-weight: 700; color: #16a34a; }
.ts-table td.ts-notes { color: #64748b; font-size: 12px; max-width: 180px; }
.ts-table tfoot td {
  padding: 11px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
  text-align: center;
}
.ts-table tfoot td.ts-foot-label {
  text-align: left;
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Assistant form (submit view) ───────────────────────────── */
.ts-form-card {
  background: #fff;
  border-radius: 16px;
  border: 1.5px solid #e2e8f0;
  padding: 24px 26px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  max-width: 560px;
}
.ts-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.ts-form-field { display: flex; flex-direction: column; gap: 6px; }
.ts-form-field label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ts-form-field input, .ts-form-field textarea {
  padding: 10px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: #0f172a;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.ts-form-field input:focus, .ts-form-field textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
  background: #fff;
}
.ts-form-field textarea { resize: vertical; min-height: 70px; }
.ts-form-full { grid-column: 1 / -1; }

/* ── Empty state ────────────────────────────────────────────── */
.ts-empty {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 14px;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ts-summary-strip { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ts-summary-value { font-size: 20px; }
  .ts-assistant-stats { display: none; }
  .ts-form-card { padding: 16px 14px; }
  .ts-form-grid { grid-template-columns: 1fr; }
}

/* =============================================
   iOS & macOS COMPATIBILITY FIXES
   ============================================= */

/* ── 1. iOS Safari: remove tap highlight flash on buttons/links */
a, button, .btn, .bottom-nav-item, .planner-nav-btn,
.modal-close, .search-clear-btn, .pw-toggle-btn {
  -webkit-tap-highlight-color: transparent;
}

/* ── 2. iOS Safari: prevent rubber-band scroll on fixed overlays */
.modal-backdrop, #pwResetOverlay, #_cfModal {
  -webkit-overflow-scrolling: auto;
  overscroll-behavior: contain;
}

/* ── 3. iOS Safari: modal card scroll momentum */
.modal-card, .modal-body {
  -webkit-overflow-scrolling: touch;
}

/* ── 4. iOS Safari: inputs — remove inner shadow & rounded corners
        Only apply to text-style inputs. NEVER apply to radio/checkbox
        as it makes them invisible on macOS/iOS Safari.
        NEVER apply to password inputs — Safari needs its default
        appearance to render the masking dots (•••). */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="password"]),
textarea,
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Password inputs: keep native appearance for masking dots,
   but normalise the visual look to match other inputs */
input[type="password"] {
  background: #fff;
  box-shadow: none;
  -webkit-box-shadow: none;
  font-family: inherit;
}
/* When eye is clicked and field switches to text, apply appearance:none
   so the revealed text looks clean and consistent */
input[type="text"].pw-revealed {
  -webkit-appearance: none;
  appearance: none;
}

/* ── 5. iOS Safari: date input — make it look like other inputs */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}

/* ── 6. iOS: ensure password field eye toggle is always tappable */
.pw-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pw-field-wrap input {
  flex: 1;
  padding-right: 46px !important;
  /* Prevent iOS from clipping the text behind the eye button */
  box-sizing: border-box;
  width: 100%;
}

/* ── 7. macOS Safari: fix sticky hover states on buttons */
@media (hover: hover) {
  .btn:hover { filter: brightness(0.93); }
  .bottom-nav-item:hover { background: #f1f5f9; }
}
/* Remove hover effects on touch devices (iOS) */
@media (hover: none) {
  .btn:hover { filter: none; }
  .bottom-nav-item:hover { background: transparent; }
}

/* ── 8. iOS: bottom nav safe area — extra padding for home bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  /* Push page content above the nav + safe area */
  @media (max-width: 768px) {
    .page {
      padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }
  }
}

/* ── 9. iOS: topbar safe area for notch/Dynamic Island */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (max-width: 768px) {
    .topbar {
      padding-top: env(safe-area-inset-top);
      height: calc(56px + env(safe-area-inset-top));
    }
  }
}

/* ── 10. iOS: minimum tap target size (44×44px) for all interactive elements */
@media (max-width: 768px) {
  .btn,
  .btn.small,
  .planner-nav-btn,
  .modal-close,
  .logout,
  .back,
  .search-clear-btn,
  .ref-remove-btn,
  .conf-test-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* Back link is inline — override justify */
  .back {
    justify-content: flex-start;
    display: inline-flex;
  }
  /* Bottom nav items: column layout, tall enough to tap */
  .bottom-nav-item {
    min-height: 52px;
    flex-direction: column;
    justify-content: center;
  }
}

/* ── 11. iOS: planner modal — account for home bar at bottom */
@media (max-width: 768px) {
  .modal-card {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ── 12. macOS: topbar brand image — consistent sizing on Retina */
.topbar-brand img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ── 13. iOS: planner grid — prevent text selection during scroll */
.planner-wrap,
.planner-grid {
  -webkit-user-select: none;
  user-select: none;
}

/* ── 14. iOS/macOS: fix select dropdown appearance */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px !important;
}

/* ── 15. iOS: auth card — prevent overflow on small screens */
@media (max-width: 400px) {
  .auth-card {
    padding: 24px 18px;
    border-radius: 16px;
  }
  .auth-logo span {
    font-size: 18px;
  }
}

/* =============================================
   MOBILE UTILITY CLASSES
   ============================================= */

/* Show only on mobile */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: block; }
}

/* =============================================
   MOBILE — BOTTOM NAV SIGN OUT
   Sign Out moves from topbar to a final slot
   in the bottom nav on mobile.
   ============================================= */
.bottom-nav-signout {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav-signout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    background: none;
    border: none;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .bottom-nav-signout:active { color: #ef4444; }
  .bottom-nav-signout svg { width: 20px; height: 20px; }
}

/* =============================================
   MOBILE — HOME LOWER SECTION ORDERING
   Ensures .home-lower respects CSS order on mobile
   ============================================= */
@media (max-width: 768px) {
  .home-lower { display: flex !important; flex-direction: column; }
}
/* ── Additional SMS recipients (appointment modal) ────────────── */
.add-recipient-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1.5px dashed #bfdbfe;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.add-recipient-btn:hover { background: #dbeafe; border-color: #93c5fd; }

.recipient-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.recipient-row input {
  padding: 9px 11px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.recipient-row input:focus { outline: none; border-color: #93c5fd; }
.recipient-row .rcpt-name  { flex: 1 1 40%; min-width: 0; }
.recipient-row .rcpt-phone { flex: 1 1 60%; min-width: 0; }
.recipient-remove-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: #fef2f2;
  color: #dc2626;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.recipient-remove-btn:hover { background: #fee2e2; }

.recipient-hint {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 8px;
}

/* =============================================
   BLOCK TIME DIALOG
   Built from the app's own .modal-* / .form-field / .btn classes so it
   matches every other dialog. Only the pieces those classes don't already
   cover live here. Appended at the end so these win over earlier base rules.
   ============================================= */

/* Selects were never styled — inputs were. Match them exactly.
   Native appearance is left alone on purpose: overriding it has caused
   input-rendering problems on iOS Safari elsewhere in this app. */
.form-field select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  background: #fff;
}

/* Two fields side by side (From / To). */
.bh-row {
  display: flex;
  gap: 12px;
}
.bh-row .form-field { flex: 1; margin-bottom: 0; }

/* Subtitle under the dialog title showing which day(s) the block applies to. */
.bh-subtitle {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
  margin-top: 2px;
}

/* Quiet helper line under the From/To row. */
.bh-hint {
  font-size: 11.5px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 8px 0 16px;
}

/* Inline validation message. */
.bh-error {
  font-size: 12.5px;
  color: #dc2626;
  font-weight: 600;
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
  display: none;
}
.bh-error.show { display: block; }

/* When an error is showing, the footer stacks so the message gets its own row. */
.bh-footer { flex-wrap: wrap; }
.bh-footer .bh-error { flex-basis: 100%; }

/* Secondary action, paired with .btn for the primary. */
.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: none;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }

.bh-footer { justify-content: flex-end; }

@keyframes bhIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.bh-card { animation: bhIn 0.18s ease; }

@media (prefers-reduced-motion: reduce) {
  .bh-card { animation: none; }
}

/* Badges on appointments that arrived through the public agent booking link. */
.pg-appt-agent,
.pg-appt-nophone {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  white-space: nowrap;
}
.pg-appt-agent   { background: #ede9fe; color: #6d28d9; }
.pg-appt-nophone { background: #fef3c7; color: #b45309; }
