/* ==========================================================================
   KOLOBOK VPN // DASHBOARD (ЛИЧНЫЙ КАБИНЕТ) STYLES
   Material Design 3 (Material You) Responsive UI
   ========================================================================== */

/* Dashboard Layout & Overflow Protection */
html, body.dashboard-page {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  position: relative;
  box-sizing: border-box;
}

.dashboard-page {
  background-color: var(--md-background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.dashboard-main {
  flex: 1;
  padding: 5.5rem 0 3.5rem; /* Accounts for fixed top-app-bar */
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Ensure container fits mobile screens without overflowing */
.dashboard-page .container {
  width: 100% !important;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 1.25rem;
}

/* Guest Alert Banner */
.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem 1.75rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #f0f7ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  margin-bottom: 2rem;
  box-shadow: var(--elevation-1);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.guest-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guest-banner-text {
  flex: 1;
}

.guest-banner-text h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.guest-banner-text p {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.45;
  margin: 0;
}

.guest-banner-action {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .guest-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem 1rem;
    gap: 1rem;
  }
  .guest-banner-action {
    width: 100%;
  }
  .guest-banner-action .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Dashboard Top Navigation User Pill */
.dash-user-chip {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  background-color: var(--md-surface-container);
  border-radius: var(--radius-full);
  border: 1px solid var(--md-divider);
  cursor: pointer;
  transition: var(--trans-standard);
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 220px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.dash-user-chip:hover {
  background-color: var(--md-surface-container-high);
  box-shadow: var(--elevation-1);
}

.dash-user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
  min-width: 0;
}

#header-username {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--md-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.dash-sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--md-status-green);
  font-weight: 600;
}

.dash-sync-indicator::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--md-status-green);
  box-shadow: 0 0 6px var(--md-status-green);
}

/* User Greeting Header */
.dash-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dash-header-title h1 {
  font-size: 1.85rem;
  margin-bottom: 0.25rem;
}

.dash-header-title p {
  color: var(--md-secondary);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Dashboard Grid Layout (Centered & Balanced) */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (min-width: 992px) {
  .dash-grid {
    grid-template-columns: 360px 1fr;
  }
}

/* Subscription Hero Card */
.sub-hero-card {
  background: linear-gradient(135deg, #1e68c5 0%, #154c93 100%);
  color: #ffffff;
  border-radius: var(--radius-2xl);
  padding: 1.75rem;
  box-shadow: 0 10px 25px -5px rgba(30, 104, 197, 0.35);
  position: relative;
  overflow: hidden;
}

.sub-hero-card::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.sub-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.sub-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sub-status-pill.active {
  background: rgba(39, 174, 96, 0.25);
  color: #a3ffc7;
  border: 1px solid rgba(163, 255, 199, 0.4);
}

.sub-status-pill.expired {
  background: rgba(235, 87, 87, 0.25);
  color: #ffb4b4;
  border: 1px solid rgba(255, 180, 180, 0.4);
}

.sub-tariff-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #ffffff;
}

.sub-tariff-server {
  font-size: 0.85rem;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 1.5rem;
}

/* Multiple Subscriptions Selector inside Hero Card */
.sub-multi-pills {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.sub-pill-tab {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.sub-pill-tab-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sub-pill-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.sub-pill-tab.active {
  background: #ffffff;
  color: #154c93;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sub-pill-tab-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  flex-shrink: 0;
  white-space: nowrap;
}

.sub-pill-tab.active .sub-pill-tab-badge {
  background: rgba(21, 76, 147, 0.15);
  color: #154c93;
}

.sub-progress-wrap {
  margin-bottom: 1.25rem;
}

.sub-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.sub-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.sub-progress-fill {
  height: 100%;
  background: #ffffff;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.sub-dates-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  opacity: 0.85;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 1.5rem;
}

.sub-hero-actions {
  display: flex;
  gap: 0.75rem;
}

.sub-hero-actions .btn {
  flex: 1;
}

.btn-white {
  background-color: #ffffff;
  color: var(--md-primary);
  font-weight: 600;
}

.btn-white:hover {
  background-color: #f1f5f9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-white-tonal {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-white-tonal:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Telegram Bot Sync Banner */
.tg-sync-banner {
  background: linear-gradient(135deg, #e8f4fd 0%, #d8eaff 100%);
  border: 1px solid #b8daff;
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.tg-sync-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #229ed9;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tg-sync-content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #0c4a6e;
}

.tg-sync-content p {
  font-size: 0.8125rem;
  color: #334155;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.tg-sync-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0284c7;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tg-sync-link:hover {
  text-decoration: underline;
}

/* Content Column & Cards */
.dash-content-col {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.dash-card {
  background-color: var(--md-surface);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--md-divider);
  box-shadow: var(--elevation-1);
  padding: 1.75rem;
  transition: var(--trans-standard);
  box-sizing: border-box;
  overflow: hidden;
}

.dash-card:hover {
  box-shadow: var(--elevation-2);
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.dash-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
}

.dash-card-subtitle {
  font-size: 0.8125rem;
  color: var(--md-secondary);
}

/* Multi-Key List Component */
.keys-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.key-box-container {
  background-color: var(--md-surface-container-low);
  border: 1px solid var(--md-divider);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.25rem;
  transition: all 0.2s ease;
}

.key-box-container:hover {
  border-color: #cbd5e1;
}

.key-box-container.active-qr-key {
  border-color: #3b82f6;
  background-color: #f8fafc;
  box-shadow: 0 0 0 1px #3b82f6;
}

.key-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.625rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.key-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.key-type-icon {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
}

.key-title-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--md-on-surface);
}

.key-proto-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: #334155;
}

.btn-qr-select {
  background: #ffffff;
  border: 1px solid var(--md-divider);
  color: var(--md-on-surface);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-qr-select:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-qr-select.active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.key-box-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  margin-bottom: 0.5rem;
}

.key-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.key-input-field {
  flex: 1;
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--md-on-surface);
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-input-field:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px rgba(30, 104, 197, 0.15);
}

/* Clean QR Code Container */
.connect-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
  align-items: start;
}

