:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #f8fafc;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --primary-dark: #334155;
  --primary-hover: #1e293b;
  --primary-blue: #2563eb;
  --border-color: #e2e8f0;
  --border-focus: #94a3b8;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --radius-lg: 14px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-popup: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  --shadow-phone: 0 25px 50px -12px rgba(0, 0, 0, 0.18), 0 0 0 1px #cbd5e1;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary-dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* Desktop Nav Tabs */
.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  color: var(--text-main);
  background: #e2e8f0;
}

.nav-item.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.mobile-add-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Main Content Views */
.main-content {
  flex: 1;
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
  animation: fadeIn 0.15s ease-out;
}

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

/* Desktop Split Layout */
.home-split-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}

.sessions-column {
  min-width: 0;
}

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

.column-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

/* USSD Cards List */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ussd-card {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  cursor: pointer;
}

.ussd-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.card-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.card-logo-wrap img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.card-body {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}

.card-phone-num {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.2;
  margin-bottom: 2px;
}

.card-url-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.card-meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.meta-network {
  font-weight: 800;
  color: var(--text-main);
  font-size: 0.8rem;
}

.meta-code {
  font-weight: 600;
  color: var(--text-muted);
}

.meta-provider {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.card-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-card-start {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-card-start:hover {
  background: var(--primary-dark);
  color: #ffffff;
  border-color: var(--primary-dark);
}

.btn-card-delete {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

/* Empty State Card */
.empty-state-card {
  background: #ffffff;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.empty-state-card.hidden {
  display: none !important;
}

.empty-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.4;
  margin-bottom: 6px;
}

/* ================= SMARTPHONE CHASSIS (DESKTOP ONLY) ================= */
.desktop-phone-column {
  display: flex;
  justify-content: center;
  position: sticky;
  top: 76px;
}

.phone-frame {
  width: 310px;
  height: 590px;
  background: #ffffff;
  border: 7px solid #e2e8f0;
  border-radius: 36px;
  position: relative;
  box-shadow: var(--shadow-phone);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.phone-notch {
  width: 100px;
  height: 15px;
  background: #e2e8f0;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  z-index: 100;
}

.phone-screen {
  flex: 1;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.phone-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  z-index: 90;
}

.phone-status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.phone-inner-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  position: relative;
}

.phone-dialer-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.phone-dial-display input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  padding: 8px 0;
  border-bottom: 2px solid var(--border-color);
  letter-spacing: 0.05em;
}

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

.key-btn {
  height: 46px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.key-btn:hover {
  background: #f1f5f9;
}

.key-btn:active {
  background: #e2e8f0;
  transform: translateY(1px);
}

.phone-call-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.phone-call-btn {
  flex: 1;
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.3);
  transition: all 0.15s;
}

.phone-call-btn:hover {
  background: #047857;
}

.phone-backspace-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.phone-backspace-btn:hover {
  background: #f1f5f9;
}

/* In-Phone Dialog (Desktop Mode inside Screen) */
.desktop-dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 150;
  animation: fadeIn 0.15s ease-out;
}

.desktop-dialog-overlay.hidden {
  display: none;
}

.in-phone-dialog-card {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-popup);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.in-phone-dialog-body {
  min-height: 60px;
  max-height: 180px;
  overflow-y: auto;
}

.in-phone-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Form Styles */
.form-card {
  max-width: 540px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 18px;
}

.form-field {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.req {
  color: var(--danger);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary-blue);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

.carrier-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.carrier-mtn {
  background: #fef9c3;
  color: #854d0e;
}

.carrier-vodafone {
  background: #fee2e2;
  color: #991b1b;
}

.carrier-airteltigo {
  background: #e0f2fe;
  color: #075985;
}

.carrier-unknown {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.15s;
}

.field-input:focus {
  background: #ffffff;
  border-color: var(--border-focus);
}

/* Provider Picker Button */
.provider-picker-btn {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s;
}

.provider-picker-btn:hover {
  background: #ffffff;
  border-color: var(--border-focus);
}

.provider-btn-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.provider-btn-left img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.universal-icon-box {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-text {
  color: var(--text-muted);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary,
.btn-dark {
  background: var(--primary-dark);
  color: #ffffff;
}

.btn-primary:hover,
.btn-dark:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
  height: 44px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.12s ease-out;
}

.modal-overlay.hidden {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popup);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

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

.sheet-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.sheet-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
}

.providers-stack {
  padding: 4px 0;
  max-height: 340px;
  overflow-y: auto;
}

.provider-option {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.1s;
}

.provider-option:last-child {
  border-bottom: none;
}

.provider-option:hover {
  background: var(--bg-subtle);
}

.provider-option img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  margin-right: 12px;
}

.provider-option-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

/* Mobile USSD Dialog Popup */
.ussd-dialog-card {
  width: 100%;
  max-width: 330px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-popup);
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-body-area {
  min-height: 70px;
  max-height: 220px;
  overflow-y: auto;
}

.spinner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 10px 0;
}

.mini-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.dialog-prompt-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: pre-wrap;
  line-height: 1.4;
}

.dialog-text-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.9rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  outline: none;
}

.dialog-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Specs Wrapper */
.specs-wrapper {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spec-block {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.spec-block h2,
.spec-block h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.spec-block p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.spec-block pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
  overflow-x: auto;
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  height: 56px;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.bottom-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.bottom-tab-item.active {
  color: var(--text-main);
  font-weight: 700;
}

/* ================= RESPONSIVE BEHAVIOR (MOBILE VS DESKTOP) ================= */
@media (max-width: 900px) {
  .home-split-layout {
    grid-template-columns: 1fr;
  }

  .desktop-phone-column {
    display: none !important; /* Strictly hide the phone chassis on mobile */
  }

  .desktop-nav {
    display: none;
  }

  .mobile-add-btn {
    display: flex;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .main-content {
    padding: 12px;
    padding-bottom: 74px; /* Clearance for bottom navigation bar */
  }

  .ussd-card {
    padding: 10px;
  }

  .card-logo-wrap {
    width: 40px;
    height: 40px;
    margin-right: 10px;
  }

  .card-logo-wrap img {
    width: 28px;
    height: 28px;
  }

  .btn-card-start {
    padding: 5px 10px;
    font-size: 0.78rem;
  }
}
