/* ============================================================
   Feliz Base — Nordic Minimalist Design System (Swedish Palette)
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Swedish Palette */
  --falu-red: #8B2500;
  --falu-red-light: #B33A00;
  --ocean-blue: #003F72;
  --ocean-blue-light: #005A9E;
  --ocean-blue-subtle: #E8F0F8;
  --birch-white: #F5F0EB;
  --birch-cream: #FAF7F3;
  --pine-green: #2D5A3D;
  --pine-green-light: #3D7A52;
  --golden-yellow: #FFD700;
  --golden-muted: #E6C200;
  --granite: #4A4A4A;
  --granite-light: #6B6B6B;
  --snow: #FFFFFF;
  --frost: #F8F9FA;
  --shadow-soft: rgba(0, 63, 114, 0.06);
  --shadow-medium: rgba(0, 63, 114, 0.12);
  --shadow-strong: rgba(0, 63, 114, 0.18);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--granite);
  background: var(--birch-white);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Typography ---- */
h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ocean-blue);
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
}

h3 {
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
}

p {
  color: var(--granite-light);
  font-weight: 300;
  max-width: 60ch;
}

/* ---- Utility ---- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.text-center {
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ocean-blue);
  color: var(--snow);
  box-shadow: 0 4px 16px rgba(0, 63, 114, 0.25);
}

.btn-primary:hover {
  background: var(--ocean-blue-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 63, 114, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--ocean-blue);
  border: 1.5px solid var(--ocean-blue);
}

.btn-secondary:hover {
  background: var(--ocean-blue);
  color: var(--snow);
}

.btn-accent {
  background: var(--falu-red);
  color: var(--snow);
  box-shadow: 0 4px 16px rgba(139, 37, 0, 0.25);
}

.btn-accent:hover {
  background: var(--falu-red-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(139, 37, 0, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--granite);
  padding: 0.5rem 1rem;
}

.btn-ghost:hover {
  color: var(--ocean-blue);
  background: var(--ocean-blue-subtle);
}

.btn-sm {
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 1rem 2.5rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- Form Elements ---- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--granite);
  margin-bottom: var(--space-xs);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.required-star {
  color: var(--falu-red);
  font-weight: 600;
}

.form-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid #D9D4CF;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--granite);
  background: var(--snow);
  transition: all var(--duration-fast) var(--ease-out);
  outline: none;
}

.form-input::placeholder {
  color: #B0A99F;
}

.form-input:focus {
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 3px rgba(0, 63, 114, 0.1);
}

.form-input:invalid:not(:placeholder-shown) {
  border-color: var(--falu-red);
}

/* ---- Cards ---- */
.card {
  background: var(--snow);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: 0 2px 12px var(--shadow-soft);
  transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
  box-shadow: 0 8px 32px var(--shadow-medium);
}

/* ---- Navbar ---- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--space-md) 0;
  transition: all var(--duration-normal) var(--ease-out);
  background: transparent;
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 rgba(0, 63, 114, 0.06);
}

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

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.navbar-logo {
  width: 32px;
  height: 32px;
  background: var(--ocean-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--snow);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.navbar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ocean-blue);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ---- Hero Section ---- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding-top: 80px;
}

.hero::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 63, 114, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 37, 0, 0.04) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.4rem 1rem;
  background: var(--ocean-blue-subtle);
  color: var(--ocean-blue);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: var(--space-xl);
  animation: fadeInUp 0.6s var(--ease-out) both;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  background: var(--pine-green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.hero h1 {
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}

.hero h1 em {
  font-style: normal;
  color: var(--falu-red);
}

.hero p {
  font-size: 1.15rem;
  margin-bottom: var(--space-2xl);
  animation: fadeInUp 0.6s var(--ease-out) 0.2s both;
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  animation: fadeInUp 0.6s var(--ease-out) 0.3s both;
}

/* ---- Features Section ---- */
.features {
  padding: var(--space-4xl) 0;
}

