/* ==========================================================================
   NVIDIA Free Gateway - Design System (Green Theme, Light & Dark)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --primary: #76b900;
  --primary-dark: #5f9400;
  --primary-soft: rgba(118, 185, 0, 0.12);
  --primary-border: rgba(118, 185, 0, 0.35);
  --primary-gradient: linear-gradient(135deg, #76b900 0%, #a3d34c 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-page: #f5f7f2;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f6ee;
  --bg-input: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.85);
  --bg-code: #f4f6f0;

  --border-color: #e4e8de;
  --border-strong: #d3d9c8;

  --text-main: #17210b;
  --text-muted: #5f6c50;
  --text-sub: #8b957d;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(23, 33, 11, 0.06);
  --shadow-md: 0 6px 24px rgba(23, 33, 11, 0.09);
  --shadow-lg: 0 16px 48px rgba(23, 33, 11, 0.16);

  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;
}

:root[data-theme="dark"] {
  --primary: #86cc0a;
  --primary-dark: #6fa800;
  --primary-soft: rgba(134, 204, 10, 0.14);
  --primary-border: rgba(134, 204, 10, 0.4);
  --primary-gradient: linear-gradient(135deg, #86cc0a 0%, #5f9400 100%);

  --bg-page: #0c1210;
  --bg-card: #131b16;
  --bg-card-hover: #1a251d;
  --bg-input: #0f1712;
  --bg-sidebar: #0f1612;
  --bg-header: rgba(12, 18, 16, 0.85);
  --bg-code: #0f1712;

  --border-color: #223026;
  --border-strong: #2e4034;

  --text-main: #e8f0e2;
  --text-muted: #93a38a;
  --text-sub: #6b7a63;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-med), color var(--transition-med);
}

::selection {
  background: var(--primary);
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

code, pre, .mono {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

/* ==========================================================================
   Header
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 28px;
  background: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--primary);
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

:root[data-theme="dark"] .brand-badge {
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 2px 10px rgba(118, 185, 0, 0.3);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 7px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group .hint {
  font-size: 0.75rem;
  color: var(--text-sub);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border-color);
}

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

.switch-row .switch-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.switch-row .switch-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.switch .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-warning { background: rgba(245, 158, 11, 0.14); color: #d97706; }
.badge-danger  { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-info    { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.badge-muted   { background: var(--bg-card-hover); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }

:root[data-theme="dark"] .badge-success { color: #34d399; }
:root[data-theme="dark"] .badge-warning { color: #fbbf24; }
:root[data-theme="dark"] .badge-danger  { color: #f87171; }
:root[data-theme="dark"] .badge-info    { color: #60a5fa; }
:root[data-theme="dark"] .badge-primary { color: var(--primary); }

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

/* ==========================================================================
   Cards & Tables
   ========================================================================== */

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.table-toolbar .toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-toolbar input, .table-toolbar select {
  width: auto;
  min-width: 160px;
  padding: 7px 12px;
  font-size: 0.84rem;
}

.table-responsive {
  overflow-x: auto;
}

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

.admin-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-sub);
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

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

.admin-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.admin-table .cell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.admin-table .cell-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(10, 15, 8, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.98);
  transition: transform var(--transition-med);
}

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

.modal-box.modal-lg {
  max-width: 720px;
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.modal-body {
  padding: 22px 24px;
}

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

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  font-size: 0.86rem;
  animation: toastIn 0.25s ease;
}

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

.toast-item.toast-success { border-left: 4px solid var(--success); }
.toast-item.toast-error   { border-left: 4px solid var(--danger); }
.toast-item.toast-warning { border-left: 4px solid var(--warning); }
.toast-item.toast-info    { border-left: 4px solid var(--info); }

/* ==========================================================================
   Code blocks
   ========================================================================== */

.code-block {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-main);
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-svg-sm {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }
  .header-actions .btn span {
    display: none;
  }
}
