/* ================================================================
   index.css - Global Styles & Design System
   ================================================================
   This contains all styling variables, form design, buttons,
   and animations to ensure a premium, modern user interface.
   ================================================================ */

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

/* ================================================================
   DESIGN TOKENS (Variables)
   ================================================================ */
:root {
  /* Chameleons brand: pastel sky blue, peach, live orange */
  --bg-primary: #f4f7fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef3fb;

  --text-primary: #1a1e26;
  --text-secondary: #6b7280;
  --text-muted: #94a3b8;

  --accent-color: #ff701f;
  --accent-hover: #ea580c;
  --accent-glow: rgba(255, 112, 31, 0.18);
  --brand-blue: #aecdfb;
  --brand-blue-soft: #bfdbfe;
  --brand-peach: #fdba74;
  --brand-peach-soft: #fed7aa;
  --brand-navy: #334155;
  --brand-teal: #60a5fa;
  --brand-teal-soft: #93c5fd;
  --brand-gold: #fdba74;
  --brand-gradient: linear-gradient(90deg, #bfdbfe 0%, #fed7aa 100%);
  --brand-gradient-strong: linear-gradient(90deg, #93c5fd 0%, #fdba74 100%);

  --success-color: #16a34a;
  --error-color: #ef4444;
  --warning-color: #ff701f;

  --border-color: rgba(147, 197, 253, 0.45);
  --border-focus: rgba(255, 112, 31, 0.4);
  --app-header-h: 76px;
  --border-radius-sm: 10px;
  --border-radius-md: 14px;
  --border-radius-lg: 18px;

  --admin-card: #ffffff;
  --admin-border: rgba(174, 205, 251, 0.7);
  --admin-text: #1a1e26;
  --admin-muted: #6b7280;
  --admin-primary: #ff701f;
  --admin-primary-dark: #ea580c;
  --admin-green-rgb: 255, 112, 31;

  --font-family-sans: 'Inter', sans-serif;
  --font-family-display: 'Outfit', sans-serif;

  --shadow-sm: 0 1px 3px rgba(26, 30, 38, 0.05);
  --shadow-md: 0 12px 32px rgba(37, 99, 235, 0.08), 0 4px 12px rgba(249, 115, 22, 0.06);
  --shadow-lg: 0 22px 48px rgba(26, 30, 38, 0.08);
  --shadow-glow: 0 12px 28px rgba(249, 115, 22, 0.28);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================
   RESET & SYSTEM WRAPPERS
   ================================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover {
  color: var(--accent-hover);
}

/* ================================================================
   COMMON LAYOUTS
   ================================================================ */
.auth-page-container {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.08) 0%, transparent 42%),
              radial-gradient(circle at 88% 82%, rgba(249, 115, 22, 0.08) 0%, transparent 42%);
  padding: 24px;
}

/* Glassmorphism Card style */
.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg), 0 20px 25px -5px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

/* Subtle top gradient glow on active cards */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-color), var(--success-color));
}

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

.auth-title {
  font-family: var(--font-family-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ================================================================
   INPUTS & FORM STYLING
   ================================================================ */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.form-input {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  font-family: var(--font-family-sans);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 24px;
  font-family: var(--font-family-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}

.btn-primary {
  background-color: var(--accent-color);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

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

.btn:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* ================================================================
   FEEDBACK & ALERTS
   ================================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert[hidden] {
  display: none !important;
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

.alert-success {
  background-color: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.22);
  color: #15803d;
}

/* Switch page link style */
.auth-switch-text {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-switch-link {
  color: var(--accent-color);
  font-weight: 500;
  cursor: pointer;
}
.auth-switch-link:hover {
  text-decoration: underline;
}
.auth-switch-link.is-disabled {
  color: var(--text-secondary);
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

/* ================================================================
   DASHBOARD LAYOUT - Sidebar + Main Content
   ================================================================ */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-primary);
  max-width: 100vw;
  overflow-x: hidden;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-header-h);
  z-index: 400;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  backdrop-filter: blur(16px);
  box-shadow: none;
}

.app-header-left,
.app-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-header-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-header-refresh:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--accent-color);
}

.app-header-refresh:disabled {
  opacity: 0.65;
  cursor: wait;
}

.app-header-refresh-icon {
  display: block;
  flex-shrink: 0;
}

.app-header-refresh.is-loading .app-header-refresh-icon {
  animation: appHeaderRefreshSpin 0.75s linear infinite;
}

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

@media (max-width: 720px) {
  .app-header-refresh-label {
    display: none;
  }
  .app-header-refresh {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
}

.app-header-menu {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  padding: 10px 11px;
  flex-shrink: 0;
  box-sizing: border-box;
  line-height: 0;
}
.app-header-menu span {
  display: block;
  width: 100%;
  height: 2px;
  margin: 5px 0;
  background: #0f172a;
  border-radius: 99px;
  transition: transform 0.3s ease, opacity 0.25s ease;
}
.dashboard-layout.is-nav-open .app-header-menu span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.dashboard-layout.is-nav-open .app-header-menu span:nth-child(2) {
  opacity: 0;
}
.dashboard-layout.is-nav-open .app-header-menu span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-family-display);
  font-weight: 800;
  font-size: inherit;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-width: 0;
  flex-shrink: 0;
}
.app-header-brand-text {
  display: block;
  white-space: nowrap;
  line-height: 1.1;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}
