/* ==============================================================
   MINER HUB ADMIN PORTAL & CMS
   Design Engineering Standard: Linear / Vercel / Raycast Aesthetic
   Neutral Deep Zinc Palette with Restrained Warm Mineral Brass Accent
   ============================================================== */

:root {
  /* Surface Layers (Deep Matte Zinc) */
  --bg-canvas: #09090b;
  --bg-subtle: #0f0f12;
  --bg-surface: #141418;
  --bg-surface-elevated: #1a1a20;
  --bg-hover: #22222a;
  --bg-active: #2b2b35;

  /* Hairline Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-focus: #C5A059;

  /* Typography Colors */
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-faint: #52525b;

  /* Restrained Warm Mineral Brass / Champagne Gold Accent */
  --accent-gold: #C5A059;
  --accent-gold-hover: #D4B26F;
  --accent-gold-muted: rgba(197, 160, 89, 0.12);
  --accent-gold-border: rgba(197, 160, 89, 0.25);
  --accent-gold-text: #E5C378;

  /* Semantic Status Colors (Linear Muted Pastels) */
  --amber-bg: rgba(245, 158, 11, 0.1);
  --amber-text: #fbbf24;
  --amber-border: rgba(245, 158, 11, 0.22);

  --emerald-bg: rgba(16, 185, 129, 0.1);
  --emerald-text: #34d399;
  --emerald-border: rgba(16, 185, 129, 0.22);

  --cyan-bg: rgba(6, 182, 212, 0.1);
  --cyan-text: #38bdf8;
  --cyan-border: rgba(6, 182, 212, 0.22);

  --purple-bg: rgba(168, 85, 247, 0.1);
  --purple-text: #c084fc;
  --purple-border: rgba(168, 85, 247, 0.22);

  --rose-bg: rgba(244, 63, 94, 0.1);
  --rose-text: #fb7185;
  --rose-border: rgba(244, 63, 94, 0.22);

  --zinc-bg: rgba(113, 113, 122, 0.12);
  --zinc-text: #a1a1aa;
  --zinc-border: rgba(113, 113, 122, 0.22);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transitions (Emil Kowalski curve) */
  --ease-snappy: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 140ms var(--ease-snappy);
  --transition-normal: 200ms var(--ease-snappy);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 20px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border-default);
}

/* ==============================================================
   RESET & BASE
   ============================================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
  letter-spacing: -0.011em;
  overflow-x: hidden;
}

/* Scrollbar refinement */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Keyboard hint tag */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  line-height: 1.2;
}

/* ==============================================================
   BUTTON SYSTEM
   ============================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              transform 100ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button (Refined Warm Mineral Brass) */
.btn-gold {
  background: var(--accent-gold);
  color: #09090b;
  font-weight: 600;
  border: 1px solid var(--accent-gold-hover);
}
.btn-gold:hover {
  background: var(--accent-gold-hover);
}

/* Outline Accent Button */
.btn-outline-gold {
  background: transparent;
  color: var(--accent-gold-text);
  border: 1px solid var(--accent-gold-border);
}
.btn-outline-gold:hover {
  background: var(--accent-gold-muted);
  border-color: var(--accent-gold);
}

/* Secondary Neutral Button */
.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

/* Success / Direct WA Button */
.btn-success {
  background: #15803d;
  color: #ffffff;
  border: 1px solid #16a34a;
}
.btn-success:hover {
  background: #16a34a;
}

/* Destructive Button */
.btn-danger-outline {
  background: transparent;
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}
.btn-danger-outline:hover {
  background: var(--rose-bg);
  border-color: var(--rose-text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

/* ==============================================================
   BADGES & PILLS (Linear / GitHub Style)
   ============================================================== */
.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.status-pill .dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  display: inline-block;
}

/* Tag variants */
.status-pill-amber,
.badge-yellow {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}
.status-pill-amber .dot { background: var(--amber-text); }

.status-pill-emerald,
.badge-green {
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-border);
}
.status-pill-emerald .dot { background: var(--emerald-text); }

.status-pill-cyan,
.badge-blue {
  background: var(--cyan-bg);
  color: var(--cyan-text);
  border: 1px solid var(--cyan-border);
}
.status-pill-cyan .dot { background: var(--cyan-text); }

.status-pill-purple {
  background: var(--purple-bg);
  color: var(--purple-text);
  border: 1px solid var(--purple-border);
}
.status-pill-purple .dot { background: var(--purple-text); }

.status-pill-rose,
.badge-red {
  background: var(--rose-bg);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}
.status-pill-rose .dot { background: var(--rose-text); }

.status-pill-slate,
.badge-gray {
  background: var(--zinc-bg);
  color: var(--zinc-text);
  border: 1px solid var(--zinc-border);
}
.status-pill-slate .dot { background: var(--zinc-text); }

