/* ============================================================
   TheraTrack — Stylesheet
   Font: DM Sans + DM Mono
   Palette: Deep navy, clinical teal, warm white
   ============================================================ */

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

:root {
  --navy: #0f1f3d;
  --navy-mid: #1a3260;
  --navy-light: #2a4a8c;
  --teal: #0d9488;
  --teal-light: #14b8a6;
  --teal-pale: #e6faf8;
  --accent: #f59e0b;
  --accent-pale: #fffbeb;
  --white: #ffffff;
  --surface: #f7f8fc;
  --surface-2: #eef0f7;
  --border: #dde2ef;
  --border-strong: #c4cce0;
  --text-primary: #0f1f3d;
  --text-secondary: #4a5680;
  --text-muted: #8892b0;
  --success: #0d9488;
  --success-bg: #e6faf8;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --paid: #7c3aed;
  --paid-bg: #f3f0ff;
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(15,31,61,0.08), 0 1px 2px rgba(15,31,61,0.06);
  --shadow-md: 0 4px 12px rgba(15,31,61,0.1);
}

html, body { height: 100%; font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text-primary); background: var(--surface); }

/* ── UTILS ── */
.hidden { display: none !important; }
.req { color: var(--danger); }

/* ── SCREEN SYSTEM ── */
.screen { width: 100%; }
.screen.active { display: block; }

/* ── AUTH ── */
.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(13,148,136,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(42,74,140,0.3) 0%, transparent 50%);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
}

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

.logo-mark {
  width: 56px;
  height: 56px;
  background: #0f172a;
  color: var(--white);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.logo-mark::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 12px;
  width: 22px;
  height: 3px;
  background: #2dd4bf;
  border-radius: 2px;
  opacity: 0.9;
  box-shadow: 0 7px 0 rgba(45,212,191,0.6), 0 14px 0 rgba(45,212,191,0.35);
}

.logo-mark.sm {
  width: 32px;
  height: 32px;
  font-size: 11px;
  border-radius: 8px;
}

.logo-mark.sm::before {
  width: 11px;
  height: 2px;
  left: 4px;
  top: 7px;
  box-shadow: 0 4px 0 rgba(45,212,191,0.6), 0 8px 0 rgba(45,212,191,0.35);
}

.logo-name { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.logo-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.auth-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-note { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 20px; }

/* ── FORMS ── */
.field-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.02em; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}

textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

.form-error { font-size: 12px; color: var(--danger); min-height: 16px; }

/* ── BUTTONS ── */
.btn-primary {
  padding: 9px 20px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--navy-mid); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.full { width: 100%; padding: 11px; }

.btn-secondary {
  padding: 9px 16px;
  background: var(--white);
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.btn-signout {
  width: 100%;
  padding: 8px;
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 8px;
}

.btn-signout:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ── SIDEBAR ── */
#screen-app {
  display: block;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#sidebar-nav {
  flex: 1 1 0;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
  /* flex: 1 1 0 lets nav shrink so footer always shows */
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}

.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }

.nav-item.active {
  background: rgba(13,148,136,0.25);
  color: var(--teal-light);
  font-weight: 500;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  background: var(--navy);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: capitalize; }

/* ── MAIN CONTENT ── */
#main-content {
  margin-left: 220px;
  min-height: 100vh;
  padding: 32px 36px;
  box-sizing: border-box;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header h1 { font-size: 22px; font-weight: 600; color: var(--navy); line-height: 1.2; }
.page-desc { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── STATS ROW ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 600; color: var(--navy); line-height: 1; }
.stat-value.teal { color: var(--teal); }
.stat-value.amber { color: var(--warning); }
.stat-value.purple { color: var(--paid); }

/* ── TOAST ── */
.toast {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid;
}

.toast.success { background: var(--success-bg); color: var(--success); border-color: var(--teal-light); }
.toast.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ── VISIT FORM ── */
.visit-form { max-width: 760px; }

.form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--surface-2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ── TABLE ── */
.table-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead { background: var(--surface); }