.connect-options-grid.full-width-setup {
  display: block !important;
  grid-template-columns: 1fr !important;
  width: 100% !important;
}

.connect-options-grid.full-width-setup .setup-tabs-wrapper {
  width: 100% !important;
  max-width: 100% !important;
}

@media (min-width: 640px) {
  .connect-options-grid:not(.full-width-setup) {
    grid-template-columns: 190px 1fr;
  }
}

.qr-code-frame {
  background: #ffffff;
  border: 1px solid var(--md-divider);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--elevation-1);
}

.qr-canvas-holder {
  width: 154px;
  height: 154px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem auto;
  position: relative;
  background: #ffffff;
  border-radius: 8px;
  padding: 5px;
  box-sizing: border-box;
}

.qr-canvas-holder canvas[style*="display: none"],
.qr-canvas-holder img[style*="display: none"] {
  display: none !important;
}

.qr-canvas-holder canvas,
.qr-canvas-holder img {
  width: 144px;
  height: 144px;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 4px;
}

.qr-caption {
  font-size: 0.72rem;
  color: var(--md-secondary);
  line-height: 1.35;
}

/* Instructions Protocol Segmented Switcher (SPEED vs STABLE) */
.inst-segment-container {
  width: 100%;
  margin-bottom: 1.25rem;
}

.inst-segment-nav {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  gap: 4px;
  box-sizing: border-box;
  width: 100%;
}

.inst-segment-pill {
  flex: 1 1 0%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none !important;
  outline: none !important;
  background: transparent;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none;
  white-space: nowrap;
  user-select: none;
}

.inst-segment-pill:hover:not(.active) {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.6);
}

.inst-segment-pill.active {
  background: #ffffff !important;
  color: #0f172a !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08) !important;
}

.inst-segment-pill .inst-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 560px) {
  .inst-segment-nav {
    border-radius: 12px;
    flex-direction: column;
    padding: 4px;
  }
  .inst-segment-pill {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
}

.inst-protocol-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.85rem;
}

.inst-protocol-badge.speed {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fef08a;
}

.inst-protocol-badge.stable {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Quick Platform Installation Instructions Tabs */
.dash-tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--md-divider);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.dash-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.625rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  transition: var(--trans-quick);
  white-space: nowrap;
}

.dash-tab-btn:hover {
  color: var(--md-primary);
}

.dash-tab-btn.active {
  color: var(--md-primary);
  border-bottom-color: var(--md-primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

.step-instruction-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--md-on-surface-variant);
  line-height: 1.45;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--md-surface-container-high);
  color: var(--md-primary);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Smart TV Sync Form (Centered & No Overflow) */
.tv-sync-form {
  background: var(--md-surface-container-low);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  border: 1px solid var(--md-divider);
  box-sizing: border-box;
  width: 100%;
}

.tv-code-input-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  max-width: 290px;
  margin: 0 auto;
  box-sizing: border-box;
}

