
:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-hover: #121212;
  --surface-raised: #171717;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #ededed;
  --text-muted: #888888;
  --text-dim: #666666;
  --accent: #ffffff;
  --blue: #0070f3;
  --blue-subtle: rgba(0, 112, 243, 0.12);
  --green: #10b981;
  --green-subtle: rgba(16, 185, 129, 0.12);
  --amber: #f5a623;
  --amber-subtle: rgba(245, 166, 35, 0.12);
  --red: #ee0000;
  --red-subtle: rgba(238, 0, 0, 0.12);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', monospace;
}

* {
  box-sizing: border-box;
}

/* App Layout Grid: Responsive Desktop Sidebar + Mobile Drawer */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg);
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-viewport {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

.container {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

/* Sidebar Elements */
.sidebar-brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-menu {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.menu-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 10px 12px 4px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.menu-link:hover {
  background-color: var(--surface-hover);
  color: #ffffff;
}

.menu-link.active {
  background-color: var(--surface-raised);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--border);
}

.menu-link.active svg {
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 55;
}

/* Mobile Header */
.mobile-header {
  display: none;
  height: 56px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.hamburger-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.hamburger-btn:hover {
  background-color: var(--surface-hover);
  border-color: var(--border-hover);
}

/* Top Navbar inside Container */
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: #ffffff;
}

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

/* Stat Grid */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  margin-bottom: 24px;
  overflow: hidden;
}

.stat-item {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
  transition: background 0.15s;
}

.stat-item:last-child {
  border-right: none;
}

.stat-item:hover {
  background-color: var(--surface-hover);
}

.stat-item-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-item-value {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #ffffff;
  letter-spacing: -0.5px;
}

/* Cards */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 24px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-hover);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Data Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  min-width: 620px;
}

th {
  padding: 11px 16px;
  background-color: #000000;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap !important;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* CRITICAL: Badge and Chip Styling - NEVER WRAP OR SPLIT TEXT */
.badge-fast {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background-color: var(--blue-subtle) !important;
  color: #70b8ff !important;
  border: 1px solid rgba(0, 112, 243, 0.3) !important;
  border-radius: var(--radius-sm) !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  font-family: var(--font-mono) !important;
  white-space: nowrap !important;
  width: max-content !important;
  flex-shrink: 0 !important;
}

.badge-scraper {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background-color: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  width: max-content !important;
  flex-shrink: 0 !important;
}

.token-chip {
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: #ffffff !important;
  background-color: #141414 !important;
  border: 1px solid var(--border) !important;
  padding: 2px 8px !important;
  border-radius: var(--radius-sm) !important;
  display: inline-flex !important;
  align-items: center !important;
  white-space: nowrap !important;
  width: max-content !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.token-chip:hover {
  border-color: var(--border-strong) !important;
  background-color: #1c1c1c !important;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea {
  width: 100%;
  background-color: #000000;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
textarea:focus {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap !important;
  user-select: none;
}

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

.btn-primary {
  background-color: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.btn-primary:hover {
  background-color: #eaeaea;
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background-color: var(--surface-raised);
  border-color: var(--border-hover);
  color: #ffffff;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-danger-sm {
  height: 28px;
  padding: 0 10px;
  background-color: transparent;
  color: #ff6b6b;
  border: 1px solid rgba(238, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap !important;
}

.btn-danger-sm:hover {
  background-color: var(--red-subtle);
  border-color: rgba(238, 0, 0, 0.4);
  color: #ffffff;
}

/* Status Indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border);
  white-space: nowrap !important;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-dim);
}

.status-dot.online {
  background-color: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.status-dot.waiting {
  background-color: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

/* Quality Selector */
.quality-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quality-opt {
  flex: 1;
  min-width: 100px;
  text-align: center;
  background-color: #000000;
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
  transition: all 0.15s ease;
  white-space: nowrap !important;
}

.quality-opt:hover {
  background-color: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.quality-opt.active {
  background-color: var(--surface-raised);
  border-color: #ffffff;
  color: #ffffff;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}

.empty-state-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-dim);
}

.empty-state-text {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Toast System */
#toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  background-color: #111111;
  border: 1px solid var(--border-strong);
  color: #ededed;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  pointer-events: auto;
}

/* Responsive Breakpoints */
@media (max-width: 820px) {
  .stat-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-item:nth-child(2) {
    border-right: none;
  }

  .stat-item:nth-child(-n+2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    z-index: 50;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .main-viewport {
    padding-top: 56px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .container {
    padding: 20px 16px 40px;
  }

  .stat-strip {
    grid-template-columns: 1fr;
  }

  .stat-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .stat-item:last-child {
    border-bottom: none;
  }
}