th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

/* Allow address/email columns to wrap */
td:nth-child(6), td:nth-child(5) {
  white-space: normal;
  word-break: break-word;
  max-width: 200px;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface); }
.table-empty { text-align: center; color: var(--text-muted); padding: 32px !important; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.pending { background: var(--warning-bg); color: var(--warning); }
.badge.invoiced { background: var(--success-bg); color: var(--success); }
.badge.paid { background: var(--paid-bg); color: var(--paid); }
.badge.pt { background: #eff6ff; color: #1d4ed8; }
.badge.ot { background: #f3f0ff; color: #6d28d9; }
.badge.st { background: #fff7ed; color: #c2410c; }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-input { width: auto !important; font-size: 13px !important; padding: 7px 10px !important; }
.toolbar-actions { display: flex; gap: 8px; }

/* ── DASHBOARD AGENCY GRID ── */
.section-title-row {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.agency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.agency-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.agency-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 12px;
  line-height: 1.3;
}

.agency-card-stats { display: flex; flex-direction: column; gap: 4px; }

.agency-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.agency-stat-label { color: var(--text-muted); }
.agency-stat-val { font-weight: 600; color: var(--text-primary); }
.agency-stat-val.teal { color: var(--teal); }

/* ── INVOICE ── */
.invoice-controls {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.invoice-controls .field-group { min-width: 160px; }

.invoice-preview { background: var(--surface-2); border-radius: var(--radius-lg); padding: 20px; }

.invoice-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.invoice-doc {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 48px;
  box-shadow: var(--shadow-md);
  max-width: 800px;
  margin: 0 auto;
  font-size: 13px;
  line-height: 1.6;
}

.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; }
.inv-company-name { font-size: 20px; font-weight: 700; color: var(--navy); }
.inv-company-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.inv-meta { text-align: right; }
.inv-meta-title { font-size: 24px; font-weight: 700; color: var(--teal); letter-spacing: -0.02em; }
.inv-meta-num { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.inv-meta-date { font-size: 12px; color: var(--text-muted); }

.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; padding: 20px; background: var(--surface); border-radius: var(--radius); }
.inv-party-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.inv-party-name { font-weight: 600; font-size: 14px; color: var(--navy); }
.inv-party-detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.inv-table th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 8px 12px; border-bottom: 2px solid var(--navy); text-align: left; }
.inv-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.inv-table tr:last-child td { border-bottom: none; }
.inv-table .num { text-align: right; font-family: 'DM Mono', monospace; }

.inv-totals { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.inv-totals-box { min-width: 240px; }
.inv-total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; color: var(--text-secondary); }
.inv-total-row.grand { font-size: 14px; font-weight: 700; color: var(--navy); border-top: 2px solid var(--navy); margin-top: 4px; padding-top: 8px; }
.inv-total-row span:last-child { font-family: 'DM Mono', monospace; }

.inv-footer { border-top: 1px solid var(--border); padding-top: 16px; font-size: 11px; color: var(--text-muted); }

/* ── SETTINGS ── */
.settings-section {
  margin-bottom: 32px;
}

.settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.settings-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 2px;
}

.settings-section-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,31,61,0.5);
  z-index: 100;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 101;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--danger); }

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

.btn-danger {
  padding: 5px 12px;
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
}

.btn-danger:hover { background: var(--danger-bg); }

/* ── MOBILE RESPONSIVENESS ── */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    position: fixed;
    left: -220px;
    top: 0;
    height: 100%;
    height: 100dvh;
    width: 220px !important;
    z-index: 200;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #sidebar.open { left: 0; }

  #main-content {
    margin-left: 0 !important;
    padding: 72px 16px 32px 16px !important;
  }

  /* Mobile header bar */
  #mobile-header {
    display: flex !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr !important;
  }

  .invoice-controls {
    flex-direction: column !important;
  }

  .toolbar {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .filters {
    flex-wrap: wrap !important;
  }

  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
}

@media (min-width: 769px) {
  #mobile-header { display: none !important; }
}