.badge-gold {
  background: var(--accent-gold-muted);
  color: var(--accent-gold-text);
  border: 1px solid var(--accent-gold-border);
}

/* ==============================================================
   AUTH / LOGIN SCREEN (Minimalist Stripe/Linear Architecture)
   ============================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle at 50% 30%, rgba(197, 160, 89, 0.05) 0%, transparent 70%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: authCardEnter 200ms var(--ease-snappy);
}

@keyframes authCardEnter {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-gold-text);
  background: var(--accent-gold-muted);
  border: 1px solid var(--accent-gold-border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  margin-bottom: 14px;
}

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

.auth-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

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

.form-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-help {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select.form-select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  outline: none;
}

input:focus,
textarea:focus,
select.form-select:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  padding-right: 36px;
}

.btn-toggle-pw {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast);
}

.btn-toggle-pw:hover {
  color: var(--text-primary);
}

/* Toggle Switch */
.toggle-group {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.toggle-label {
  font-size: 0.8125rem !important;
  font-weight: 500;
  color: var(--text-primary) !important;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-default);
  transition: var(--transition-fast);
  border-radius: var(--radius-full);
}

.slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: var(--transition-fast);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
}

input:checked + .slider::before {
  transform: translateX(16px);
  background-color: #09090b;
}

/* ==============================================================
   APP LAYOUT (Sidebar + Main View)
   ============================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-canvas);
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon-box {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold-text);
  font-size: 0.8125rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item i {
  font-size: 0.875rem;
  width: 16px;
  text-align: center;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.nav-item:hover i {
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-surface-elevated);
  border-color: var(--border-default);
  color: var(--text-primary);
  font-weight: 600;
}
.nav-item.active i {
  color: var(--accent-gold-text);
}

.nav-item span:first-of-type {
  flex: 1;
}

.nav-item .badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 1px 6px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.625rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-logout:hover {
  color: var(--rose-text);
  background: var(--rose-bg);
}

/* ==============================================================
   MAIN WRAPPER & TOPBAR
   ============================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 52px;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.page-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 3px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10B981;
}

.pulse-dot {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* ==============================================================
   CONTENT CONTAINER & TABS
   ============================================================== */
.content-container {
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: tabFadeIn 160ms var(--ease-snappy);
}

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

/* ==============================================================
   STAT METRIC STRIP (Clean SaaS / Linear Standard)
   ============================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  font-feature-settings: "tnum";
}

.stat-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stat-card.highlight-card {
  border-color: var(--accent-gold-border);
}
.stat-card.highlight-card .stat-icon-wrap {
  color: var(--accent-gold-text);
  background: var(--accent-gold-muted);
}

/* ==============================================================
   CARDS & CONTAINERS
   ============================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-body {
  padding: 20px;
}

/* Filter Card */
.filter-card {
  padding: 10px 14px;
}

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

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  padding-left: 28px;
  padding-right: 28px;
  height: 34px;
}

.btn-clear-search {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group select {
  height: 34px;
  min-width: 150px;
}

.filter-group .btn {
  height: 34px;
}

/* ==============================================================
   PRECISION DATA TABLE
   ============================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

.data-table thead th {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  padding: 9px 16px;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background-color: var(--bg-hover);
}

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

.primary-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-title {
  font-weight: 500;
  color: var(--text-primary);
}

.cell-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 40px 16px !important;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

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

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-info {
  font-family: var(--font-mono);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==============================================================
   SETTINGS GRIDS & FORMS
   ============================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 18px;
}

.max-w-4xl {
  max-width: 760px;
}

.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.test-result-box {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.45;
  font-family: var(--font-mono);
}

.test-result-success {
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-text);
}

.test-result-error {
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  color: var(--rose-text);
}

/* ==============================================================
   MODAL / DRAWER SYSTEM (Emil Kowalski Precision)
   ============================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: backdropEnter 140ms var(--ease-snappy);
}

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

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalEnter 160ms var(--ease-snappy);
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-badge {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--accent-gold-text);
  font-weight: 500;
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.modal-company {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

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

.info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.info-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.info-value {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.phone-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-quote {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 6px;
}

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

/* ==============================================================
   TOAST NOTIFICATION (Sonner Standard)
   ============================================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 400px;
  animation: toastSlideUp 180ms var(--ease-snappy);
  transition: opacity 160ms var(--ease-snappy), transform 160ms var(--ease-snappy);
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-success i { color: #34d399; }
.toast-error i { color: #fb7185; }
.toast-info i { color: var(--accent-gold-text); }

/* ==============================================================
   RESPONSIVE QUERIES
   ============================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform var(--transition-fast);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .grid-2-col,
  .modal-grid-2 {
    grid-template-columns: 1fr;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 14px;
  }
  .content-container {
    padding: 14px;
  }
}
