:root {
  --primary: #1e4a8c;
  --primary-light: #3b6fd4;
  --primary-dark: #152a54;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 72px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* Splash */
.splash {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #1e4a8c 0%, #2a5bb8 50%, #3b6fd4 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 100;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 16px;
  letter-spacing: -0.5px;
}

.splash p {
  opacity: 0.85;
  margin-top: 4px;
  font-size: 0.95rem;
}

.splash-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  height: 100%;
  opacity: 1;
  transition: opacity 0.3s;
}

.main.hidden {
  display: none;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo {
  height: 48px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  object-position: left center;
  display: block;
}
.topbar-logo.hidden {
  display: none;
}
#page-title.hidden {
  display: none;
}
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:active {
  background: var(--border);
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

/* Bottom Nav */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 8px;
  z-index: 30;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 56px;
  transition: color 0.15s;
}

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

.nav-item svg {
  stroke: currentColor;
}

.nav-add {
  position: relative;
  top: -18px;
}

.add-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.4);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 4px;
  border: 1px solid var(--border);
  text-align: center;
  min-width: 0;
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.15;
}

.stat-card .label {
  font-size: 0.62rem;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

@media (max-width: 340px) {
  .stat-card .value { font-size: 1.15rem; }
  .stat-card .label { font-size: 0.58rem; }
}

.stat-card.warning .value { color: var(--warning); }
.stat-card.danger .value { color: var(--danger); }

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 12px;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.section-header a, .section-header button.link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

/* Credential item */
.cred-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.cred-item:active {
  transform: scale(0.98);
}

.cred-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
}