.features-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.features-header p {
  margin: var(--space-md) auto 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.feature-card {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
  font-size: 1.5rem;
}

.feature-icon.blue {
  background: var(--ocean-blue-subtle);
}

.feature-icon.red {
  background: rgba(139, 37, 0, 0.08);
}

.feature-icon.green {
  background: rgba(45, 90, 61, 0.08);
}

.feature-card h3 {
  margin-bottom: var(--space-sm);
  font-size: 1.15rem;
}

.feature-card p {
  font-size: 0.9rem;
  margin: 0 auto;
}

/* ---- Auth Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--snow);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 420px;
  position: relative;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--duration-normal) var(--ease-spring);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--frost);
  color: var(--granite);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
  background: #EEE;
  transform: rotate(90deg);
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.modal-header h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.modal-header p {
  font-size: 0.85rem;
  margin: 0 auto;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  background: var(--frost);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: var(--space-xl);
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--granite-light);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.auth-tab.active {
  background: var(--snow);
  color: var(--ocean-blue);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeIn 0.3s var(--ease-out);
}

.form-error {
  background: rgba(139, 37, 0, 0.06);
  color: var(--falu-red);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: var(--space-md);
  display: none;
}

.form-error.show {
  display: block;
  animation: shake 0.4s var(--ease-out);
}

.form-success {
  background: rgba(45, 90, 61, 0.06);
  color: var(--pine-green);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: var(--space-md);
  display: none;
}

.form-success.show {
  display: block;
}

.auth-divider {
  text-align: center;
  font-size: 0.75rem;
  color: #B0A99F;
  margin: var(--space-lg) 0;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #E8E4DF;
}

.auth-divider::before {
  left: 0;
}

.auth-divider::after {
  right: 0;
}

/* ---- Dashboard ---- */
.dashboard {
  min-height: 100vh;
  padding-top: 80px;
}

.dashboard-header {
  padding: var(--space-2xl) 0 var(--space-xl);
  border-bottom: 1px solid rgba(0, 63, 114, 0.06);
  margin-bottom: var(--space-2xl);
}

.dashboard-greeting h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  margin-bottom: var(--space-xs);
}

.dashboard-greeting p {
  font-size: 0.9rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-xl);
  padding-bottom: var(--space-3xl);
}

/* Profile Card */
.profile-card {
  position: sticky;
  top: 100px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ocean-blue), var(--ocean-blue-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--snow);
  font-size: 1.5rem;
  font-family: var(--font-display);
  margin-bottom: var(--space-lg);
}

.profile-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.profile-info-row:last-child {
  border-bottom: none;
}

.profile-info-label {
  font-size: 0.8rem;
  color: var(--granite-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.profile-info-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--granite);
}

.role-badge {
  display: inline-flex;
  padding: 0.2rem 0.7rem;
  background: var(--ocean-blue-subtle);
  color: var(--ocean-blue);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Preferences Editor */
.prefs-card {
  position: relative;
}

.prefs-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.prefs-card h3 {
  font-size: 1.15rem;
}

.prefs-actions {
  display: flex;
  gap: var(--space-sm);
}

.prefs-editor {
  width: 100%;
  min-height: 300px;
  padding: var(--space-lg);
  border: 1.5px solid #E8E4DF;
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--granite);
  background: var(--birch-cream);
  resize: vertical;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.prefs-editor:focus {
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 3px rgba(0, 63, 114, 0.08);
}

.prefs-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  font-size: 0.8rem;
  color: var(--granite-light);
  min-height: 24px;
}

.prefs-status.saved {
  color: var(--pine-green);
}

.prefs-status.error {
  color: var(--falu-red);
}

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

/* Toast */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 32px var(--shadow-medium);
  animation: slideInRight 0.3s var(--ease-spring);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.success {
  background: var(--pine-green);
  color: var(--snow);
}

.toast.error {
  background: var(--falu-red);
  color: var(--snow);
}

.toast.info {
  background: var(--ocean-blue);
  color: var(--snow);
}

