/* ═══════════════════════════════════════════════════════════════
   MediScript — Premium Medical UI  v3
   Mobile-first · Telegram Web App · Clinical SaaS style
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  /* Brand */
  --blue-50:   #eff6ff;
  --blue-100:  #dbeafe;
  --blue-500:  #3b82f6;
  --blue-600:  #2563eb;
  --blue-700:  #1d4ed8;
  --blue-800:  #1e40af;

  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-600: #16a34a;

  --red-50:    #fef2f2;
  --red-100:   #fee2e2;
  --red-500:   #ef4444;
  --red-600:   #dc2626;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;

  --purple-50:  #faf5ff;
  --purple-500: #a855f7;

  /* Neutrals */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic */
  --primary:       var(--blue-600);
  --primary-dark:  var(--blue-700);
  --primary-light: var(--blue-50);
  --success:       var(--green-500);
  --danger:        var(--red-600);
  --warning:       var(--amber-500);

  --bg:        var(--slate-50);
  --surface:   #ffffff;
  --border:    var(--slate-200);
  --text:      var(--slate-800);
  --text-2:    var(--slate-600);
  --text-3:    var(--slate-400);

  /* Layout */
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --bottom-tab-h:  65px; /* ← tab bar height — CHANGED */
  --max-w:         1200px;

  /* Radii */
  --r-sm:  8px;
  --r:     12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 24px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 6px rgba(15,23,42,.05), 0 2px 4px rgba(15,23,42,.04);
  --shadow-md: 0 8px 16px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 20px 40px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.06);
  --shadow-blue: 0 8px 24px rgba(37,99,235,.28);
  --shadow-green: 0 8px 24px rgba(34,197,94,.28);

  --t: 0.18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