.cred-icon.license { background: #ecfdf5; color: #059669; }
.cred-icon.cert { background: #eff6ff; color: #2563eb; }
.cred-icon.comp { background: #fef3c7; color: #d97706; }
.cred-icon.cne { background: #fef3c7; }
.cred-icon.cme { background: #e0e7ff; }
.cred-icon.ce { background: #fce7f3; }
.cred-icon.other { background: #f1f5f9; color: #64748b; }

.cred-info {
  flex: 1;
  min-width: 0;
}

.cred-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cred-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.cred-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.cred-status.valid { background: #d1fae5; color: #065f46; }
.cred-status.expiring { background: #fef3c7; color: #92400e; }
.cred-status.expired { background: #fee2e2; color: #991b1b; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:active {
  background: var(--bg);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  width: auto;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone.dragover {
  border-color: var(--primary);
  background: #eff4ff;
}

.upload-zone svg {
  color: var(--primary);
  margin-bottom: 8px;
}

.upload-zone p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.upload-zone .hint {
  font-size: 0.75rem;
  margin-top: 4px;
  color: #94a3b8;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 150;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal-sheet {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle {
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

/* Detail view */
.detail-header {
  text-align: center;
  padding: 16px 0 24px;
}

.detail-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 2rem;
}

.detail-meta {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.meta-row span:first-child {
  color: var(--text-secondary);
}

.meta-row span:last-child {
  font-weight: 500;
  text-align: right;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
  width: 100%;
}
.action-row .btn {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin-top: 0 !important;
  padding: 10px 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Filter chips */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Share packet */
.packet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.packet-item.selected {
  border-color: var(--primary);
  background: #eff4ff;
}

.packet-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  /* Keep light for healthcare professional clean look for now */
}

/* ========== Auth Screens ========== */
#auth-root {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 32px;
  max-width: 420px;
  margin: 0 auto;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  margin-bottom: 12px;
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.auth-card {
  width: 100%;
  background: var(--surface);
  border-radius: 20px;
  padding: 24px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.auth-error {
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid #fecaca;
}

.auth-switch {
  text-align: center;
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-switch .link-btn,
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

.auth-footer {
  margin-top: 28px;
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
}

.welcome-line {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ========== FAQ ========== */
.faq-intro {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.faq-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.faq-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.faq-item strong {
  color: var(--text);
}

.faq-footer {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 24px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.auth-faq-link {
  margin-top: 12px;
  text-align: center;
}

.faq-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin: 24px 0 12px;
}

.faq-list {
  margin: 8px 0 12px 18px;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.faq-list li {
  margin-bottom: 4px;
}

/* ========== Upgrade / Freemium ========== */
.upgrade-hero {
  text-align: center;
  padding: 12px 0 20px;
}

.upgrade-badge {
  display: inline-block;
  background: linear-gradient(135deg, #1e4a8c, #3b6fd4);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.upgrade-hero h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}

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

.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.plan-row:last-of-type {
  border-bottom: none;
}

.plan-row-pro {
  background: #eff4ff;
  margin: 0 -16px;
  padding: 14px 16px;
  border-radius: 12px;
  border-bottom: none;
}

.plan-name {
  font-weight: 600;
  font-size: 1rem;
}

.plan-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.plan-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.plan-price span {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.plan-alt {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

.pro-features {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.upgrade-note {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

.limit-banner {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid #fcd34d;
}

.limit-banner.danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.limit-banner .link-btn {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}


/* High-impact polish v2.3 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  gap: 14px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #dbe7ff;
  border-top-color: #1e4a8c;
  border-radius: 50%;
  animation: cvspin 0.8s linear infinite;
}
@keyframes cvspin { to { transform: rotate(360deg); } }
.a2hs-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #eff4ff;
  border: 1px solid #93b4e8;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: #152a54;
  line-height: 1.4;
}
.a2hs-text { flex: 1; }
.a2hs-dismiss {
  border: none;
  background: transparent;
  color: #1e4a8c;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  font-size: 0.95rem;
  background: #fff;
}
.search-bar input:focus {
  outline: none;
  border-color: #1e4a8c;
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 6px 8px 6px 12px;
}
.search-wrap:focus-within {
  border-color: #1e4a8c;
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}
.search-icon { font-size: 1rem; opacity: 0.7; flex-shrink: 0; }
.search-wrap input {
  flex: 1;
  border: none !important;
  box-shadow: none !important;
  padding: 8px 4px !important;
  outline: none;
  font-size: 0.95rem;
  background: transparent;
  min-width: 0;
}
.search-go {
  flex-shrink: 0;
  border: none;
  background: #1e4a8c;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.search-go:active { opacity: 0.9; }

.search-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 6px 2px 0;
}
.search-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 4px 2px 10px;
}
.search-clear {
  border: none;
  background: #e2e8f0;
  color: #475569;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.search-clear.hidden { display: none; }
.search-go { display: none; }

/* Light polish v2.6 */
.offline-bar {
  background: #b45309;
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
  z-index: 50;
}
.offline-bar.hidden { display: none; }

.btn {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn + .btn, .btn.mt-8 { margin-top: 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:active { background: #eff4ff; }
.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1.5px solid #fecaca;
}
.btn-sm {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.85rem;
  width: auto;
}

.toast.toast-error { background: #991b1b; }
.toast.toast-success { background: #1e4a8c; }
.toast.toast-info { background: #334155; }

.mb-8 { margin-bottom: 10px; }
.mt-8 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }

.cred-icon.resume, .detail-icon.resume { background: #e0e7ff; }
.cred-icon.award, .detail-icon.award { background: #fef3c7; }

/* In-app share v2.8 */
.share-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
}
.share-tab {
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #64748b;
  cursor: pointer;
}
.share-tab.active {
  background: #fff;
  color: #1e4a8c;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.channel-seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.channel-btn {
  border: 1.5px solid var(--border, #e2e8f0);
  background: #fff;
  padding: 10px 6px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.8rem;
  color: #64748b;
  cursor: pointer;
}
.channel-btn.active {
  background: #1e4a8c;
  border-color: #1e4a8c;
  color: #fff;
}
.inbox-row {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.inbox-row h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.inbox-row p { font-size: 0.8rem; color: #64748b; margin-top: 2px; }
.inbox-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #dbe7ff;
  color: #1e4a8c;
  padding: 3px 10px;
  border-radius: 999px;
}

.splash-logo img {
  width: min(280px, 78vw);
  height: auto;
  max-height: 100px;
  border-radius: 16px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  padding: 0;
  box-sizing: border-box;
  box-shadow: none;
}
.auth-logo img {
  width: min(280px, 82vw);
  height: auto;
  max-height: 96px;
  border-radius: 0;
  object-fit: contain;
  object-position: center;
  background: transparent;
  padding: 0;
  box-sizing: border-box;
  box-shadow: none;
}

.nav-item {
  position: relative;
}
.nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 2;
}
.nav-badge.hidden { display: none; }

.legal-doc {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  padding-bottom: 24px;
}
.legal-doc h3 {
  font-size: 1rem;
  margin: 18px 0 8px;
  color: var(--primary, #1e4a8c);
}
.legal-doc ul, .legal-doc ol {
  margin: 8px 0 8px 1.2rem;
}
.legal-doc li { margin-bottom: 6px; }
.legal-updated {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.install-steps {
  margin: 8px 0 8px 1.2rem;
}
.install-steps li { margin-bottom: 8px; }

/* ===== Dark mode ===== */
html[data-theme="dark"] {
  --primary: #5b8def;
  --primary-light: #7baaf5;
  --primary-dark: #3b6fd4;
  --bg: #0b1220;
  --surface: #141b2d;
  --text: #e8eef8;
  --text-secondary: #94a3b8;
  --border: #2a3548;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] #app {
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .bottom-nav,
html[data-theme="dark"] .card,
html[data-theme="dark"] .detail-meta,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .packet-item,
html[data-theme="dark"] .inbox-row {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .btn-outline {
  background: var(--surface);
  color: var(--primary-light);
  border-color: var(--primary);
}

html[data-theme="dark"] .btn-outline:active {
  background: #1a2740;
}

html[data-theme="dark"] .btn-primary {
  background: var(--primary);
  color: #fff;
}

html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .search-wrap input {
  background: #0f172a;
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .chip {
  background: #1a2740;
  border-color: var(--border);
  color: var(--text-secondary);
}

html[data-theme="dark"] .chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

html[data-theme="dark"] .limit-banner {
  background: #1e293b;
  border-color: #334155;
  color: var(--text);
}

html[data-theme="dark"] .cred-status.valid {
  background: #064e3b;
  color: #6ee7b7;
}
html[data-theme="dark"] .cred-status.expiring {
  background: #78350f;
  color: #fcd34d;
}
html[data-theme="dark"] .cred-status.expired {
  background: #7f1d1d;
  color: #fca5a5;
}

html[data-theme="dark"] .share-tabs {
  background: #1a2740;
}
html[data-theme="dark"] .share-tab.active {
  background: var(--surface);
  color: var(--primary-light);
}

html[data-theme="dark"] .channel-btn {
  background: #0f172a;
  border-color: var(--border);
  color: var(--text-secondary);
}
html[data-theme="dark"] .channel-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

html[data-theme="dark"] .nav-item.active {
  color: var(--primary-light);
}

html[data-theme="dark"] .stat-card {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .toast {
  background: #1e293b;
  color: #f1f5f9;
}

html[data-theme="dark"] a {
  color: var(--primary-light);
}

html[data-theme="dark"] .btn-danger {
  background: #3f1d1d;
  color: #fca5a5;
  border-color: #7f1d1d;
}

html[data-theme="dark"] .legal-doc h3 {
  color: var(--primary-light);
}

html[data-theme="dark"] .empty-state {
  color: var(--text-secondary);
}

html[data-theme="dark"] .search-clear {
  background: #334155;
  color: #e2e8f0;
}

.theme-seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.theme-seg button {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 10px 6px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}
.theme-seg button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.splash-tag {
  margin-top: 12px;
  font-size: 0.95rem;
  text-align: center;
  color: #1a365d;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 1;
}
.splash-logo {
  width: auto;
  height: auto;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  animation: none;
}

.auth-tagline {
  text-align: center;
  color: #1a365d;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 4px 0 16px;
  letter-spacing: 0.01em;
}
.splash-tag {
  opacity: 0.9;
  margin-top: 12px;
  font-size: 0.95rem;
  text-align: center;
}

.splash .splash-tag {
  color: #dbe7ff;
  opacity: 1;
  font-weight: 600;
}
/* On cream/white auth header area use logo navy */
.auth-card .auth-tagline,
#auth-screen .auth-tagline {
  color: #1a365d;
}

.single-share-sheet {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.single-ch-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
}
.single-ch-row .channel-btn {
  font-size: 0.72rem;
  padding: 10px 4px;
}
.single-share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.single-share-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
html[data-theme="dark"] .single-share-card {
  background: var(--surface);
}

.recommend-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}
.recommend-qr-wrap img {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid var(--border, #e2e8f0);
}

.inbox-row-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.inbox-dismiss-btn {
  width: 100%;
  font-size: 0.85rem;
  padding: 10px;
}

.auth-tagline {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text, #0f172a);
  max-width: 22rem;
  margin: 0 auto 10px;
  text-align: center;
}
.auth-value-list {
  list-style: none;
  padding: 0;
  margin: 0 auto 8px;
  max-width: 22rem;
  text-align: left;
}
.auth-value-list li {
  font-size: 0.85rem;
  color: var(--text-secondary, #64748b);
  line-height: 1.45;
  padding: 3px 0 3px 1.1rem;
  position: relative;
}
.auth-value-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #1e4a8c;
  font-weight: 700;
  font-size: 0.8rem;
}
[data-theme="dark"] .auth-tagline { color: var(--text, #e2e8f0); }
[data-theme="dark"] .auth-value-list li::before { color: #6b9eff; }
.splash-tag {
  font-weight: 600;
  max-width: 18rem;
  line-height: 1.35;
}