.toast.leaving {
  animation: slideOutRight 0.3s var(--ease-out) forwards;
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(60px);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

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

/* ---- App Switcher ---- */
.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.app-switcher {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.app-switcher-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--granite-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-switcher-select {
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  border: 1.5px solid #D9D4CF;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--granite);
  background: var(--snow);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236B6B6B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.app-switcher-select:focus {
  border-color: var(--ocean-blue);
  box-shadow: 0 0 0 3px rgba(0, 63, 114, 0.1);
}

/* ---- Admin Panel ---- */
.admin-panel {
  min-height: 100vh;
  padding-top: 80px;
}

.admin-header {
  padding: var(--space-2xl) 0 var(--space-xl);
  border-bottom: 1px solid rgba(0, 63, 114, 0.06);
  margin-bottom: var(--space-2xl);
}

.admin-header p {
  font-size: 0.9rem;
}

/* Stats */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  text-align: center;
  padding: var(--space-xl);
}

.stat-number {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--ocean-blue);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--granite-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: 3px;
  background: var(--frost);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-xl);
  width: fit-content;
}

.admin-tab {
  padding: 0.55rem 1.5rem;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--granite-light);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.admin-tab.active {
  background: var(--snow);
  color: var(--ocean-blue);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

/* Admin Section Cards */
.admin-section {
  margin-bottom: var(--space-xl);
}

.admin-section .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.admin-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 240px;
}

.admin-search .form-input {
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
}

/* Admin Tables */
.admin-table-wrap {
  overflow: visible;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--granite-light);
  border-bottom: 2px solid rgba(0, 63, 114, 0.08);
  white-space: nowrap;
}

.admin-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--granite);
}

.admin-table tbody tr:hover {
  background: var(--birch-cream);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* Admin Pagination */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding-top: var(--space-md);
}

/* Role badge variants */
.role-badge.admin {
  background: rgba(139, 37, 0, 0.08);
  color: var(--falu-red);
}

.role-badge.developer {
  background: rgba(45, 90, 61, 0.08);
  color: var(--pine-green);
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge.active {
  background: rgba(45, 90, 61, 0.1);
  color: var(--pine-green);
}

.status-badge.suspended {
  background: rgba(180, 100, 0, 0.1);
  color: #B46400;
}

.status-badge.disabled {
  background: rgba(139, 37, 0, 0.08);
  color: var(--falu-red);
}

/* Switch and checkbox group */
.switch-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Action dropdown */
.action-group {
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.action-more-wrap {
  position: relative;
  display: inline-block;
}

.action-more-btn {
  font-size: 1.1rem;
  letter-spacing: 1px;
  padding: 0.25rem 0.45rem !important;
  line-height: 1;
  color: var(--granite-light);
  border: 1px solid var(--frost);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  transition: all 0.15s;
}

.action-more-btn:hover {
  background: var(--frost);
  color: var(--granite);
}

.action-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  min-width: 100px;
  background: var(--snow);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  padding: 4px 0;
  animation: dropdown-in 0.15s ease;
}

.action-dropdown.show {
  display: block;
}

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

.action-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 14px;
  font-size: 0.8rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--granite);
  transition: background 0.12s;
}

.action-dropdown button:hover {
  background: var(--frost);
}

.action-dropdown button.danger {
  color: var(--falu-red);
}

/* Clickable number pill */
.clickable-num {
  display: inline-block;
  color: var(--ocean-blue);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(20, 54, 95, 0.06);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  border-bottom: 1px dashed transparent;
}

.clickable-num:hover {
  background: rgba(20, 54, 95, 0.12);
  border-bottom-color: var(--ocean-blue);
}

/* Developer expand row */
.dev-expand-btn {
  font-size: 0.7rem;
  padding: 0.3rem 0.5rem !important;
  min-width: 28px;
  color: var(--granite-light);
}

.dev-apps-row td {
  background: var(--frost);
}

.dev-apps-inner {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
}

.dev-sub-table {
  font-size: 0.82rem;
}

.dev-sub-table th {
  font-size: 0.68rem;
  border-bottom-width: 1px;
}