/* ── MOBILE HEADER ── */
#mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--navy);
  z-index: 150;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

#mobile-menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

#mobile-logo {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

#mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

/* ── SLIDE IN ANIMATION ── */
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page.active {
  animation: fadeIn 0.2s ease;
}

/* ── BETTER EMPTY STATES ── */
.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px !important;
  font-size: 13px;
}

/* ── TOAST IMPROVEMENTS ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9997;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
}

/* ── SCROLLBAR POLISH ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── LOADING SKELETON ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, #e8eaf2 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius);
  height: 14px;
}

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

/* ── TABS ── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--navy);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

.tab-panel {
  animation: fadeIn 0.2s ease;
}

.tab-panel.hidden {
  display: none;
}

/* ── SCHEDULE v2 — chips & pills ── */
.tt-chip {
  padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border); background: var(--white); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s; white-space: nowrap; font-family: 'DM Sans', sans-serif;
}
.tt-chip:hover { border-color: var(--teal); color: var(--teal); }
.tt-chip-active { border-color: var(--teal) !important; background: var(--teal-pale) !important; color: var(--teal) !important; }
.tt-visit-pill:hover { box-shadow: 0 2px 8px rgba(15,31,61,0.12); }
.tt-visit-pill[draggable="true"]:active { cursor: grabbing; }

/* ── AVAILABILITY RULES v2 ── */
.avail-btn { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; border: 0.5px solid var(--color-border-secondary); background: none; color: var(--color-text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-family: 'DM Sans', sans-serif; white-space: nowrap; }
.avail-btn:hover { border-color: var(--teal); color: var(--teal); }
.avail-btn.avail-set { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); }
.day-toggle { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--color-border-secondary); background: var(--color-background-secondary); font-size: 12px; font-weight: 500; color: var(--color-text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer !important; transition: all 0.15s; user-select: none; }
.day-toggle.avail-on { background: #e6faf8 !important; color: #065f56 !important; border-color: #0d9488 !important; }
.pill-conflict { background: #fffbeb !important; border-left-color: #f59e0b !important; color: #92400e !important; }
.conflict-badge { font-size: 9px; font-weight: 600; color: #b45309; background: #fef3c7; border-radius: 3px; padding: 1px 4px; display: inline-block; margin-top: 2px; }
.avail-stripe-row { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); height: 4px; margin: 0; }
.avail-stripe-cell { height: 4px; transition: background 0.2s; }
.stripe-avail { background: rgba(13,148,136,0.3); }
.stripe-unavail { background: rgba(245,158,11,0.35); }
.stripe-neutral { background: transparent; }

/* ── MOBILE FIXES ── */
@media (max-width: 768px) {
  /* Push content below fixed mobile header */
  #main-content {
    margin-left: 0 !important;
    padding: 72px 16px 32px 16px !important;
  }

  /* Make all tables horizontally scrollable */
  .table-wrap, .table-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 500px;
  }

  /* Stack form grids to single column */
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Stack stat rows */
  .stats-row {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Page header stacks */
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  /* Tab bar scrollable */
  .tab-bar {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 4px;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Modals full width */
  .modal {
    width: 95vw !important;
    max-width: 95vw !important;
    margin: 0 auto;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Invoice cards don't overflow */
  .invoice-card, .table-card {
    overflow-x: auto !important;
  }

  /* Rate cards stack */
  .rate-grid {
    grid-template-columns: 1fr !important;
  }

  /* Toolbar wraps */
  .toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Filters wrap */
  .filters {
    flex-wrap: wrap !important;
  }

  /* Week nav wraps on schedule */
  #sched-my > div:first-child,
  #sched-overview > div:first-child {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Auth screen padding */
  #screen-auth {
    padding: 16px !important;
  }

  .auth-card {
    padding: 24px 20px !important;
  }
}

@media (max-width: 400px) {
  #main-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .stats-row {
    grid-template-columns: 1fr !important;
  }

  h1 { font-size: 20px !important; }
}
