/* ==========================================================================
   釜山 2026 eSIM 流量查詢助手 - Stylesheet
   Modern, Mobile-First, Dark Ocean Palette
   ========================================================================== */

:root {
  --bg-main: #0b1329;
  --bg-card: #152238;
  --bg-card-hover: #1e2f4d;
  --bg-header: rgba(11, 19, 41, 0.85);
  
  --primary: #0284c7;
  --primary-light: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --danger: #ef4444;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.5);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.35);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, textarea, [role="button"] {
  touch-action: manipulation;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* App Container (手機100%滿版貼邊 + 電腦大螢幕置中) */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  position: relative;
  background: radial-gradient(circle at 50% 0%, #172b4d 0%, var(--bg-main) 70%);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

@media (min-width: 768px) {
  .app-container {
    max-width: 640px;
    margin: 0 auto;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
  }
}

/* Top App Header (瀏海與動態島安全區適配) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  padding-bottom: 0.85rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), #0369a1);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.badge-online {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Icon Buttons */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* Main Area (滿版貼邊最適留白) */
.app-main {
  flex: 1;
  padding: 1.25rem 0.85rem 3rem;
}

/* View transitions */
.view {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view.active {
  display: block;
}

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

/* View Hero Section (加大清晰標題) */
.view-hero {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
}

.hero-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 0.4rem;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   VIEW 1: Users Grid
   ========================================================================== */
.users-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.35rem 1.25rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.user-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.user-card:hover, .user-card:active {
  transform: translateY(-2px);
  background-color: var(--bg-card-hover);
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}

.user-card:hover::before, .user-card:active::before {
  opacity: 1;
}

.user-card-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar-large {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #0f766e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.user-info h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

.user-meta-tag {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.user-card-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-light);
  font-size: 0.9rem;
  font-weight: 600;
}

.user-card-right svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.user-card:hover .user-card-right svg {
  transform: translateX(4px);
}

/* Info Banner */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  margin-top: 1rem;
}

.info-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.info-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.45;
}

/* ==========================================================================
   VIEW 2: Cards List
   ========================================================================== */
.view-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back:hover, .btn-back:active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.btn-back svg {
  width: 16px;
  height: 16px;
}

.current-user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(2, 132, 199, 0.15);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-light);
}

.user-avatar-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sim-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.2rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.25s ease;
}

.sim-card-item:hover, .sim-card-item:active {
  transform: translateY(-2px);
  background-color: var(--bg-card-hover);
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}

.sim-card-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sim-card-badge {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(15, 23, 42, 0.8));
  border: 1px solid var(--border-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-light);
  flex-shrink: 0;
}

.sim-card-details h4 {
  font-size: 1.18rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-seq-badge {
  font-size: 0.75rem;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.sim-card-iccid {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.sim-card-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--primary-light);
  font-size: 0.9rem;
  font-weight: 600;
  flex-shrink: 0;
}

.sim-card-right svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   VIEW 3: Usage Detail & Embedded Query
   ========================================================================== */
.detail-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.detail-title-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
}

.detail-title-badge .highlight {
  color: var(--primary-light);
  font-weight: 700;
}

/* Fast Card Carousel Switcher */
.card-switcher-container {
  margin-bottom: 1.25rem;
}