.dev-sub-table td {
  padding: 0.6rem 1rem;
}

/* Auth Mode Selector */
.auth-mode-selector {
  display: flex;
  gap: var(--space-xs);
  padding: 3px;
  background: var(--ocean-blue-subtle);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-md);
}

.auth-mode-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ocean-blue);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.auth-mode-btn.active {
  background: var(--ocean-blue);
  color: var(--snow);
  box-shadow: 0 2px 8px rgba(0, 63, 114, 0.2);
}

/* Developer Panel */
.developer-panel {
  min-height: 100vh;
  padding-top: 80px;
}

/* Analytics Section */
.analytics-range-selector {
  display: flex;
  gap: 2px;
  background: var(--frost);
  border-radius: var(--radius-full);
  padding: 3px;
}

.analytics-range-btn {
  background: transparent;
  color: var(--granite-light);
  border-radius: var(--radius-full);
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
}

.analytics-range-btn.active {
  background: var(--ocean-blue);
  color: var(--snow);
  box-shadow: 0 2px 8px rgba(0, 63, 114, 0.2);
}

.analytics-summary {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.analytics-stat {
  flex: 1;
  text-align: center;
  padding: var(--space-lg);
  background: var(--frost);
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-out);
}

.analytics-stat:hover {
  background: var(--ocean-blue-subtle);
}

