/* ==========================================================================
   MailVault Intelligence - Core Design System & Stylesheet
   Theme: Sleek Cyber Slate Glassmorphism
   Typography: Inter & Prompt (Thai Support)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Tokens */
  --bg-base: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #273549;
  --bg-glass: rgba(15, 23, 42, 0.75);
  --bg-glass-card: rgba(30, 41, 59, 0.65);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  --border-hover: rgba(255, 255, 255, 0.16);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #090d16;

  /* Accents */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.28);
  --primary-hover: #4f46e5;

  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.25);

  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.25);

  --cyan: #06b6d4;
  --purple: #8b5cf6;

  /* Shadows & Blurs */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --backdrop-blur: blur(16px);

  /* Layout Constants */
  --header-height: 72px;
  --sidebar-width: 360px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glow */
.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 35%),
    radial-gradient(circle at 50% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 45%);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   App Layout
   ========================================================================== */
#app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 20px;
  flex-shrink: 0;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 6px;
}

/* Global Search Bar */
.search-container {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 68px 0 42px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.search-input:focus {
  outline: none;
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Quick Stats Bar */
.quick-stats-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 4px 16px;
  margin-right: 8px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 700;
}

.stat-pill.danger strong {
  color: var(--rose);
}

.stat-pill.success strong {
  color: var(--emerald);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-scan {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  color: #fff;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.3);
  position: relative;
  overflow: hidden;
}
.btn-scan::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: rotate(30deg);
  animation: shine 4s infinite linear;
}

@keyframes shine {
  0% { transform: translate(-100%, -100%) rotate(30deg); }
  20%, 100% { transform: translate(100%, 100%) rotate(30deg); }
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Main Body Workspace (Sidebar + Detail Pane)
   ========================================================================== */
.app-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   Sidebar (Accounts List)
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

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

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.badge-count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* Category Filter Tabs */
.sidebar-filters {
  display: flex;
  padding: 10px 16px;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
}
.sidebar-filters::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}
.filter-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.filter-tab.active {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 600;
}

/* Accounts List */
.accounts-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.account-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  transform: translateX(2px);
}

.account-item.active {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--border-focus);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 3px 0 0 var(--border-focus);
}

.account-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.account-badge-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
}

.account-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.account-status-dot.active {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald-glow);
}
.account-status-dot.warning {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}
.account-status-dot.error {
  background: var(--rose);
  box-shadow: 0 0 8px var(--rose-glow);
}

.account-email-row {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  word-break: break-all;
}

.account-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.account-services-count {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.account-breach-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Detail View / Main Pane
   -------------------------------------------------------------------------- */
.detail-pane {
  flex: 1;
  background: transparent;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  min-height: 0;
}

.detail-pane > * {
  flex-shrink: 0;
}

/* Hero Section */
.hero-card {
  flex-shrink: 0;
  min-height: fit-content;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--backdrop-blur);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--hero-accent, #6366f1), transparent);
}

.hero-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-info-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.hero-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  width: fit-content;
}

.hero-email-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  word-break: break-all;
}

.hero-notes {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 680px;
}

.hero-status-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.hero-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Security Score Dial */
.score-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
}

.score-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  border: 3px solid;
  position: relative;
}

.score-circle.excellent {
  border-color: var(--emerald);
  color: #34d399;
  background: var(--emerald-glow);
}
.score-circle.good {
  border-color: var(--cyan);
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.15);
}
.score-circle.warning {
  border-color: var(--amber);
  color: #fbbf24;
  background: var(--amber-glow);
}
.score-circle.danger {
  border-color: var(--rose);
  color: #fb7185;
  background: var(--rose-glow);
}

.score-label {
  display: flex;
  flex-direction: column;
}
.score-label span:first-child {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.score-label span:last-child {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================================
   Two-Column Grid (Credentials & Recovery + Breaches)
   ========================================================================== */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex-shrink: 0;
}

.card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: var(--backdrop-blur);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

/* Credential Rows */
.credential-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 12px;
}

.cred-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
}

.cred-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-masked {
  letter-spacing: 0.15em;
  font-weight: 700;
}

.cred-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-mini-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-mini-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Storage Bar */
.storage-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.storage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Breach Section */
.breach-alert-box {
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breach-alert-box.has-breaches {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.breach-alert-box.safe {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.breach-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}
.breach-alert-box.has-breaches .breach-header-row {
  color: #fb7185;
}
.breach-alert-box.safe .breach-header-row {
  color: #34d399;
}

.breach-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.breach-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breach-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.breach-service-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.breach-leaked-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.leaked-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* ==========================================================================
   Services & Username Vault (Core Section)
   ========================================================================== */
.services-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.services-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.services-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.category-pills {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.cat-pill {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}
.cat-pill.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Services Grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.service-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

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

.service-card.breached-card {
  border-color: rgba(244, 63, 94, 0.4);
}

.service-card.breached-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, transparent 50%, rgba(244, 63, 94, 0.5) 50%);
}

.service-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.service-icon-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.service-title-group h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.service-category-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* The Star Feature: Highlighted Username Box */
.username-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.username-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.username-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #818cf8;
  font-weight: 600;
}