.app-header-brand .sidebar-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}
.app-header-brand .sidebar-logo-icon img {
  width: 22px;
  height: 22px;
}
.app-header-wordmark,
.app-header-title,
.app-header-kicker {
  display: none !important;
}

.app-user-menu {
  position: relative;
}

.app-user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  max-width: 280px;
}

.app-user-status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.app-user-menu-trigger:hover,
.app-user-menu.open .app-user-menu-trigger {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.app-user-menu-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.app-user-menu-chevron {
  font-size: 11px;
  color: #94a3b8;
}

.app-user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  display: none;
  z-index: 420;
}

.app-user-menu.open .app-user-menu-dropdown {
  display: block;
}

.app-user-menu-meta {
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 6px;
}

.app-user-menu-meta strong {
  font-size: 13px;
  color: var(--text-primary);
}

.app-user-menu-meta span {
  font-size: 12px;
  color: var(--text-muted);
}

.app-user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.app-user-menu-item:hover {
  background: #f1f5f9;
}

.app-user-menu-item-signout {
  color: #dc2626;
}

/* --- Sidebar --- */
.sidebar {
  width: 250px;
  height: calc(100vh - var(--app-header-h));
  background: #fff;
  border-right: 1px solid rgba(174, 205, 251, 0.7);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 20px;
  position: fixed;
  top: var(--app-header-h);
  left: 0;
  z-index: 100;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 24px 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #bfdbfe 0%, #fed7aa 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e3a8a;
  flex-shrink: 0;
  box-shadow: none;
  border: 1px solid rgba(37, 99, 235, 0.12);
}
.sidebar-logo-icon img,
.app-logo-mark img,
.auth-stage-mark img {
  display: block;
  width: 22px;
  height: 22px;
}
.app-logo-mark img {
  width: 26px;
  height: 26px;
}