.analytics-stat-number {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--ocean-blue);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.analytics-stat-label {
  font-size: 0.75rem;
  color: var(--granite-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.analytics-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.analytics-chart-card {
  background: var(--frost);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.analytics-chart-card h4 {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--granite);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chart-container {
  width: 100%;
  position: relative;
}

.chart-container canvas {
  width: 100%;
  display: block;
}

/* Admin stats auto grid */
.admin-stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* ---- Confirm Modal ---- */
.confirm-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.confirm-actions .btn {
  flex: 1;
  justify-content: center;
}

/* ---- Toast transitions ---- */
.toast-success {
  background: var(--pine-green);
  color: var(--snow);
}

.toast-error {
  background: var(--falu-red);
  color: var(--snow);
}

.toast {
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s var(--ease-spring);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .profile-card {
    position: static;
  }

  .admin-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .analytics-charts {
    grid-template-columns: 1fr;
  }
}

/* ---- Responsive: Large Phone ---- */
@media (max-width: 768px) {
  :root {
    --space-lg: 1.25rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 3rem;
    --space-4xl: 4rem;
  }

  .hero {
    padding-top: 100px;
    min-height: auto;
    padding-bottom: var(--space-3xl);
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .feature-card {
    padding: var(--space-xl) var(--space-lg);
  }

  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
  }

  .navbar-title {
    font-size: 1rem;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .admin-search {
    min-width: 100%;
  }

  .admin-table {
    font-size: 0.8rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.6rem 0.65rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Responsive: Small Phone ---- */
@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .container {
    padding: 0 var(--space-md);
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .card {
    padding: var(--space-lg);
    border-radius: var(--radius-md);
  }

  .modal {
    padding: var(--space-lg);
  }

  .prefs-editor {
    min-height: 200px;
    font-size: 0.8rem;
  }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
  }

  .auth-divider::before,
  .auth-divider::after {
    width: 30%;
  }

  .stat-number {
    font-size: 1.75rem;
  }
}

/* ---- Responsive: Tablet landscape & iPad ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .hero-content {
    max-width: 550px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

/* ---- Verification Code Styles ---- */
.captcha-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.captcha-img {
  flex-shrink: 0;
  width: 120px;
  height: 40px;
  background: var(--frost);
  border: 1.5px solid #D9D4CF;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.captcha-img:hover {
  border-color: var(--ocean-blue);
}

.captcha-img svg {
  width: 100%;
  height: 100%;
}

.captcha-input {
  flex: 1;
  min-width: 0;
}

.email-code-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.email-code-input {
  flex: 1;
  min-width: 0;
}

.btn-send-code {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem;
  font-size: 0.82rem;
  white-space: nowrap;
  border-radius: var(--radius-md);
}

.btn-send-code:disabled {
  background: var(--frost);
  color: var(--granite-light);
  border-color: #D9D4CF;
  opacity: 0.7;
}

/* ---- System Logs ---- */
.log-stats-bar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.log-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--duration-fast) var(--ease-out);
}

.log-stat-chip .log-stat-count {
  font-family: var(--font-display);
  font-size: 1rem;
}

.log-stat-chip.info {
  background: var(--ocean-blue-subtle);
  color: var(--ocean-blue);
}

.log-stat-chip.warn {
  background: rgba(196, 127, 23, 0.1);
  color: #9a6b10;
}

.log-stat-chip.error {
  background: rgba(139, 37, 0, 0.08);
  color: var(--falu-red);
}

.log-stat-chip.total {
  background: var(--frost);
  color: var(--granite);
}

/* Log level badges */
.log-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.log-level-badge .log-level-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.log-level-badge.info {
  background: var(--ocean-blue-subtle);
  color: var(--ocean-blue);
}

.log-level-badge.info .log-level-dot {
  background: var(--ocean-blue);
}

.log-level-badge.warn {
  background: rgba(196, 127, 23, 0.1);
  color: #9a6b10;
}

.log-level-badge.warn .log-level-dot {
  background: #c47f17;
}

.log-level-badge.error {
  background: rgba(139, 37, 0, 0.08);
  color: var(--falu-red);
}

.log-level-badge.error .log-level-dot {
  background: var(--falu-red);
  animation: pulse 1.5s infinite;
}

/* Log row left-border indicator */
.admin-table tbody tr[data-level="info"] {
  border-left: 3px solid var(--ocean-blue);
}

.admin-table tbody tr[data-level="warn"] {
  border-left: 3px solid #c47f17;
}

.admin-table tbody tr[data-level="error"] {
  border-left: 3px solid var(--falu-red);
  background: rgba(139, 37, 0, 0.02);
}

.admin-table tbody tr[data-level="error"]:hover {
  background: rgba(139, 37, 0, 0.04);
}

/* Log action code tag */
.log-action-tag {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.72rem;
  background: var(--frost);
  color: var(--granite);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Log message */
.log-message {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--granite);
  cursor: default;
  position: relative;
}

.log-message:hover {
  color: var(--ocean-blue);
}

/* App Key with copy */
.log-appkey {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.7rem;
  color: var(--granite-light);
  background: var(--frost);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  border: 1px solid transparent;
}

.log-appkey:hover {
  border-color: var(--ocean-blue);
  color: var(--ocean-blue);
  background: var(--ocean-blue-subtle);
}

.log-appkey .copy-icon {
  opacity: 0;
  font-size: 0.65rem;
  transition: opacity var(--duration-fast);
}

.log-appkey:hover .copy-icon {
  opacity: 1;
}

/* Log time */
.log-time {
  font-size: 0.78rem;
  color: var(--granite-light);
  white-space: nowrap;
}

.log-time-relative {
  display: block;
  font-size: 0.68rem;
  color: #B0A99F;
  margin-top: 2px;
}

/* Refresh button */
.log-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid #D9D4CF;
  border-radius: var(--radius-full);
  background: var(--snow);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--granite);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.log-refresh-btn:hover {
  border-color: var(--ocean-blue);
  color: var(--ocean-blue);
  background: var(--ocean-blue-subtle);
}

.log-refresh-btn.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}

.refresh-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  transition: transform var(--duration-fast);
}

/* Empty state */
.log-empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.log-empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.log-empty-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--granite);
  margin-bottom: var(--space-xs);
}

.log-empty-desc {
  font-size: 0.82rem;
  color: var(--granite-light);
}

/* Log row hover transition */
#admin-logs .admin-table tbody tr {
  transition: all var(--duration-fast) var(--ease-out);
}

/* ---- Print ---- */
@media print {

  .navbar,
  .modal-overlay,
  .toast-container {
    display: none !important;
  }

  body {
    background: white;
  }
}