.switcher-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.quick-card-switcher {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.quick-card-switcher::-webkit-scrollbar {
  height: 4px;
}

.quick-card-switcher::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.switcher-pill {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all 0.2s ease;
}

.switcher-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.switcher-pill.active {
  background: var(--primary);
  border-color: var(--primary-light);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* Card Meta Box */
.card-meta-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.meta-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.meta-val.highlight {
  color: var(--primary-light);
}

/* Code Blocks with Copy */
.meta-code-block {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.code-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy:hover, .btn-copy:active {
  background: var(--primary);
  color: #fff;
}

.btn-copy svg {
  width: 14px;
  height: 14px;
}

.code-val {
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 600;
  color: #e2e8f0;
  word-break: break-all;
  letter-spacing: 0.04em;
}

/* Action Buttons Grid */
.action-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.9rem 0.5rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action svg {
  width: 22px;
  height: 22px;
}

.btn-trip {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.btn-trip:hover {
  background: rgba(59, 130, 246, 0.22);
}

.btn-external {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.btn-external:hover {
  background: rgba(16, 185, 129, 0.22);
}

/* ==========================================================================
   Embedded Live BillionConnect Iframe
   ========================================================================== */
.iframe-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.iframe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background-color: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-color);
}

.iframe-title-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.iframe-title-area h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-refresh svg {
  width: 14px;
  height: 14px;
}

.iframe-wrapper {
  position: relative;
  width: 100%;
  height: 650px;
  background-color: #ffffff;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.iframe-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--primary-light);
  font-size: 0.85rem;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.iframe-footer-tip {
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background-color: rgba(15, 23, 42, 0.3);
  border-top: 1px solid var(--border-color);
  line-height: 1.4;
}

/* ==========================================================================
   Busan Travel Guide Section
   ========================================================================== */
.guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.guide-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.guide-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.guide-icon {
  font-size: 1.3rem;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-card {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.2rem;
}

.step-content p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Footer (含底部安全區) */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
}

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

.modal-box {
  background-color: #17243b;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 3rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background-color: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Settings Modal Content */
.settings-group {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.settings-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-group h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.3rem;
}

.text-muted {
  color: var(--text-secondary);
}

.text-sm {
  font-size: 0.78rem;
}

.settings-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  padding: 0.65rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--border-active);
}

.file-upload-btn {
  display: inline-block;
}

/* iOS PWA Step Instructions */
.pwa-instructions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.4);
  padding: 0.75rem;
  border-radius: var(--radius-md);
}

.ios-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ios-step p {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.4;
}

/* Toast Notification (含底部安全區) */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: rgba(15, 23, 42, 0.95);
  color: #38bdf8;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-full);
  padding: 0.65rem 1.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 觸控回饋原生感 (Native Touch Feedback) */
.user-card:active,
.sim-card-item:active,
.btn-primary:active,
.btn-action:active,
.btn-back:active,
.btn-icon:active,
.switcher-pill:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* Responsive adjustments (手機100%貼邊滿版 + 大字體清晰易讀) */
@media (max-width: 680px) {
  .app-header {
    padding-left: calc(0.85rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.85rem + env(safe-area-inset-right, 0px));
  }

  .brand-title {
    font-size: 1.2rem;
  }

  .brand-subtitle {
    font-size: 0.8rem;
  }

  .app-main {
    padding: 1rem 0.65rem 3rem;
  }

  .hero-title {
    font-size: 1.65rem;
  }

  .hero-desc {
    font-size: 0.92rem;
  }

  /* 使用者與SIM卡滿版大卡片 */
  .user-card {
    padding: 1.25rem 1.15rem;
  }

  .user-avatar-large {
    width: 56px;
    height: 56px;
    font-size: 1.6rem;
  }

  .user-info h3 {
    font-size: 1.35rem;
  }

  .user-meta-tag {
    font-size: 0.9rem;
  }

  .sim-card-item {
    padding: 1.15rem 1.1rem;
  }

  .sim-card-badge {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }

  .sim-card-details h4 {
    font-size: 1.15rem;
  }

  .card-meta-box {
    padding: 1.15rem 1rem;
  }

  .code-val {
    font-size: 0.98rem;
  }

  /* 流量查詢 Iframe 邊界滿版貼邊 (Edge-to-Edge) */
  .iframe-section {
    margin-left: -0.65rem;
    margin-right: -0.65rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-bottom: 1.5rem;
  }

  .iframe-wrapper {
    height: 72dvh;
    min-height: 580px;
    -webkit-overflow-scrolling: touch;
  }

  .modal-box {
    width: 96%;
    max-height: calc(100dvh - 2.5rem);
  }
}

/* 窄螢幕手機 (如 iPhone SE / 小型 Android: <= 380px) */
@media (max-width: 380px) {
  .action-buttons-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .btn-action {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.75rem 1.1rem;
    font-size: 0.88rem;
  }

  .btn-action svg {
    width: 20px;
    height: 20px;
  }

  .detail-nav-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