.sidebar-logo-text {
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-label {
  display: none;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #eef4fb;
  color: #64748b;
  border: 1px solid rgba(174, 205, 251, 0.5);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-nav-item:hover {
  background: linear-gradient(90deg, rgba(191, 219, 254, 0.55) 0%, rgba(254, 215, 170, 0.45) 100%);
  color: #1a1e26;
}

.sidebar-nav-item:hover .nav-icon {
  background: #fff;
  color: #475569;
}

.sidebar-nav-item.active {
  background: var(--brand-gradient);
  color: #1a1e26;
  box-shadow: 0 8px 18px rgba(147, 197, 253, 0.35);
  border: none;
  font-weight: 700;
}

.sidebar-nav-item.active .nav-icon {
  background: #fff;
  color: #475569;
  border-color: rgba(255, 255, 255, 0.8);
}

.sidebar-bottom {
  padding: 16px 0 0;
  border-top: 1px solid rgba(174, 205, 251, 0.7);
  margin-top: 12px;
  flex-shrink: 0;
}

.sidebar-download {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: #1a1e26;
  background: linear-gradient(90deg, rgba(191, 219, 254, 0.7) 0%, rgba(254, 215, 170, 0.65) 100%);
  border: 1px solid rgba(147, 197, 253, 0.6);
  box-shadow: 0 6px 14px rgba(147, 197, 253, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(253, 186, 116, 0.35);
  color: #1a1e26;
}

.sidebar-download-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.sidebar-download-copy strong {
  font-size: 13px;
  font-weight: 700;
}

.sidebar-download-copy small {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

/* --- Main Content Area --- */
.main-content {
  margin-left: 250px;
  margin-top: var(--app-header-h);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--app-header-h));
  min-width: 0;
  padding: 8px 20px 24px;
}

.page-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 4px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: var(--app-header-h);
  z-index: 50;
}

.page-header-title {
  font-family: var(--font-family-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-body {
  padding: 12px 4px 8px;
  flex: 1;
  min-width: 0; /* Prevents layout spills on narrow resolutions */
}

/* ================================================================
   STAT CARDS (Summary Row at the Top)
   ================================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.stat-card:hover {
  border-color: #fdba74;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(147, 197, 253, 0.22);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1e3a8a; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.yellow { background: #ffedd5; color: #c2410c; }
.stat-icon.purple { background: #e0e7ff; color: #3730a3; }

.stat-value {
  font-family: var(--font-family-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================================================================
   SECTION CARD WRAPPER
   ================================================================ */
.section-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

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

.section-card-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.table-responsive-wrapper {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ================================================================
   DATA TABLE
   ================================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 24px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px 24px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

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

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* ================================================================
   STATUS BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-online {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.22);
}

.badge-offline {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.badge-approved {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}

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

.badge-dot.pulse {
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ================================================================
   BUTTONS (Extended)
   ================================================================ */
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--border-radius-sm);
}

.btn-ghost {
  background: #ffffff;
  color: #2563eb;
  border: 1.5px solid rgba(37, 99, 235, 0.28);
}

.btn-ghost:hover {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-color: #2563eb;
}

.btn-danger-ghost {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.1);
  box-shadow: none;
}

.btn-success {
  background-color: var(--success-color);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #15803d;
  box-shadow: 0 10px 22px rgba(22, 163, 74, 0.25);
}

/* Width variants */
.btn-auto { width: auto; }

/* ================================================================
   MODAL OVERLAY
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

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

.modal-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #f87171; /* red cross */
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
}

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

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state-icon {
  opacity: 0.3;
}

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

.empty-state-text {
  font-size: 13px;
  text-align: center;
  max-width: 300px;
  line-height: 1.6;
}

/* ================================================================
   INPUT HELPER TEXT & CREDENTIAL BOX
   ================================================================ */
.form-helper {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.credential-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--success-color);
  margin-top: 12px;
  line-height: 1.8;
}