.tv-digit-input {
  flex: 1 1 0;
  min-width: 0;
  max-width: 38px;
  width: 100%;
  height: 46px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-display);
  border: 2px solid var(--md-outline-variant);
  border-radius: var(--radius-sm);
  background: var(--md-surface);
  color: var(--md-primary);
  outline: none;
  transition: var(--trans-quick);
  box-sizing: border-box;
  padding: 0;
}

.tv-digit-input:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px rgba(30, 104, 197, 0.18);
}

.tv-dash-separator {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--md-outline);
  user-select: none;
  padding: 0 0.1rem;
}

.tv-sync-feedback {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  text-align: center;
}

.tv-sync-feedback.success {
  color: var(--md-status-green);
}

.tv-sync-feedback.error {
  color: #d32f2f;
}

/* Referral & Partner Stats Grid */
.ref-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 540px) {
  .ref-stats-grid {
    grid-template-columns: 1fr;
  }
}

.ref-stat-box {
  background: var(--md-surface-container-low);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--md-divider);
}

.ref-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--md-primary);
  margin-bottom: 0.25rem;
}

.ref-stat-label {
  font-size: 0.75rem;
  color: var(--md-secondary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

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

.modal-dialog {
  background-color: var(--md-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--elevation-3);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem 1.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--md-divider);
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--md-secondary);
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans-quick);
}

.modal-close-btn:hover {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

.modal-body {
  padding: 1.5rem 1.75rem;
}

/* Modal Tariff Category Switcher */
.modal-category-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: var(--md-surface-container-high);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}

.modal-cat-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-cat-tab:hover {
  color: var(--md-on-surface);
  background: rgba(255, 255, 255, 0.5);
}

.modal-cat-tab.active {
  background: #ffffff;
  color: var(--md-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tariff-section-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.8125rem;
  color: #334155;
  line-height: 1.4;
  margin-bottom: 1rem;
}

/* Badges for tariffs */
.tariff-badge-new {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #0284c7;
  background: #e0f2fe;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.tariff-badge-popular {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #1e68c5;
  background: #e0e7ff;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.tariff-badge-discount {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #16a34a;
  background: #dcfce7;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.tariff-badge-hit {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #ea580c;
  background: #ffedd5;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

/* Tariff Selector Grid in Modal */
.modal-tariffs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tariff-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border: 2px solid var(--md-outline-variant);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--trans-quick);
  background: var(--md-surface);
}

.tariff-select-item:hover {
  border-color: var(--md-primary);
  background: var(--md-surface-container-lowest);
}

.tariff-select-item.selected {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.tariff-select-item.selected .tariff-price-bold {
  color: var(--md-primary);
}

.tariff-info-col h5 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
}

.tariff-info-col span {
  font-size: 0.8125rem;
  color: var(--md-secondary);
}

.tariff-price-col {
  text-align: right;
}

.tariff-price-bold {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: var(--font-display);
}

/* Payment Methods Selector */
.payment-methods-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.payment-method-card {
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--trans-quick);
}

.payment-method-card:hover {
  border-color: var(--md-primary);
}

.payment-method-card.selected {
  border-color: var(--md-primary);
  background: #f0f7ff;
  color: var(--md-primary);
  font-weight: 600;
}

/* Toast Notifications */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #191c20;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-notice .material-symbols-outlined {
  color: #4ade80;
}

/* ==========================================================================
   Comprehensive Responsive System (Mobile, Tablet, Desktop)
   ========================================================================== */

