/* ===========================
   Login Overlay
   =========================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a10;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(99,102,241,0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(139,92,246,0.12) 0%, transparent 50%);
}

.login-overlay.login-fade-out {
  animation: loginFadeOut 0.4s ease-out forwards;
}

@keyframes loginFadeOut {
  to { opacity: 0; transform: scale(1.02); }
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(22, 22, 30, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(99,102,241,0.1);
  animation: cardSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(32px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-logo-title {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-heading {
  font-size: 22px;
  font-weight: 700;
  color: #e8e8f0;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.04em;
}

.login-field input {
  height: 46px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0 14px;
  color: #e8e8f0;
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 200ms ease;
  width: 100%;
}

.login-field input:focus {
  border-color: rgba(99,102,241,0.6);
  background: rgba(99,102,241,0.06);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.login-pass-wrap {
  position: relative;
}

.login-pass-wrap input {
  padding-right: 44px;
}

.pass-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 200ms;
}

.pass-toggle:hover { color: rgba(255,255,255,0.7); }

.login-error {
  font-size: 13px;
  color: #f87171;
  min-height: 18px;
  text-align: center;
}

.login-error.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

.login-btn {
  height: 48px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
  margin-top: 4px;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(99,102,241,0.5);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* App fade-in after login */
.app-fade-in {
  animation: appFadeIn 0.5s ease-out;
}

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


*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Dark Mode (default) ── */
body.dark {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --secondary: #8b5cf6;

  --bg-base: #0f0f13;
  --bg-card: #16161e;
  --bg-card-hover: #1e1e2a;
  --bg-sidebar: #12121a;
  --bg-input: #1a1a24;
  --bg-table-row: #14141c;
  --bg-table-row-alt: #16161e;
  --bg-table-row-hover: #1c1c2e;
  --bg-thead: #0f0f16;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(99, 102, 241, 0.4);
  --border-active: rgba(99, 102, 241, 0.7);

  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a78;
  --text-accent: #818cf8;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

  --topbar-bg: rgba(15, 15, 19, 0.85);
  --scrollbar-thumb: rgba(255,255,255,0.1);
  --scrollbar-thumb-hover: rgba(255,255,255,0.2);

  --apn-color: #a5b4fc;
  --apn-bg: rgba(99,102,241,0.08);
  --network-color: #34d399;
  --network-bg: rgba(16,185,129,0.1);
  --network-border: rgba(16,185,129,0.2);
  --carrier-color: #fbbf24;
  --carrier-bg: rgba(251,191,36,0.1);
  --carrier-border: rgba(251,191,36,0.2);
  --highlight-bg: rgba(99, 102, 241, 0.3);
  --highlight-text: #a5b4fc;
}

/* ── Light Mode ── */
body.light {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-glow: rgba(79, 70, 229, 0.1);
  --secondary: #7c3aed;

  --bg-base: #f5f6fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f1ff;
  --bg-sidebar: #ffffff;
  --bg-input: #f3f4f6;
  --bg-table-row: #ffffff;
  --bg-table-row-alt: #f8f9ff;
  --bg-table-row-hover: #eef0ff;
  --bg-thead: #f0f1ff;

  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(79, 70, 229, 0.35);
  --border-active: rgba(79, 70, 229, 0.6);

  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #9090b0;
  --text-accent: #4f46e5;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);

  --topbar-bg: rgba(255, 255, 255, 0.9);
  --scrollbar-thumb: rgba(0,0,0,0.12);
  --scrollbar-thumb-hover: rgba(0,0,0,0.2);

  --apn-color: #4338ca;
  --apn-bg: rgba(79,70,229,0.07);
  --network-color: #059669;
  --network-bg: rgba(16,185,129,0.08);
  --network-border: rgba(16,185,129,0.25);
  --carrier-color: #b45309;
  --carrier-bg: rgba(245,158,11,0.08);
  --carrier-border: rgba(245,158,11,0.25);
  --highlight-bg: rgba(99, 102, 241, 0.18);
  --highlight-text: #3730a3;
}

/* Shared constants */
:root {
  --esim-color: #6366f1;
  --esim-bg: rgba(99, 102, 241, 0.1);
  --sim-color: #10b981;
  --sim-bg: rgba(16, 185, 129, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --topbar-height: 68px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --theme-transition: background 0.35s ease, color 0.35s ease,
                      border-color 0.35s ease, box-shadow 0.35s ease;
}

/* ===========================
   Base
   =========================== */
html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: var(--theme-transition);
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ===========================
   Layout
   =========================== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: var(--theme-transition);
  box-shadow: var(--shadow-sm);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: radial-gradient(ellipse at top left, rgba(99,102,241,0.06) 0%, transparent 70%);
  pointer-events: none;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.logo svg {
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(99,102,241,0.25);
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.logo-title {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.logo-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--border-active);
  color: var(--primary);
  background: var(--primary-glow);
  transform: rotate(20deg) scale(1.08);
  box-shadow: 0 0 12px var(--primary-glow);
}

.theme-toggle:active {
  transform: rotate(20deg) scale(0.95);
}

.theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Type Navigation */
.type-nav {
  padding: 20px 16px 16px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  padding: 0 4px;
}

.type-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.type-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateX(2px);
  background: var(--bg-card-hover);
}