.username-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  font-family: 'Inter', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-meta-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.service-detection-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--primary);
}

.service-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition-normal);
}

.modal-backdrop.open .modal-card {
  transform: scale(1) translateY(0);
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  height: 42px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
  height: 80px;
  padding: 10px 14px;
  resize: vertical;
}

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

/* PIN Lock Screen Modal Specific */
.pin-lock-modal {
  max-width: 400px;
  text-align: center;
  align-items: center;
  padding: 36px 28px;
}

.pin-shield-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  box-shadow: 0 0 24px var(--primary-glow);
}

.pin-dots-container {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 20px 0;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: var(--transition-fast);
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: scale(1.1);
}

.pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.numpad-btn {
  height: 54px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.numpad-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.numpad-btn:active {
  transform: scale(0.96);
}

/* Smart Auto-Scan Modal Specific */
.scan-radar-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 10px auto 20px auto;
  border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, transparent 70%);
  overflow: hidden;
}

.scan-radar-sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(6, 182, 212, 0.4) 60deg, transparent 60.1deg);
  border-radius: 50%;
  animation: radarRotate 2s linear infinite;
}

@keyframes radarRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.scan-console-logs {
  background: #060911;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: 'Consolas', monospace;
  font-size: 0.8rem;
  height: 180px;
  overflow-y: auto;
  color: #38bdf8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.scan-log-line {
  line-height: 1.4;
  opacity: 0.9;
}
.scan-log-line.success {
  color: #34d399;
}
.scan-log-line.warning {
  color: #fbbf24;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success {
  border-left: 3px solid var(--emerald);
}
.toast.info {
  border-left: 3px solid var(--primary);
}

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

/* Responsive adjustments */
@media (max-width: 960px) {
  .app-workspace {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: 280px;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
  .search-container {
    max-width: 240px;
  }
}

/* ==========================================================================
   Cloudflare D1 Cloud Sync Styles
   ========================================================================== */
.btn-sync-status {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-sync-status:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-muted);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  transition: var(--transition-fast);
}

.sync-dot.status-synced {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.sync-dot.status-syncing {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  animation: pulse-sync 1s infinite alternate;
}

.sync-dot.status-offline {
  background: #64748b;
  box-shadow: none;
}

.sync-dot.status-error {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

@keyframes pulse-sync {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.2); opacity: 1; }
}

.sync-info-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sync-info-box i {
  color: #818cf8;
  flex-shrink: 0;
  margin-top: 2px;
}

.sync-info-box p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sync-status-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.sync-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}

.sync-status-row:last-child {
  border-bottom: none;
}

.sync-status-label {
  color: var(--text-muted);
}

.sync-status-val {
  color: var(--text-primary);
  font-weight: 500;
}

/* ==========================================================================
   User Profile & Authentication System Styles
   ========================================================================== */
.btn-auth-trigger {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-auth-trigger:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(59, 130, 246, 0.35) 100%);
  color: #fff;
  border-color: #818cf8;
}

/* User Menu Widget (Logged in) */
.user-menu-container {
  position: relative;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.user-profile-badge:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--border-medium);
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.user-profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  padding: 8px 0;
  z-index: 1000;
  display: none;
}

.user-dropdown-menu.open {
  display: block;
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.user-dropdown-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.user-dropdown-item.danger {
  color: var(--rose);
}
.user-dropdown-item.danger:hover {
  background: rgba(244, 63, 94, 0.1);
  color: #fb7185;
}

/* Auth Modal Styles */
.auth-nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
}

.auth-tab-btn.active {
  color: #fff;
  border-bottom-color: var(--primary);
}

.auth-form-panel {
  display: none;
}
.auth-form-panel.active {
  display: block;
}

.auth-alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 16px;
  display: none;
}
.auth-alert-box.error {
  display: block;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.auth-alert-box.success {
  display: block;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* ==========================================================================
   Auth Gatekeeper Screen (Full-Screen Security Gate)
   ========================================================================== */
.auth-gate-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 25%, rgba(30, 41, 59, 0.98) 0%, rgba(9, 13, 22, 0.99) 100%);
  backdrop-filter: blur(28px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(1.02);
}

.auth-gate-screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.auth-gate-card {
  width: 100%;
  max-width: 460px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 50px rgba(99, 102, 241, 0.18);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.auth-gate-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #38bdf8, #10b981);
}

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

.auth-gate-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(56, 189, 248, 0.2) 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.35);
}

.auth-gate-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-gate-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-demo-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.auth-demo-divider::before,
.auth-demo-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.btn-demo-mode {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 100%;
}

.btn-demo-mode:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--text-primary);
}

.demo-mode-badge {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}