input, select, textarea, button { font-family: inherit; }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR  (desktop ≥ 769px)
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--slate-900);
  display: flex;
  flex-direction: column;
  z-index: 400;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t), box-shadow var(--t);
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-blue);
}
.logo-text { font-size: 17px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--slate-400); cursor: pointer; font-size: 20px; padding: 4px; border-radius: 6px; transition: color var(--t); }
.sidebar-toggle:hover { color: #fff; }

.sidebar-doctor {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.doctor-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.doctor-info { overflow: hidden; }
.doctor-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doctor-spec { font-size: 11px; color: var(--slate-500); margin-top: 1px; }

.sidebar-nav { list-style: none; padding: 12px 12px; flex: 1; }
.nav-item + .nav-item { margin-top: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--slate-400);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--t), color var(--t);
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active .nav-link {
  background: rgba(37,99,235,.25);
  color: #fff;
  font-weight: 600;
}
.nav-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; opacity: .8; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer { padding: 14px 14px 20px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.btn-new-rx {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--blue-600);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 700;
  transition: background var(--t), box-shadow var(--t);
  width: 100%;
}
.btn-new-rx:hover { background: var(--blue-700); box-shadow: var(--shadow-blue); color: #fff; }
.btn-logout {
  display: block; width: 100%; margin-top: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.10);
  color: var(--slate-500); padding: 8px;
  border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  transition: all var(--t);
}
.btn-logout:hover { background: rgba(255,255,255,.06); color: var(--slate-300); }

/* ── Sidebar backdrop ───────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 399;
  opacity: 0;
  transition: opacity var(--t);
}
.sidebar-backdrop.visible { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   MAIN WRAPPER
   ═══════════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}
.topbar-toggle { display: none; background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-2); padding: 6px; border-radius: var(--r-sm); transition: background var(--t); }
.topbar-toggle:hover { background: var(--slate-100); }
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; color: var(--text); }
.topbar-actions { display: flex; gap: 8px; }

/* ── Content ────────────────────────────────────────────────── */
.main-content { padding: 24px; flex: 1; }

/* ── Messages ───────────────────────────────────────────────── */
.messages-container { padding: 12px 24px 0; }
.alert {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; padding: 13px 16px; border-radius: var(--r-sm);
  margin-bottom: 10px; font-size: 14px; border: 1px solid;
  animation: fadeSlideDown .2s ease;
}
@keyframes fadeSlideDown {
  from { opacity:0; transform: translateY(-6px); }
  to   { opacity:1; transform: translateY(0); }
}
.alert-success { background: var(--green-50);  border-color: var(--green-100); color: var(--green-600); }
.alert-error,
.alert-danger  { background: var(--red-50);    border-color: var(--red-100);   color: var(--red-600);   }
.alert-warning { background: var(--amber-50);  border-color: var(--amber-100); color: #92400e; }
.alert-info    { background: var(--blue-50);   border-color: var(--blue-100);  color: var(--blue-700);  }
.alert-close { background: none; border: none; cursor: pointer; opacity: .45; font-size: 16px; line-height: 1; flex-shrink: 0; transition: opacity var(--t); }
.alert-close:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--slate-50);
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.card-link { font-size: 13px; color: var(--primary); font-weight: 600; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════ */
.dash-hero {
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-600) 60%, #3b82f6 100%);
  border-radius: var(--r-xl);
  padding: 28px 24px 24px;
  margin-bottom: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.dash-hero::before {
  content: '';
  position: absolute; top: -40px; right: -30px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.07);
  border-radius: 50%;
}
.dash-hero::after {
  content: '';
  position: absolute; bottom: -50px; right: 40px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}
.dash-greeting { font-size: 13px; opacity: .75; font-weight: 500; margin-bottom: 4px; }
.dash-title    { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.dash-subtitle { font-size: 13px; opacity: .70; margin-top: 4px; }
.dash-stats-row {
  display: flex; gap: 12px; margin-top: 20px; position: relative; z-index: 1;
}
.dash-stat {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--r);
  padding: 12px 16px;
  flex: 1; min-width: 0;
}
.dash-stat-val  { font-size: 26px; font-weight: 800; line-height: 1; }
.dash-stat-lbl  { font-size: 11px; opacity: .75; margin-top: 2px; font-weight: 500; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 16px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.quick-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--blue-200, #bfdbfe); color: var(--text); text-decoration: none; }
.qa-icon {
  width: 44px; height: 44px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.qa-blue  .qa-icon { background: var(--blue-50);  }
.qa-green .qa-icon { background: var(--green-50); }
.qa-label { font-size: 14px; font-weight: 700; }
.qa-desc  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Recent section ─────────────────────────────────────────── */
.section-title {
  font-size: 13px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}
.section-link { font-size: 12px; color: var(--primary); font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ═══════════════════════════════════════════════════════════════
   PATIENT CARDS
   ═══════════════════════════════════════════════════════════════ */
.patient-list { display: flex; flex-direction: column; gap: 10px; }
.patient-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t), border-color var(--t);
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.patient-card:hover { box-shadow: var(--shadow); border-color: var(--slate-300); color: inherit; text-decoration: none; }
.patient-initials {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.patient-initials.female { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.patient-initials.other  { background: linear-gradient(135deg, var(--amber-500), #d97706); }
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.patient-arrow { color: var(--slate-300); font-size: 18px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   STATS GRID (legacy dashboard)
   ═══════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-xs);
}
.stat-icon-wrap {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-blue   .stat-icon-wrap { background: var(--blue-50);   }
.stat-green  .stat-icon-wrap { background: var(--green-50);  }
.stat-orange .stat-icon-wrap { background: var(--amber-50);  }
.stat-purple .stat-icon-wrap { background: var(--purple-50); }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
/* keep legacy icon selector working */
.stat-icon  { font-size: 20px; }
.stat-body  { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 14px; min-width: 500px;
}
.table th {
  padding: 10px 16px;
  background: var(--slate-50);
  text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-hover tbody tr { transition: background var(--t); }
.table-hover tbody tr:hover td { background: var(--blue-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .02em; white-space: nowrap;
}
.badge-blue     { background: var(--blue-100);  color: var(--blue-700);  }
.badge-green    { background: var(--green-100); color: var(--green-600); }
.badge-red      { background: var(--red-100);   color: var(--red-600);   }
.badge-amber    { background: var(--amber-100); color: #92400e;          }
.badge-category { background: var(--purple-50); color: var(--purple-500);}
.badge-gender   { background: var(--blue-50);   color: var(--blue-600);  }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all var(--t);
  white-space: nowrap;
  min-height: 42px;
  line-height: 1;
  -webkit-user-select: none; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.975); }

.btn-primary       { background: var(--blue-600);  color:#fff; border-color: var(--blue-600); }
.btn-primary:hover { background: var(--blue-700);  box-shadow: var(--shadow-blue); color:#fff; }

.btn-success       { background: var(--green-500); color:#fff; border-color: var(--green-500); }
.btn-success:hover { background: var(--green-600); box-shadow: var(--shadow-green); color:#fff; }

.btn-outline       { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--blue-50); border-color: var(--blue-500); }

.btn-ghost         { background: var(--slate-100); color: var(--text-2); border-color: transparent; }
.btn-ghost:hover   { background: var(--slate-200); color: var(--text); }

.btn-danger        { background: var(--red-600);   color:#fff; border-color: var(--red-600); }
.btn-danger:hover  { background: #b91c1c; color:#fff; }

.btn-danger-outline { background: transparent; color: var(--red-600); border-color: var(--red-100); }
.btn-danger-outline:hover { background: var(--red-50); border-color: var(--red-500); }

.btn-sm  { padding: 7px 14px; font-size: 12px; min-height: 34px; border-radius: var(--r-sm); }
.btn-lg  { padding: 14px 28px; font-size: 16px; min-height: 52px; border-radius: var(--r-lg); }
.btn-xl  { padding: 16px 28px; font-size: 16px; min-height: 56px; border-radius: var(--r-lg); width: 100%; }
.btn-block { width: 100%; }
.btn-icon  { padding: 9px; min-height: 40px; min-width: 40px; }

/* Sticky submit row */
.sticky-actions {
  position: sticky; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  margin: 0 -20px -20px;
  display: flex; gap: 10px;
  box-shadow: 0 -4px 16px rgba(15,23,42,.08);
}

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */
.form-group  { margin-bottom: 18px; }
.form-label  {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 7px;
}
.form-control {
  display: block; width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  min-height: 46px;
}
.form-control:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--slate-500); } /* ← placeholder rangi — CHANGED */
select.form-control {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%2394a3b8' d='M7 9.5L2 4.5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}
textarea.form-control { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-error { display: block; font-size: 12px; color: var(--red-600); margin-top: 5px; font-weight: 600; }
.form-hint  { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 0; }
.form-row .col-3  { flex: 0 0 calc(25% - 10.5px); min-width: 0; }
.form-row .col-4  { flex: 0 0 calc(33.33% - 9.5px); min-width: 0; }
.form-row .col-6  { flex: 0 0 calc(50% - 7px); min-width: 0; }
.form-row .col-8  { flex: 0 0 calc(66.67% - 5px); min-width: 0; }
.form-row .col-12 { flex: 0 0 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.form-card { max-width: 760px; }

/* ── Section card inside form ───────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.form-section-header {
  padding: 14px 20px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.form-section-title {
  font-size: 13px; font-weight: 700;
  color: var(--text); text-transform: uppercase; letter-spacing: .04em;
}
.form-section-body { padding: 20px; }

/* ═══════════════════════════════════════════════════════════════
   DRUG ROW (prescription form)
   ═══════════════════════════════════════════════════════════════ */
.drug-row {
  background: var(--slate-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--t);
}
.drug-row:focus-within { border-color: var(--blue-500); }
.drug-row-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.drug-row-num { font-size: 11px; font-weight: 800; color: var(--blue-600); text-transform: uppercase; letter-spacing: .06em; }
.delete-label { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--red-600); cursor: pointer; }

/* ═══════════════════════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════════════════════ */
.search-wrap {
  position: relative; margin-bottom: 16px;
}
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--slate-400); font-size: 16px; pointer-events: none;
}
.search-input-field {
  display: block; width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 15px; color: var(--text);
  background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none; min-height: 46px;
}
.search-input-field:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-input-field::placeholder { color: var(--slate-500); } /* ← placeholder rangi — CHANGED */

/* keep legacy class working */
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 160px; }
.form-control.search-input { border-radius: var(--r-lg); }

/* ═══════════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════════ */
.pagination-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-info { font-size: 13px; color: var(--text-2); flex: 1; text-align: center; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--text-2);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .35; display: block; }
.empty-state p { margin-bottom: 16px; font-size: 15px; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════
   PROFILE / DETAIL GRIDS
   ═══════════════════════════════════════════════════════════════ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.profile-field { display: flex; flex-direction: column; gap: 4px; }
.profile-field-wide { grid-column: 1/-1; }
.field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.field-value { font-size: 15px; color: var(--text); line-height: 1.5; }

.rx-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rx-header-card .rx-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.rx-number { font-size: 20px; font-weight: 800; color: var(--primary); }
.rx-date   { font-size: 14px; color: var(--text-2); }
.rx-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.diagnosis-text { font-size: 15px; line-height: 1.8; white-space: pre-wrap; }
.notes-text { font-size: 13px; margin-top: 10px; color: var(--text-2); white-space: pre-wrap; }
.rx-action-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════ */
.text-muted    { color: var(--text-2) !important; }
.text-center   { text-align: center; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-block       { display: block; }
.actions-cell  { white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: 4px; }
.patient-name-link { font-weight: 700; color: var(--text); }
.patient-name-link:hover { color: var(--primary); }
.dashboard-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ═══════════════════════════════════════════════════════════════
   AUTH
   ═══════════════════════════════════════════════════════════════ */
.auth-page    { background: linear-gradient(160deg, var(--slate-900) 0%, var(--blue-800) 100%); min-height: 100vh; }
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  padding: 44px 40px; width: 100%; max-width: 400px;
}
.auth-logo        { text-align: center; margin-bottom: 36px; }
.logo-icon-lg     {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  border-radius: var(--r-xl); font-size: 36px; margin-bottom: 16px;
  box-shadow: var(--shadow-blue);
}
.auth-title    { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -.4px; }
.auth-subtitle { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.auth-form .form-group { margin-bottom: 20px; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 24px; line-height: 1.7; }

/* ═══════════════════════════════════════════════════════════════
   BOTTOM TAB BAR  (mobile)
   ═══════════════════════════════════════════════════════════════ */
.bottom-tabs {
  display: flex; gap: 30px; justify-content: space-evenly ;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-tab-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 0 rgba(15,23,42,.06);
  z-index: 400;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-tabs-inner { display: flex; height: 100%; }
.bottom-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;           /* ← icon va label orasidagi bo'shliq — CHANGED */
  color: var(--text-3); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  text-decoration: none;
  padding: 8px 16px;  /* ← gorizontal padding — CHANGED */
  position: relative; transition: color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.bottom-tab:hover { color: var(--primary); text-decoration: none; }
.bottom-tab.active { color: var(--primary); }
.bottom-tab.active::after {
  content: '';
  position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 3px; background: var(--primary);
  border-radius: 3px 3px 0 0;
}
.bottom-tab-icon { display: flex; align-items: center; justify-content: center;  }

/* FAB */
.fab {
  display: none;
  position: fixed;
  bottom: calc(var(--bottom-tab-h) + 14px); right: 18px;
  width: 52px; height: 52px;
  background: var(--blue-600); color: #fff;
  border-radius: 50%; font-size: 28px;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-blue);
  text-decoration: none; z-index: 390;
  transition: transform var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(37,99,235,.4); color: #fff; text-decoration: none; }
.fab:active { transform: scale(.95); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  ≤ 1024px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-cols { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  ≤ 768px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }

  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  /* sidebar-backdrop visibility is controlled by JS only */
  .sidebar-toggle { display: flex; }

  .main-wrapper { margin-left: 0; padding-bottom: var(--bottom-tab-h); }

  .topbar { padding: 0 16px; }
  .topbar-toggle { display: flex; }
  .topbar-title { font-size: 15px; }
  .topbar-actions .btn { padding: 8px 14px; font-size: 13px; }

  .bottom-tabs { display: flex; }
  .fab { display: flex; }

  .main-content { padding: 16px; }
  .messages-container { padding: 10px 16px 0; }

  /* Cards */
  .card { border-radius: var(--r); margin-bottom: 12px; }
  .card-header { padding: 13px 16px; }
  .card-body { padding: 16px; }
  .form-section-body { padding: 16px; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 22px; }

  /* Dashboard */
  .dash-hero { padding: 22px 18px 20px; border-radius: var(--r-lg); }
  .dash-title { font-size: 19px; }
  .dash-stats-row { gap: 8px; }
  .quick-actions { grid-template-columns: 1fr 1fr; gap: 10px; }
  .qa-icon { width: 38px; height: 38px; font-size: 18px; }
  .qa-label { font-size: 13px; }

  /* Profile / RX */
  .profile-grid { grid-template-columns: 1fr; gap: 14px; }
  .rx-cols { grid-template-columns: 1fr; }
  .rx-action-row { flex-direction: column; }
  .rx-action-row .btn { width: 100%; }
  .rx-number { font-size: 17px; }

  /* Tables */
  .card-body.p-0 { overflow-x: auto; }
  .table { min-width: 480px; }
  .table th, .table td { padding: 10px 12px; }

  /* Forms */
  .form-row { flex-direction: column; gap: 0; }
  .form-row .col-3, .form-row .col-4,
  .form-row .col-6, .form-row .col-8 { flex: none; width: 100%; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .form-card { max-width: 100%; }
  .sticky-actions { padding: 12px 16px; margin: 0 -16px -16px; }

  /* Auth */
  .auth-card { padding: 32px 24px; border-radius: var(--r-xl); }
  .logo-icon-lg { width: 60px; height: 60px; font-size: 28px; }

  /* Drug rows */
  .drug-row { padding: 13px; }

  /* Search */
  .search-form { flex-direction: column; }
  .search-input { max-width: 100%; }

  /* Actions */
  .actions-cell { white-space: normal; }
  .actions-cell .btn { margin-bottom: 4px; }
}

@media (max-width: 400px) {
  .quick-actions { grid-template-columns: 1fr; }
  .dash-stats-row { flex-direction: column; gap: 6px; }
  .dash-stat { padding: 10px 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD v5  — Premium mobile-first
   ═══════════════════════════════════════════════════════════════ */

/* ── Page-level overrides ───────────────────────────────────── */
.dash-page .topbar { display: none !important; }
.dash-page .fab    { display: none !important; }
.dash-page .main-content { padding: 0; }

/* ── Compact header ─────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
}
.dash-greeting {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 2px;
}
.dash-doctor {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  line-height: 1.2;
}
.dash-avatar {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,.30);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.dash-avatar:hover { opacity: .85; }

/* ── CTA buttons ────────────────────────────────────────────── */
.dash-cta {
  padding: 6px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-cta-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 54px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: var(--r-lg);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.1px;
  text-decoration: none;
  box-shadow: var(--shadow-blue);
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
}
.btn-cta-primary:hover  { background: var(--blue-700); color: #fff; text-decoration: none; }
.btn-cta-primary:active { transform: scale(.98); box-shadow: 0 3px 10px rgba(37,99,235,.25); }

.btn-cta-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: var(--blue-50);
  color: var(--blue-600);
  border: 1.5px solid var(--blue-100);
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background var(--t), border-color var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
}
.btn-cta-secondary:hover  { background: var(--blue-100); border-color: var(--blue-500); color: var(--blue-700); text-decoration: none; }
.btn-cta-secondary:active { transform: scale(.98); }

/* ── Section heading ────────────────────────────────────────── */
.dash-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 10px;
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.dash-section a {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Quick access 2×2 grid ─────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px;
}
.dash-grid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--t), transform var(--t);
  -webkit-tap-highlight-color: transparent;
}
.dash-grid-card:hover  { box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none; }
.dash-grid-card:active { transform: scale(.97); }

.dgc-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dgc-blue   .dgc-icon { background: var(--blue-50);   }
.dgc-green  .dgc-icon { background: var(--green-50);  }
.dgc-amber  .dgc-icon { background: var(--amber-50);  }
.dgc-purple .dgc-icon { background: var(--purple-50); }

.dgc-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dgc-count {
  font-size: 20px; font-weight: 800; color: var(--text);
  letter-spacing: -.5px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.dgc-label {
  font-size: 11px; color: var(--text-2); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Recent Rx (card wrapper) ───────────────────────────────── */
.rx-card {
  margin: 0 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.rx-list { display: flex; flex-direction: column; }
.rx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  text-decoration: none;
  color: inherit;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
}
.rx-row + .rx-row { border-top: 1px solid var(--slate-100); }
.rx-row:hover { text-decoration: none; color: inherit; }
.rx-row:active { background: var(--slate-50); }

.rx-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.rx-row-body { flex: 1; min-width: 0; }
.rx-row-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-row-diag { font-size: 12px; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-row-date { font-size: 11px; color: var(--text-3); flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Stats row at bottom ────────────────────────────────────── */
.dash-stats-bottom {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 20px;
}
.dsb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-xs);
}
.dsb-val { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.dsb-lbl { font-size: 10px; color: var(--text-3); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

@media (max-width: 400px) {
  .dash-grid { gap: 8px; padding: 0 16px; }
  .dash-grid-card { padding: 12px 10px; min-height: 66px; }
  .dgc-icon { width: 36px; height: 36px; border-radius: 8px; }
  .dgc-count { font-size: 18px; }
  .dash-stats-bottom { grid-template-columns: repeat(2, 1fr); padding: 0 16px; }
  .btn-cta-primary  { height: 50px; font-size: 15px; }
  .btn-cta-secondary { height: 46px; }
}

/* ═══════════════════════════════════════════════════════════════
   LANGUAGE SWITCHER  — CHANGED
   ═══════════════════════════════════════════════════════════════ */
.lang-sw {
  position: relative;
  flex-shrink: 0;
}
.lang-sw-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  transition: background var(--t), border-color var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.lang-sw-btn:hover { background: var(--slate-100); border-color: var(--slate-300); color: var(--text); }
.lang-sw-code { font-variant-numeric: tabular-nums; }

.lang-sw-drop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  min-width: 100px;
  z-index: 500;
  overflow: hidden;
  animation: fadeSlideDown .14s ease;
}
.lang-sw-drop form { display: flex; flex-direction: column; }
.lang-sw.open .lang-sw-drop { display: block; }

.lang-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.lang-opt:hover    { background: var(--slate-50); color: var(--text); }
.lang-opt--active  { color: var(--primary); background: var(--blue-50); }
.lang-opt-flag     { font-size: 16px; line-height: 1; }

/* Topbar ichida compact ko'rinish */
.topbar .lang-sw { margin-left: 4px; }

/* ═══════════════════════════════════════════════════════════════
   SWIPE NAVIGATION HINT  — CHANGED
   ═══════════════════════════════════════════════════════════════ */
.swipe-nav-hint {
  position: fixed;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  width: 44px; height: 44px;
  background: rgba(37,99,235,.12);
  border: 1.5px solid rgba(37,99,235,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue-600);
  opacity: 0;
  pointer-events: none;
  z-index: 600;
  transition: opacity .15s ease, transform .15s ease;
}
.swipe-nav-hint--left  { left: 10px; }
.swipe-nav-hint--right { right: 10px; }
.swipe-nav-hint--visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .bottom-tabs, .fab,
  .messages-container, .sidebar-backdrop,
  .topbar-actions, .rx-action-row,
  .search-form, .pagination-bar { display: none !important; }
  .main-wrapper { margin-left: 0 !important; padding-bottom: 0 !important; }
  .card { box-shadow: none !important; border-color: #ccc !important; }
}

/* ═══════════════════════════════════════════════════════════════
   TELEGRAM CONTACT PICKER MODAL  — CHANGED
   ═══════════════════════════════════════════════════════════════ */
.tg-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 900;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.tg-modal-overlay.open { display: flex; }

.tg-modal {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpSheet .22s cubic-bezier(.34,1.06,.64,1);
}
@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.tg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tg-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.tg-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: var(--r-sm);
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t);
}
.tg-modal-close:hover { background: var(--slate-100); }

.tg-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0;
}

.tg-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 10px;
  background: var(--slate-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
}
.tg-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.tg-search input::placeholder { color: var(--slate-400); }

.tg-contacts { padding: 0 6px; }

.tg-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  background: none;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.tg-contact-item:hover,
.tg-contact-item:active { background: var(--slate-50); }
.tg-contact-item.selected { background: var(--blue-50); }

.tg-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--slate-200);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tg-av-blue  { background: var(--blue-100);  color: var(--blue-700); }
.tg-av-green { background: #dcfce7; color: #166534; }

.tg-contact-info { flex: 1; min-width: 0; }
.tg-contact-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-contact-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 1px;
}

.tg-contact-check {
  flex-shrink: 0;
  display: none;
}
.tg-contact-item.selected .tg-contact-check { display: block; }

.tg-manual {
  margin: 10px 14px 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tg-manual-label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
  margin-bottom: 6px;
}
.tg-manual input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 14px;
  color: var(--text);
  background: var(--slate-50);
  outline: none;
  transition: border-color var(--t);
  box-sizing: border-box;
}
.tg-manual input:focus { border-color: var(--primary); background: #fff; }

.tg-modal-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tg-selected-info {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.tg-send-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t), opacity var(--t);
  -webkit-tap-highlight-color: transparent;
}
.tg-send-btn:disabled { opacity: .45; cursor: not-allowed; }
.tg-send-btn:not(:disabled):hover { background: var(--blue-700); }

.tg-modal-hint {
  font-size: 12px;
  color: var(--text-2);
  margin: 8px 0 0;
  text-align: center;
  line-height: 1.4;
}
.tg-modal-hint a { color: var(--primary); }

/* ── Telegram modal: username input + desc — CHANGED ── */
.tg-username-wrap {
  display: flex;
  align-items: center;
  margin: 0 14px 4px;
  background: var(--slate-50);
  border: 2px solid var(--primary);
  border-radius: var(--r);
  padding: 10px 12px;
  gap: 4px;
}
.tg-username-prefix {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  flex-shrink: 0;
}
.tg-username-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}
.tg-username-wrap input::placeholder { color: var(--slate-400); font-weight: 400; }

.tg-contacts-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  padding: 10px 16px 4px;
}

.tg-desc-wrap {
  margin-bottom: 10px;
}
.tg-desc-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 14px;
  color: var(--text);
  background: var(--slate-50);
  outline: none;
  resize: none;
  transition: border-color var(--t);
  box-sizing: border-box;
  font-family: inherit;
}
.tg-desc-input:focus { border-color: var(--primary); background: #fff; }
.tg-desc-input::placeholder { color: var(--slate-400); }

/* ═══════════════════════════════════════════════════════════════
   SHARE BOTTOM SHEET
   ═══════════════════════════════════════════════════════════════ */
.share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 900;
  align-items: flex-end;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.share-overlay.open { display: flex; }

.share-sheet {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 520px;
  padding: 0 0 max(20px, env(safe-area-inset-bottom)) 0;
  animation: slideUpSheet .2s cubic-bezier(.34,1.06,.64,1);
}

.share-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
}

.share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.share-rx-num  { font-size: 15px; font-weight: 800; color: var(--text); }
.share-rx-sub  { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.share-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--slate-100);
  border: none; border-radius: 50%;
  cursor: pointer; color: var(--text-2);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.share-close:active { background: var(--slate-200); }

.share-options { padding: 10px 14px 6px; display: flex; flex-direction: column; gap: 8px; }

.share-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t), border-color var(--t), transform .1s;
  min-height: 72px;
}
.share-option:active { transform: scale(.98); background: var(--slate-50); }

.share-option-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.share-icon-tg   { background: #e8f3ff; color: #2563eb; }
.share-icon-copy { background: var(--slate-100); color: var(--text-2); }

.share-option-text { flex: 1; min-width: 0; }
.share-option-title { font-size: 15px; font-weight: 700; color: var(--text); }
.share-option-sub   { font-size: 12px; color: var(--text-2); margin-top: 3px; word-break: break-all; }

.share-option-arrow { color: var(--slate-300); flex-shrink: 0; }

.share-copy-badge {
  display: none;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}
.share-copy-badge.show { display: block; }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR PROFILE DROPDOWN
   ═══════════════════════════════════════════════════════════════ */
.topbar-profile {
  position: relative;
  flex-shrink: 0;
  margin-left: 6px;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.topbar-avatar:hover { opacity: .85; }

.topbar-profile-drop {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 600;
  overflow: hidden;
  animation: fadeSlideDown .14s ease;
}
.topbar-profile.open .topbar-profile-drop { display: block; }

.topbar-profile-name {
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: #ef4444;
  cursor: pointer;
  text-align: left;
  transition: background var(--t);
  -webkit-tap-highlight-color: transparent;
}
.topbar-logout-btn:hover { background: #fef2f2; }

/* ── Dashboard profile dropdown ── */
.dash-profile {
  position: relative;
}
.dash-profile-drop {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 600;
  overflow: hidden;
  animation: fadeSlideDown .14s ease;
}
.dash-profile.open .dash-profile-drop { display: block; }
.dash-profile-name {
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