.type-btn.active {
  border-color: var(--border-active);
  color: var(--text-primary);
  background: var(--primary-glow);
  box-shadow: 0 0 16px rgba(99,102,241,0.12), inset 0 0 16px rgba(99,102,241,0.04);
}

.type-btn.active .type-icon {
  color: var(--primary-light);
}

.type-btn.active[id="btn-sim"] {
  border-color: rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.07);
  box-shadow: 0 0 16px rgba(16,185,129,0.08);
}

.type-btn.active[id="btn-sim"] .type-icon {
  color: #10b981;
}

.type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: all var(--transition);
}

.type-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  z-index: 1;
}

.type-name {
  font-weight: 600;
  font-size: 14px;
}

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

.type-arrow {
  font-size: 18px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  transition: transform var(--transition);
}

.type-btn.active .type-arrow {
  color: var(--primary-light);
  transform: translateX(3px);
}

/* Sidebar Stats */
.sidebar-stats {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-light);
  font-family: var(--font-mono);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ===========================
   Main Content
   =========================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  transition: var(--theme-transition);
}

/* Top Bar */
.top-bar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: var(--theme-transition);
}

.top-bar-left {
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumb-type {
  color: var(--primary-light);
  font-weight: 600;
}

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

/* Search Box */
.search-container {
  flex: 1;
  max-width: 680px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  transition: all var(--transition);
  height: 44px;
}

.search-box:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 0 20px rgba(99, 102, 241, 0.06);
}

/* ── Field Filter Button ── */
.field-filter-wrap {
  position: relative;
  flex-shrink: 0;
}

.field-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.field-filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.field-filter-btn.active,
.field-filter-btn.has-extra {
  border-color: var(--border-active);
  color: var(--primary-light);
  background: var(--primary-glow);
}

.filter-caret {
  opacity: 0.5;
  transition: transform var(--transition);
}

.field-filter-btn.active .filter-caret {
  transform: rotate(180deg);
}

/* ── Dropdown Panel ── */
.field-filter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: fadeIn 0.15s ease-out;
}

.field-filter-dropdown.open {
  display: flex;
}

.filter-dropdown-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.filter-note {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── Checkbox Rows ── */
.filter-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}

.filter-check-row:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.filter-always-on {
  cursor: default;
  opacity: 0.6;
}

.filter-always-on:hover {
  background: transparent;
}

/* Hide native checkbox */
.filter-check-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Custom visual checkbox */
.filter-check-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-hover);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: transparent;
  flex-shrink: 0;
  transition: all var(--transition);
}

.filter-check-row input:checked + .filter-check-box {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-check-row input:checked + .filter-check-box::after {
  content: '?;
}

.checked-always {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}


.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

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

.top-bar-right { flex-shrink: 0; display: flex; align-items: center; margin-left: auto; }

.search-hint {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ===========================
   Results Area
   =========================== */
.results-area {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  position: relative;
}

.results-area::-webkit-scrollbar {
  width: 6px;
}

.results-area::-webkit-scrollbar-track {
  background: transparent;
}

.results-area::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.results-area::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  max-width: 300px;
}

/* Default (Welcome) State */
.default-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px;
  gap: 40px;
}

.default-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hero-icon {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.default-hero h2 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.default-hero p {
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.7;
}

.quick-tips {
  width: 100%;
  max-width: 560px;
}

.quick-tips h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-align: center;
}

.tips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.tip-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tip-emoji {
  font-size: 24px;
  margin-bottom: 4px;
}

.tip-card span:not(.tip-emoji) {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.tip-card small {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===========================
   Table
   =========================== */
.table-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.table-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  position: sticky;
  top: 0;
  z-index: 5;
  transition: var(--theme-transition);
}

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

.result-label strong {
  color: var(--primary-light);
  font-weight: 700;
}

.search-term-display {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
}

.table-scroll {
  flex: 1;
  overflow: auto;
}

.table-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg-thead);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  transition: var(--theme-transition);
}

.data-table thead th:first-child {
  padding-left: 28px;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  animation: rowFadeIn 0.2s ease-out both;
}

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

.data-table tbody tr:nth-child(even) {
  background: var(--bg-table-row-alt);
}

.data-table tbody tr:hover {
  background: var(--bg-table-row-hover);
}

