:root {
  --bg-main: #f7f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f3eff7;
  --bg-stage-active: #f1ecf7;
  --accent-purple: #7852a9;
  --accent-purple-light: #ece4f5;
  --accent-dark: #2c2538;
  --accent-green: #377154;
  --accent-green-bg: #e5f3eb;
  --text-primary: #1f1b24;
  --text-secondary: #7e758a;
  --text-muted: #a69fb0;
  --border-subtle: #ede7f2;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(35, 20, 50, 0.04);
  --shadow-md: 0 6px 20px rgba(35, 20, 50, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  padding-bottom: 84px;
}

#app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  position: relative;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  padding: 16px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.05);
}

/* Screens / Tabs */
.screen-view {
  display: none;
  padding: 8px 18px 24px;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease-in-out;
}

.screen-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Header */
.screen-heading {
  margin-bottom: 4px;
}

.screen-overline {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.screen-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.screen-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* User Greeting Avatar */
.greeting-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mascot-avatar {
  width: 52px;
  height: 52px;
  background: #fdf5f2;
  border-radius: 50%;
  border: 2px solid #ecd8d2;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pill-mascot {
  width: 24px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(to bottom, #ffebd8 50%, #9b72cf 50%);
  border: 2px solid #3d2f47;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mascot-eyes {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.mascot-eye {
  width: 3px;
  height: 4px;
  background: #2b2233;
  border-radius: 50%;
}

.mascot-mouth {
  width: 6px;
  height: 3px;
  border-bottom: 2px solid #2b2233;
  border-radius: 0 0 4px 4px;
  margin-top: 2px;
}

/* Main Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  position: relative;
}

/* Focus Action Card (Today) */
.focus-card {
  background: #ffffff;
  padding: 22px;
  border: 1px solid #e7deee;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.focus-card::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(235, 222, 248, 0.4) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

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

.status-badge-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
}

.status-badge-text.pending {
  color: var(--accent-purple);
}

.focus-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-dark);
}

.focus-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-dark);
  line-height: 1.1;
  margin-bottom: 4px;
}

.focus-dosage {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 12px;
}

.focus-stage-pill {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-purple);
  margin-bottom: 18px;
}

/* Buttons */
.focus-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-primary-action {
  flex: 1;
  padding: 13px 20px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-subtle);
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary-action:active {
  transform: scale(0.98);
}

.btn-primary-action.taken {
  background: #fbf9fc;
  color: #4b4155;
}

.btn-primary-action.ready {
  background: var(--accent-purple);
  color: #ffffff;
  border-color: var(--accent-purple);
  box-shadow: 0 4px 14px rgba(120, 82, 169, 0.3);
}

.btn-icon-more {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-subtle);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Section Title */
.block-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.block-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.block-overline {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.block-heading {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-dark);
}

.count-badge {
  background: #eee8f5;
  color: var(--accent-purple);
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* List Items */
.list-card-item {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s;
}

.list-card-item:active {
  transform: scale(0.99);
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-dark);
}

.item-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.chevron-icon {
  color: #b0a8bb;
  font-size: 18px;
}

/* Schedule Row Card */
.schedule-item {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.sched-time {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-dark);
}

.sched-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sched-pill-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-dark);
}

.sched-pill-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.sched-status-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-green);
}

.sched-status-tag.pending {
  color: var(--accent-purple);
}

/* Therapy Detail Page */
.pill-hero-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  position: relative;
}

.pill-big-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: #f1ecf7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 14px;
  color: var(--accent-purple);
}

.pill-hero-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent-dark);
  margin-bottom: 4px;
}

.pill-hero-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pill-hero-badge {
  background: #eeeaef;
  color: #6a5e77;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
}

/* Stage Card (by user screenshot) */
.scheme-summary-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scheme-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scheme-label {
  font-size: 15px;
  color: var(--text-secondary);
}

.scheme-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-dark);
}

