:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #e0e7ff;
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  font-family: 'Outfit', system-ui, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* --- AUTH VIEW (Login Page) --- */
.auth-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-app);
  z-index: 10000;
  display: flex; /* overridden by JS if not needed */
}

.auth-left {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.auth-branding {
  color: white;
  z-index: 2;
  text-align: center;
}

.auth-branding h1 {
  font-size: 48px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -1px;
}

.auth-branding p {
  font-size: 18px;
  opacity: 0.9;
  font-weight: 300;
}

/* Decorative glassmorphism circles */
.circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}
.circle-1 {
  width: 300px;
  height: 300px;
  top: -50px;
  left: -50px;
}
.circle-2 {
  width: 400px;
  height: 400px;
  bottom: -100px;
  right: -50px;
  background: rgba(255, 255, 255, 0.15);
}

.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 40px;
}

.auth-form-container {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  padding: 40px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.auth-form-container h3 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-main);
}

.auth-form-container p {
  color: var(--text-sub);
  margin-bottom: 32px;
  font-size: 15px;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-main);
}

/* --- MAIN APP LAYOUT --- */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-area {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 24px;
}

.header-icons {
  display: flex;
  gap: 12px;
}

.header-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 12px;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.nav-bottom {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-container {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-sub);
}

.search-container input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-app);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-container input:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* Tabs */
#tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

#tabs .tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

#tabs .tab:hover {
  border-color: #cbd5e1;
  color: var(--text-main);
}

#tabs .tab.active {
  background: var(--text-main);
  color: white;
  border-color: var(--text-main);
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-app);
}

.otp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* OTP Cards */
.account-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.account-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info .label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.info .issuer {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.account-card:hover .actions {
  opacity: 1;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-sub);
  padding: 6px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-app);
  color: var(--primary);
}

.btn-icon.del:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.otp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.otp-code-wrapper {
  background: var(--bg-app);
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.account-card .code {
  font-family: 'Outfit', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 4px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.account-card .code:hover {
  color: var(--primary-dark);
}

.timer-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.progress-ring__circle {
  stroke: var(--primary);
  stroke-dasharray: 88; /* 2 * pi * r (r=14) = 87.96 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.account-card .time {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0; top: 0;
  width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  padding: 32px;
  width: 90%;
  max-width: 480px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.close {
  position: absolute;
  right: 24px;
  top: 24px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-sub);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-app);
  transition: all 0.2s ease;
}

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

.modal-content h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.modal-desc {
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 24px;
}

.toolbar-section h4 {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 12px;
  margin-top: 24px;
}

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

.tool-btn {
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  border-color: var(--primary);
  background: white;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.tool-btn.danger { color: var(--danger); }
.tool-btn.danger:hover { border-color: var(--danger); background: var(--danger-light); }
.tool-btn.full-width { width: 100%; grid-column: 1 / -1; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Inputs & Buttons */
.full-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-app);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.full-input:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.primary-btn:hover { 
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.secondary-btn {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s ease;
}
.secondary-btn:hover { background: var(--bg-app); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-light);
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 16px;
  display: none;
}

.hint-alert {
  background: #fffbeb;
  color: #b45309;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
  border: 1px solid #fde68a;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 16px;
}

.checkbox-label input { display: none; }
.custom-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.checkbox-label input:checked + .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox-label input:checked + .custom-checkbox::after {
  content: '';
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

/* Footer */
.footer-links {
  background: white;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

/* Loading */
#loading {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20000;
  font-weight: 600;
  color: var(--primary);
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  margin-bottom: 16px;
}

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

/* PROMPT OVERLAY JS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.modal-overlay .modal-content { 
  margin: 0; 
  animation: modalPop 0.2s ease-out;
}
.button-row { display: flex; gap: 12px; margin-top: 24px; }
.button-row button { 
  flex: 1; padding: 12px; border-radius: 12px; border: none; cursor: pointer; font-family: inherit; font-weight: 500;
}
#okBtn { background: var(--primary); color: white; }
#cancelBtn { background: var(--bg-app); border: 1px solid var(--border); color: var(--text-main); }

/* Responsive */
@media (max-width: 768px) {
  .auth-left { display: none; }
  .auth-form-container { padding: 32px 24px; }
  .otp-grid { grid-template-columns: 1fr; }
  .header-main { padding: 12px 16px; }
  .nav-bottom { padding: 0 16px 12px; }
  .content-area { padding: 16px; }
  .actions { opacity: 1; } /* Always show actions on mobile */
}