.credential-label {
  color: var(--text-muted);
  font-family: var(--font-family-sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

/* ================================================================
   DEVICE NAME CELL
   ================================================================ */
.device-name-cell {
  display: flex;
  flex-direction: column;
}

.device-alias {
  font-weight: 600;
  color: var(--text-primary);
}

.device-hostname {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ================================================================
   INTERVAL EDITOR (Inline)
   ================================================================ */
.interval-editor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.interval-input {
  width: 64px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
  outline: none;
}

.interval-input:focus {
  border-color: var(--accent-color);
}

/* Loading spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

.spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ================================================================
   SCREENSHOTS HISTORY & LIVE VIEW MODALS
   ================================================================ */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content.large {
  width: 90vw;
  max-width: 1024px;
}

.modal-content.medium {
  width: 80vw;
  max-width: 720px;
}

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

.modal-title {
  font-family: var(--font-family-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-close {
  background: none;
  border: none;
  color: #f87171; /* red cross */
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body.scrollable {
  max-height: calc(85vh - 75px);
}

/* Modals loading & empty states */
.modal-loading, .modal-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.modal-loading .spinner {
  margin-bottom: 12px;
}

.modal-empty-state div {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Screenshot card grid layout */
.screenshots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.screenshot-item-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.screenshot-item-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color);
}

.screenshot-preview-container {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.screenshot-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screenshot-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

.screenshot-item-card:hover .screenshot-hover-overlay {
  opacity: 1;
}

.screenshot-metadata-footer {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
}

.screenshot-date-text {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Image loading placeholder */
.img-loader-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 12px;
}

.img-loader-placeholder.error {
  background: var(--bg-primary);
  color: var(--error-color);
  border: 1px dashed var(--border-color);
}

/* Fullscreen Overlay Style */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 7, 12, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.fullscreen-close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-close-btn:hover {
  background: rgba(255,255,255,0.18);
}

.fullscreen-download-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.fullscreen-download-btn:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.34);
}

.fullscreen-image-wrapper {
  max-width: 90vw;
  max-height: 85vh;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.fullscreen-image {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  display: block;
}

/* Live View Elements */
.live-screens-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.live-image-container {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.live-image-container.cursor-pointer {
  cursor: pointer;
}

.live-image-container:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.live-image-view {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.screenshot-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.live-image-container:hover .screenshot-hover-overlay {
  opacity: 1;
}

.live-controls-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success-color);
  border-radius: 50%;
  margin-left: 6px;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.5; }
}

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

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

/* ================================================================
   RESPONSIVE LAYOUT & MEDIA QUERIES
   ================================================================ */

/* Devices table & mobile cards toggle */
.desktop-only-table { display: block; }
.mobile-only-cards { display: none; }
.devices-table { width:100%; border-collapse:collapse; min-width:860px; }
.devices-table th { padding:12px 16px; text-align:left; font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.8px; color:var(--text-muted); background-color:var(--bg-tertiary); border-bottom:1px solid var(--border-color); white-space:nowrap; }
.devices-table td { padding:14px 16px; font-size:13px; color:var(--text-primary); border-bottom:1px solid var(--border-color); vertical-align:middle; }
.devices-table tbody tr:hover { background-color:var(--bg-tertiary); }
.device-actions-cell { display:flex; flex-wrap:wrap; gap:5px; min-width:180px; }

/* Sidebar backdrop (hidden by default, shown in 768px breakpoint) */
.sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.55); z-index:250; backdrop-filter:blur(2px); }
.mobile-header { display:none; }

@media (min-width:1440px) { .stats-row { grid-template-columns:repeat(4,1fr); } }

@media (max-width:1024px) {
  .sidebar { width:220px; }
  .main-content { margin-left:220px; }
  .page-header { padding:10px 0 12px; }
  .page-body { padding:8px 0; }
  .stats-row { grid-template-columns:repeat(2,1fr); gap:14px; }
  .overview-grid { grid-template-columns:1fr; gap:16px; }
}

@media (max-width:768px) {
  .dashboard-layout { --app-header-h: 56px; flex-direction: column; }
  .app-header {
    height: var(--app-header-h);
    padding: 0 16px;
    gap: 10px;
  }
  .app-header-left {
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .app-header-right {
    flex: 0 0 auto;
    gap: 8px;
  }
  .app-header-menu {
    display: block;
    width: 42px;
    height: 42px;
    padding: 10px 11px;
  }
  /* Keep brand identical to landing header */
  .app-header-brand {
    gap: 10px;
    font-size: inherit;
    letter-spacing: 0.06em;
    flex-shrink: 0;
  }
  .app-header-brand .sidebar-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .app-header-brand .sidebar-logo-icon img {
    width: 22px;
    height: 22px;
  }
  .app-user-menu-trigger {
    padding: 8px 10px;
    gap: 6px;
    font-size: 12px;
    max-width: 88px;
  }
  .app-user-menu-email {
    max-width: 48px;
  }
  .app-user-menu-chevron {
    display: none;
  }
  .sidebar-backdrop { display:block; }
  .sidebar { width:75vw; max-width:280px; height:calc(100vh - var(--app-header-h)); top:var(--app-header-h); transform:translateX(-100%); transition:transform 0.28s cubic-bezier(0.4,0,0.2,1); box-shadow:6px 0 30px rgba(0,0,0,0.2); z-index:300; padding-top:16px; background:#fff; }
  .sidebar.open { transform:translateX(0); }
  .main-content { margin-left:0 !important; width:100%; max-width:100vw; overflow-x:hidden; padding: 8px 12px 16px; }
  .page-header { padding:8px 0 10px; flex-direction:column; align-items:flex-start; gap:8px; }
  .page-header > div:last-child { width:100%; display:flex; flex-wrap:wrap; gap:8px; }
  .page-body { padding:8px 0; overflow-x:hidden; }
  
  /* 2x2 Grid for Stat Cards on Mobile (Prevents 4 vertical full-screen stacked cards) */
  .stats-row { grid-template-columns:repeat(2, 1fr) !important; gap:8px !important; margin-bottom:14px !important; }
  .stat-card { padding:10px 12px !important; gap:8px !important; border-radius:var(--border-radius-md) !important; }
  .stat-value { font-size:18px !important; line-height:1.1 !important; }
  .stat-label { font-size:10px !important; letter-spacing:0.3px !important; }
  .stat-icon { width:32px !important; height:32px !important; border-radius:8px !important; flex-shrink:0 !important; }
  
  .overview-grid { grid-template-columns:1fr !important; gap:12px !important; }
  .device-table-container,.table-responsive-wrapper { overflow-x:auto; width:100%; -webkit-overflow-scrolling:touch; }
  .section-card-header { padding:12px 14px; flex-wrap:wrap; gap:8px; }
  .modal-backdrop {
    padding: 16px;
    align-items: center;
    justify-content: center;
  }
  .modal-box,
  .confirm-dialog-box {
    width: min(100%, 440px);
    max-width: calc(100vw - 32px);
    max-height: min(90vh, 90dvh);
    margin: 0 auto;
    border-radius: var(--border-radius-lg) !important;
    overflow: auto;
    align-self: center;
  }
  #liveViewModal .modal-box.live-view-modal,
  .modal-box.live-view-modal {
    width: min(100%, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: min(92vh, 92dvh) !important;
    overflow: hidden;
  }
  .live-view-footer {
    padding: 12px 14px !important;
    gap: 10px;
  }
  .live-view-footer-actions {
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
  }
  .live-view-footer-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .live-view-footer .live-fps {
    width: 100%;
  }
  .live-fps-btn {
    min-width: 34px;
    height: 34px;
  }
  .modal-content {
    width: min(100%, 96vw) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(90vh, 90dvh);
    margin: 0 auto;
    border-radius: var(--border-radius-lg) !important;
    overflow: hidden;
    align-self: center;
  }
  .modal-content.medium,
  .modal-content.large {
    width: min(100%, 96vw) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(92vh, 92dvh);
    border-radius: var(--border-radius-lg) !important;
  }
  .modal-header { padding: 14px 16px 12px; }
  .modal-body { padding: 14px 16px !important; overflow-y: auto; }
  .modal-body.scrollable { max-height: calc(90vh - 65px); overflow-y: auto; padding: 14px 16px !important; }
  .report-summary-grid { grid-template-columns:1fr !important; gap:10px !important; }
  
  /* Gallery grid: 1 column on mobile */
  .gallery-grid { grid-template-columns:1fr !important; gap:12px !important; }

  /* Mobile Filter Row Wrap & Inputs */
  .filter-row-wrap { flex-direction:column !important; align-items:stretch !important; gap:10px !important; }
  .filter-row-wrap > div,
  .filter-item-search,
  .filter-item-device,
  .filter-item-date-pair {
    min-width:100% !important;
    width:100% !important;
  }
  .filter-item-search input,
  .filter-item-device select {
    width:100% !important;
  }
  .filter-item-date-pair {
    display:flex !important;
    align-items:center !important;
    gap:6px !important;
  }
  .filter-item-date-pair input.date-input {
    flex:1 !important;
    width:100% !important;
    min-width:0 !important;
  }

  /* Live view controls footer stacks on mobile */
  .live-controls-footer { flex-direction:column; align-items:stretch !important; gap:10px !important; }
  .live-controls-footer > div { width:100%; justify-content:space-between; }
  .live-controls-footer button { width:100%; justify-content:center; }

  /* Report table stats - 2 columns */
  .report-stats-row { flex-wrap:wrap; }
  .report-stats-row > div { flex: 1 1 calc(50% - 8px) !important; min-width:calc(50% - 8px) !important; }

  /* Section card inner padding reduction */
  .section-card { border-radius:var(--border-radius-md); }
  .section-card > div:first-child { padding:12px 14px !important; }

  /* Mobile Device Cards View */
  .desktop-only-table { display: none !important; }
  .mobile-only-cards { display: flex !important; flex-direction: column; gap: 12px; padding: 12px; }
  .mobile-device-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
  }
  .mobile-device-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
  }
  .mobile-device-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    padding: 10px 0;
    margin: 10px 0;
    border-top: 1px dashed var(--border-color);
    border-bottom: 1px dashed var(--border-color);
    font-size: 11px;
  }
  .mobile-device-grid-item-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
  }
  .mobile-device-grid-item-val {
    font-weight: 500;
    color: var(--text-primary);
  }
  .mobile-device-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}

@media (max-width:480px) {
  /* Maintain 2x2 grid for stat cards on small screens */
  .stats-row { grid-template-columns:repeat(2, 1fr) !important; gap:6px !important; }
  .stat-card { padding:8px 10px !important; gap:6px !important; }
  .stat-value { font-size:16px !important; }
  .stat-label { font-size:9px !important; }
  .stat-icon { width:28px !important; height:28px !important; }
  
  .page-header-title { font-size:16px; }
  .page-body { padding:8px; }
  .modal-body { padding:12px 14px !important; }

  /* Fullscreen live view controls — stack buttons vertically */
  .fullscreen-overlay .live-controls-btns { flex-direction:column; gap:8px; align-items:stretch; }
  .fullscreen-overlay .live-controls-btns button { width:100%; }
}

@media (max-width:360px) {
  .mobile-header { padding:8px 12px; }
  .page-body { padding:6px; }
  .section-card-header { padding:10px 12px; }
}