.stage-step-card {
  background: #f4eff8;
  border: 1px solid #e5dbe9;
  border-radius: var(--radius-xl);
  padding: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-step-card.active-stage {
  border: 1.5px solid #d5c2e8;
  box-shadow: 0 4px 14px rgba(120, 82, 169, 0.08);
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-overline {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.stage-badge-now {
  background: #eadff5;
  color: #634386;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.stage-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-dark);
}

.stage-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stage-cell {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stage-cell-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.stage-cell-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-dark);
}

/* History & Calendar View */
.calendar-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.cal-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-month-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-dark);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  text-align: center;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-dark);
  position: relative;
  cursor: pointer;
}

.cal-day-cell.taken {
  background: #3f6e56;
  color: #ffffff;
  font-weight: 700;
}

.cal-day-cell.planned {
  border: 1.5px solid #84679d;
  color: var(--accent-dark);
}

.cal-day-cell.empty {
  visibility: hidden;
}

/* Metrics Row */
.metrics-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-big {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-dark);
}

.metric-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.progress-strip-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar-bg {
  height: 6px;
  background: #e8e2ee;
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #6b4d89, #4b7a64);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

/* Doctor Report Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 14, 25, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  border-radius: 28px 28px 0 0;
  padding: 24px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.report-text-area {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #fbf9fc;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--accent-dark);
  resize: none;
}

/* Bottom Tab Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: 72px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

.nav-tab {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  position: relative;
  transition: all 0.15s ease;
}

.nav-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.nav-tab.active {
  color: var(--accent-dark);
  background: #f0ebf5;
  font-weight: 700;
}

/* Prescription Import & Preset Styles */
.med-switcher-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  scrollbar-width: none;
}

.med-switcher-row::-webkit-scrollbar {
  display: none;
}

.med-chip {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  background: #ede6f5;
  color: #5c3c80;
  border: 1.5px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.med-chip.active {
  background: var(--accent-purple);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(120, 82, 169, 0.25);
}

.med-chip.add-btn {
  background: #ffffff;
  color: var(--accent-purple);
  border: 1.5px dashed #cbb7e0;
}

.preset-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.preset-tag {
  background: #f1ecf7;
  color: #4b3263;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #dfd3eb;
  transition: background 0.15s;
}

.preset-tag:hover {
  background: #e2d3ee;
}

.parsed-preview-box {
  background: #f7f3fb;
  border: 1px solid #e0d2ee;
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.parsed-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-dark);
}

.parsed-step-row {
  font-size: 12px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #e3daed;
  padding-bottom: 4px;
}

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

/* User Telegram Consent & ID banner */
.tg-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #edf5f0;
  border: 1px solid #d2e7d9;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: #276241;
  font-weight: 600;
}

.tg-profile-badge svg {
  flex-shrink: 0;
}

/* Edit & Delete Styles */
.btn-danger {
  background: #fff0f0;
  color: #c93b3b;
  border: 1.5px solid #fcdcdc;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}

.btn-danger:active {
  background: #fde2e2;
  transform: scale(0.98);
}

.btn-secondary {
  background: #f5f2f8;
  color: var(--accent-dark);
  border: 1.5px solid #e5dde9;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.scheme-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.scheme-card-actions > button {
  flex: 1;
}

.input-custom {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #fdfcfe;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input-custom:focus {
  border-color: var(--accent-purple);
}

.date-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
}

.date-picker-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.date-picker-row input {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  background: #ffffff;
}

.editable-stage-item {
  background: #ffffff;
  border: 1px solid #e7dfea;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.stage-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-item-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.stage-item-inputs input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e2d9e7;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
}

.btn-remove-stage {
  background: none;
  border: none;
  color: #c93b3b;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-remove-stage:hover {
  background: #fde8e8;
}

.btn-add-step {
  padding: 8px 14px;
  border: 1.5px dashed #c0aed5;
  border-radius: var(--radius-md);
  background: #fcfbfe;
  color: var(--accent-purple);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}