.data-table tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: top;
  line-height: 1.6;
  max-width: 300px;
  word-break: break-word;
  transition: var(--theme-transition);
}

.data-table tbody td:first-child {
  padding-left: 28px;
  font-weight: 600;
}

.data-table tbody td:empty::after {
  content: '?;
  color: var(--text-muted);
  opacity: 0.4;
}

/* Plan name cell */
.plan-name-cell {
  font-weight: 600;
  color: var(--text-primary);
}

.plan-name-en {
  display: block;
  font-size: 13px;
  color: var(--primary-light);
  font-weight: 700;
}

.plan-name-zh {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── APN cell (adaptive: plain APN or APN+user+pass) ── */
.apn-td {
  vertical-align: top;
  padding-top: 11px !important;
  min-width: 160px;
}

/* Each clickable chip */
.apn-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--apn-color);
  background: var(--apn-bg);
  border: 1px solid transparent;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apn-chip.copyable {
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
}

.apn-chip.copyable:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary-light);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: translateY(-1px);
}

.apn-chip.copyable:active {
  transform: translateY(0);
  opacity: 0.8;
}

/* Sub-row for username / password */
.apn-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.apn-field-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  width: 28px;
  flex-shrink: 0;
  padding-top: 1px;
}

/* ── Toast notification ── */
#copy-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 10px 20px;
  border-radius: 24px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(99,102,241,0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 9999;
  letter-spacing: 0.01em;
}

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

#copy-toast.toast-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
}

/* Network type badge */
.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--network-bg);
  color: var(--network-color);
  border: 1px solid var(--network-border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Roaming carrier badge */
.carrier-badge {
  display: inline-flex;
  align-items: center;
  background: var(--carrier-bg);
  color: var(--carrier-color);
  border: 1px solid var(--carrier-border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Highlight matching text */
.highlight {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* Notification cell */
.notification-cell {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 250px;
  line-height: 1.5;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 220px;
  }
}

@media (max-width: 700px) {
  .app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Theme switch spin animation */
@keyframes spinOnce {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.theme-toggle.spinning {
  animation: spinOnce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===========================
   Sidebar Clock
   =========================== */
.sidebar-clock-section {
  padding: 12px 16px 10px;
  border-top: 1px solid var(--border);
}

.clock-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-secondary);
}

.clock-digits {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--primary-light);
  line-height: 1;
}

/* ===========================
   Data Reset Column
   =========================== */
.reset-td {
  vertical-align: top;
  padding-top: 10px !important;
  min-width: 190px;
}

.reset-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.reset-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

/* 流量 / 日期 badge */
.reset-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.reset-data {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.reset-date {
  background: rgba(245, 158, 11, 0.10);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* Reset time (e.g. 00:00 UTC+8) */
.reset-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Live countdown chip */
.reset-countdown {
  font-size: 10px;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
  transition: color 0.4s ease;
}

.reset-empty {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 13px;
}
/* ===========================
   Distributor Area
   =========================== */
.distributor-area {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
}

.dist-left-panel {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.dist-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dist-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

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

.dist-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.dist-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-light);
}

.dist-contact-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.dist-contact {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: 4px;
}

.dist-hours {
  font-size: 12px;
  color: var(--carrier-color);
  font-family: var(--font-mono);
}

.dist-section {
  margin-top: 16px;
}

.dist-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dist-rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-rules-list li {
  position: relative;
  padding-left: 16px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.dist-rules-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--primary-light);
  font-weight: bold;
}

.dist-scripts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.script-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.script-card:hover {
  border-color: var(--primary-light);
  background: var(--highlight-bg);
}

.script-card:active {
  transform: scale(0.98);
}

.script-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-accent);
}

.script-content {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Right Panel for Common Scripts */
.dist-right-panel {
  width: 320px;
  min-width: 320px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}

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

.common-scripts-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.script-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
}

.common-scripts-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Distributor Scrollbars */
.dist-left-panel::-webkit-scrollbar,
.common-scripts-list::-webkit-scrollbar {
  width: 6px;
}
.dist-left-panel::-webkit-scrollbar-track,
.common-scripts-list::-webkit-scrollbar-track {
  background: transparent;
}
.dist-left-panel::-webkit-scrollbar-thumb,
.common-scripts-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
.dist-left-panel::-webkit-scrollbar-thumb:hover,
.common-scripts-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Copyable Notification Cell */
.notification-cell.copyable {
  cursor: pointer;
  transition: opacity 150ms ease, color 150ms ease;
}
.notification-cell.copyable:hover {
  opacity: 0.8;
  color: var(--primary-light);
}
.notification-cell.copyable:active {
  opacity: 0.6;
}




/* User Profile & Logout */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  margin-left: 16px;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all var(--transition);
  margin-left: 4px;
}

.logout-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.logout-btn:active {
  transform: scale(0.9);
}