/* Tablet & Smaller Laptops (<= 992px) */
@media (max-width: 992px) {
  .dash-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .dash-sidebar-col {
    order: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .dash-content-col {
    order: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* Small Tablets & Large Phones (<= 768px) */
@media (max-width: 768px) {
  .dashboard-main {
    padding: 4.75rem 0 2.5rem;
  }

  .dashboard-page .container {
    padding: 0 0.875rem !important;
  }

  .bar-container {
    padding: 0 0.875rem;
  }

  /* Dashboard Header */
  .dash-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .dash-header-title {
    text-align: left;
  }

  .dash-header-title p {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
  }

  .dash-header-actions {
    display: flex;
    width: 100%;
    gap: 0.5rem;
  }

  .dash-header-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* Quick Connect & Setup Tabs */
  .connect-options-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }

  .qr-code-frame {
    max-width: 220px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
  }

  .setup-tabs-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .dash-tabs-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.35rem;
    padding-bottom: 4px;
    width: 100%;
    max-width: 100%;
  }

  .dash-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .dash-tab-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .step-item {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .toast-notice {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    justify-content: center;
  }
}

/* Medium & Compact Mobile Screens (<= 640px) */
@media (max-width: 640px) {
  .sub-hero-actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  .sub-hero-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    white-space: normal !important;
    text-align: center;
    padding: 0.65rem 1rem !important;
  }

  .empty-keys-box .btn {
    white-space: normal !important;
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    max-width: 100%;
    width: 100%;
    max-height: 88vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--radius-2xl);
    border-top-right-radius: var(--radius-2xl);
    margin: 0;
    animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-header {
    padding: 1.15rem 1.25rem 0.85rem;
  }

  .modal-body {
    padding: 1rem 1.25rem 1.5rem;
  }

  .payment-methods-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

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

/* Standard Mobile Phones (<= 560px) */
@media (max-width: 560px) {
  .dashboard-page .container {
    padding: 0 0.75rem !important;
  }

  /* User Chip Compact View */
  .dash-user-chip {
    padding: 0.3rem 0.65rem 0.3rem 0.35rem;
    gap: 0.4rem;
    max-width: 140px;
  }

  .dash-sync-indicator {
    display: none !important;
  }

  #header-username {
    font-size: 0.8125rem;
    max-width: 85px;
  }

  .sub-hero-card {
    padding: 1.25rem 1rem !important;
    border-radius: var(--radius-xl);
  }

  .sub-tariff-title {
    font-size: 1.3rem;
  }

  .tg-sync-banner {
    padding: 1rem 0.875rem !important;
    border-radius: var(--radius-xl);
  }

  .dash-card {
    padding: 1.25rem 0.875rem !important;
    border-radius: var(--radius-xl);
  }

  .dash-card-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
  }

  .dash-card-title {
    font-size: 1.05rem;
  }

  .key-box-container {
    padding: 0.875rem 0.75rem;
  }

  .key-title-text {
    font-size: 0.875rem;
  }

  .key-proto-badge {
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
  }

  .key-input-row {
    flex-direction: row;
    gap: 0.35rem;
  }

  .key-input-field {
    font-size: 0.78rem;
    padding: 0.5rem 0.5rem;
    min-width: 0;
    flex: 1 1 0;
  }

  .key-input-row .btn {
    padding: 0.5rem 0.65rem;
    font-size: 0.8125rem;
    flex-shrink: 0;
  }

  .sub-multi-pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sub-multi-pills::-webkit-scrollbar {
    display: none;
  }

  .sub-pill-tab {
    padding: 0.35rem 0.45rem;
    font-size: 0.75rem;
    border-radius: 8px;
  }

  /* 3 Columns With Compact Padding */
  .ref-stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.4rem;
  }

  .ref-stat-box {
    padding: 0.65rem 0.25rem;
  }

  .ref-stat-val {
    font-size: 1.15rem;
  }

  .ref-stat-label {
    font-size: 0.65rem;
    line-height: 1.2;
  }
}

/* Narrow Phones (<= 480px) */
@media (max-width: 480px) {
  .key-input-row .btn span:not(.material-symbols-outlined) {
    display: none;
  }

  .key-input-row .btn {
    padding: 0.5rem 0.65rem;
    min-width: 38px;
    justify-content: center;
  }
}

/* Small Screens / iPhone SE / 320px - 390px */
@media (max-width: 390px) {
  .dashboard-page .container {
    padding: 0 0.5rem !important;
  }

  .bar-container {
    padding: 0 0.625rem;
  }

  .brand-avatar {
    width: 28px;
    height: 28px;
  }

  .brand-name {
    font-size: 1rem;
  }

  /* User Chip becomes Avatar-only circular button to prevent any header overflow */
  .dash-user-chip {
    padding: 4px;
    border-radius: 50%;
    background: transparent;
    border: none;
  }

  .dash-user-chip:hover {
    background: var(--md-surface-container);
  }

  .dash-user-info {
    display: none !important;
  }

  .dash-avatar {
    width: 32px;
    height: 32px;
  }

  .dash-header-title h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  /* TV Code Input: Fluidly scales down cleanly on small screens */
  .tv-code-input-wrapper {
    max-width: 250px;
    gap: 0.25rem;
  }

  .tv-digit-input {
    height: 40px;
    font-size: 1.15rem;
    max-width: 32px;
  }

  .tv-dash-separator {
    font-size: 1.1rem;
    padding: 0;
  }
}

/* Ultra-compact Screens (<= 340px) */
@media (max-width: 340px) {
  .ref-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .tv-code-input-wrapper {
    max-width: 230px;
    gap: 0.2rem;
  }

  .tv-digit-input {
    height: 36px;
    font-size: 1.05rem;
    max-width: 28px;
  }
}
