:root {
  --primary: #7ed957;
  --secondary: #5aa13c;
  --accent-cyan: #06b6d4;
  --bg-dark: #050813;
  --bg-card: rgba(15, 23, 42, 0.6);
  --border-color: rgba(255, 255, 255, 0.07);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --info: #3b82f6;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s ease;
}

/* Base resets & iOS settings */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(circle at top, #0f172a 0%, #050813 100%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* App view containers */
.view-container {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

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

/* Loading Overlay */
.app-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 8, 19, 0.96);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.spinner-wrapper {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}

.spinner {
  animation: spin 1s linear infinite;
}

.pulse-ring {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: pulse 1.5s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0; }
  50% { opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Login Screen Styles */
#login-view {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.app-logo {
  margin-bottom: 32px;
}

.logo-icon {
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(126, 217, 87, 0.3));
  margin-bottom: 12px;
}

.app-logo h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.tagline {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

/* Inputs and Forms */
.input-group {
  text-align: left;
  margin-bottom: 24px;
}

.input-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
}

.input-wrapper {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.input-wrapper input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 14px 14px 14px 44px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: var(--transition-fast);
}

.input-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 10px rgba(126, 217, 87, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
  border: 1px solid transparent;
  gap: 8px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #050813;
  box-shadow: 0 4px 15px rgba(126, 217, 87, 0.2);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.08);
}

.support-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 24px;
  line-height: 1.4;
}

/* Main Dashboard UI */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(5, 8, 19, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 6px;
  opacity: 0.8;
  display: flex;
  align-items: center;
}

.logout-btn:active {
  opacity: 1;
  transform: scale(0.95);
}

.app-main {
  flex-grow: 1;
  padding: 20px 20px 90px 20px; /* space for bottom tab bar */
  overflow-y: auto;
  max-width: 480px; /* Mobile width constraint on desktop viewports */
  margin: 0 auto;
  width: 100%;
}

/* Tab Switching Panels */
.tab-panel {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.tab-panel.active {
  display: block;
}

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

.tab-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Glass Cards */
.card-glass {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

/* Overview Tab Components */
.welcome-box {
  margin-bottom: 20px;
}

.welcome-box h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.welcome-box p {
  font-size: 13px;
  color: var(--text-secondary);
}

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

.kpi-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.border-primary { border-left: 4px solid var(--primary); }
.border-cyan { border-left: 4px solid var(--accent-cyan); }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0;
}

.value-danger { color: var(--danger); }
.value-cyan { color: var(--accent-cyan); }

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.action-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.action-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.contact-strip {
  display: flex;
  gap: 12px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* Services tab components */
.panel-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-item-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.service-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.service-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 15px;
}

.service-status-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-active { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.badge-paused { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.badge-suspended { background: rgba(239, 68, 68, 0.12); color: var(--danger); }

.service-price {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.service-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.meta-col {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 8px;
  border-radius: 6px;
  text-align: center;
}

.meta-lbl {
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.meta-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Data usage meters */
.usage-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.usage-meter-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 10px;
}

.usage-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--primary) 100%);
  border-radius: 20px;
}

/* Credentials visual card */
.wifi-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.credential-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.credential-row span {
  color: var(--text-secondary);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
}

/* Ledger List styling */
.ledger-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
}

.ledger-desc {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.ledger-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.ledger-amt {
  font-weight: 700;
  font-size: 14px;
}

.amt-out { color: var(--success); } /* - paid down */
.amt-in { color: var(--danger); } /* + charged */
.amt-pur { color: var(--warning); } /* purchase */

/* Profile Screen Card */
.profile-detail-card {
  text-align: center;
  padding: 24px 16px;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: #050813;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.profile-detail-card h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-detail-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 12px 0;
}

.profile-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.05);
  color: var(--primary);
  border: 1px solid rgba(126, 217, 87, 0.2);
}

.install-card {
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--primary);
}

.install-card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.install-card-content h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.install-card-content p {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}

/* Bottom Navigation Bar */
.app-nav {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  height: 64px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 100;
  transition: all 0.3s ease;
}

@media (max-width: 480px) {
  .app-nav {
    bottom: 12px;
    left: 12px;
    right: 12px;
    border-radius: 16px;
    height: 60px;
  }
}

.nav-tab {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  flex: 1;
  height: 100%;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.3s ease, transform 0.2s ease;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab svg {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), stroke 0.3s ease;
}

.nav-tab:active {
  transform: scale(0.92);
}

.nav-tab.active {
  color: var(--primary);
}

.nav-tab.active svg {
  transform: translateY(-4px) scale(1.1);
  stroke: var(--primary);
  filter: drop-shadow(0 0 6px rgba(126, 217, 87, 0.5));
}

.nav-indicator-pill {
  position: absolute;
  top: 6px;
  height: 52px;
  background: rgba(126, 217, 87, 0.08);
  border: 1px solid rgba(126, 217, 87, 0.25);
  box-shadow: 0 0 14px rgba(126, 217, 87, 0.12);
  border-radius: 14px;
  transition: left 0.35s cubic-bezier(0.25, 1, 0.5, 1), width 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 480px) {
  .nav-indicator-pill {
    top: 5px;
    height: 50px;
    border-radius: 12px;
  }
}

/* Modals & Receipts */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Invoice details styling inside Modal */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 12px;
}

.invoice-logo-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-store-info h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.invoice-store-info p {
  font-size: 9px;
  color: var(--text-secondary);
}

.invoice-title-block {
  text-align: right;
  font-size: 9px;
  color: var(--text-secondary);
}

.invoice-title-block h1 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.invoice-meta-column h4 {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 2px;
}

.invoice-meta-column p {
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 10px;
}

.invoice-table th, .invoice-table td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.invoice-table th {
  color: var(--text-secondary);
  font-weight: 600;
}

.invoice-total-section {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.invoice-total-table {
  width: 60%;
  font-size: 10px;
}

.invoice-total-table td {
  padding: 3px 4px;
  text-align: right;
}

.invoice-total-table .grand-total td {
  font-weight: 700;
  font-size: 12px;
}

.invoice-notes-terms {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  font-size: 9px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.invoice-notes-terms h4 {
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
}

#login-logo-container img {
  max-height: 80px;
  max-width: 180px;
  object-fit: contain;
  background: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

#header-logo-container img {
  max-height: 32px;
  max-width: 100px;
  object-fit: contain;
  background: #ffffff;
  padding: 3px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Custom switch sliding animation */
.switch-container input:checked + .slider-round {
  background-color: var(--primary);
  border-color: var(--primary);
}

.switch-container span::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s ease;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.switch-container input:checked + .slider-round::before {
  transform: translateX(20px);
}

/* Carrier eSIM Setup Step Content */
.esim-step-content {
  display: none;
}
.esim-step-content.active {
  display: block;
}
