/* ================= TXEVA DASHBOARD OBSIDIAN & VOLT-LIME THEME ================= */
:root {
  --bg-base: #0B0C0E;
  --bg-surface: #121519;
  --bg-card: #181C22;
  --bg-hover: #20252E;
  --border: #242A35;
  --border-focus: #AFCF01;

  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;

  --volt: #AFCF01;
  --volt-glow: rgba(175, 207, 1, 0.25);
  --emerald: #10B981;
  --blue: #3B82F6;
  --amber: #F59E0B;
  --red: #EF4444;
  --purple: #8B5CF6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Cairo", Tahoma, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
}

/* ================= UTILITIES ================= */
.hidden { display: none !important; }
.text-center { text-align: center; }
.highlight-green { color: var(--emerald); }
.badge-code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid var(--border);
  direction: ltr;
  display: inline-block;
}

/* ================= AUTH SCREEN ================= */
.auth-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #1a2212 0%, var(--bg-base) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 40px rgba(175, 207, 1, 0.08);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 440px;
  width: 100%;
  animation: fadeIn 0.3s ease-out;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.brand-badge.mini { margin-bottom: 0; }

.brand-logo {
  width: 48px;
  height: 48px;
  background: var(--volt);
  color: #0B0C0E;
  font-weight: 900;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 0 15px var(--volt-glow);
  letter-spacing: -0.5px;
}
.brand-logo.mini {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.brand-meta h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}
.brand-meta span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-form .form-group {
  margin-bottom: 18px;
}
.auth-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrapper input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 14px;
  padding-left: 42px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}
.input-wrapper input:focus {
  border-color: var(--volt);
  box-shadow: 0 0 0 3px var(--volt-glow);
}

.icon-btn {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--red);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.primary-btn {
  width: 100%;
  background: var(--volt);
  color: #0B0C0E;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.primary-btn:hover {
  background: #C4E600;
  box-shadow: 0 4px 14px var(--volt-glow);
  transform: translateY(-1px);
}
.primary-btn:active {
  transform: translateY(0);
}

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

/* ================= MAIN NAVIGATION ================= */
.top-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.nav-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--volt);
  font-weight: 600;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--volt);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--volt);
  animation: pulse 2s infinite;
}

.period-selector {
  display: flex;
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 2px;
}
.period-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
}
.period-btn:hover {
  color: #fff;
}
.period-btn.active {
  background: var(--bg-card);
  color: var(--volt);
  font-weight: 700;
  border: 1px solid rgba(175, 207, 1, 0.3);
}

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

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.nav-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.nav-btn.secondary {
  color: var(--volt);
}
.nav-btn.secondary:hover {
  border-color: var(--volt);
}
.nav-btn.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.badge-mini {
  background: rgba(175, 207, 1, 0.15);
  color: var(--volt);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

/* ================= MAIN CONTENT ================= */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ================= STATS GRID ================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
}
.stat-card.volt::before { background: var(--volt); }
.stat-card.emerald::before { background: var(--emerald); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.amber::before { background: var(--amber); }

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-icon {
  font-size: 1.2rem;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
  letter-spacing: -1px;
  margin-bottom: 12px;
}
.stat-card.volt .stat-value { color: var(--volt); }

.stat-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
}
.stat-breakdown span strong {
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* ================= CHARTS GRID ================= */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.chart-card.large {
  grid-column: 1 / -1;
}

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

.card-title h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}
.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.legend-color.volt { background: var(--volt); }
.legend-color.emerald { background: var(--emerald); }

.chart-container {
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.chart-placeholder, .loading-state {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  padding: 30px;
}

/* SVG Chart Elements */
.svg-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.svg-grid line {
  stroke: var(--border);
  stroke-dasharray: 4,4;
}
.svg-axis text {
  fill: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
}
.chart-path-tokens {
  fill: none;
  stroke: var(--volt);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 6px rgba(175, 207, 1, 0.4));
}
.chart-area-tokens {
  fill: url(#voltGrad);
  opacity: 0.25;
}
.chart-bar-cost {
  fill: var(--emerald);
  opacity: 0.75;
  transition: var(--transition);
}
.chart-bar-cost:hover {
  opacity: 1;
}

/* Models List */
.model-list, .tools-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.model-row, .tool-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.model-row-head, .tool-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.model-name, .tool-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  direction: ltr;
}
.model-stats, .tool-stats {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.bar-track {
  width: 100%;
  height: 7px;
  background: var(--bg-base);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease-out;
}
.bar-fill.volt { background: var(--volt); }
.bar-fill.blue { background: var(--blue); }
.bar-fill.emerald { background: var(--emerald); }
.bar-fill.amber { background: var(--amber); }

/* ================= SECTION & TABLES ================= */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.search-box input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  width: 280px;
  outline: none;
  transition: var(--transition);
}
.search-box input:focus {
  border-color: var(--volt);
  box-shadow: 0 0 0 3px var(--volt-glow);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-top: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: right;
}
.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: var(--transition);
}
.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.device-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.device-name {
  font-weight: 700;
  color: #fff;
}
.device-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  direction: ltr;
}

.badge-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}
.badge-tag.blue { background: rgba(59, 130, 246, 0.15); color: #93C5FD; }
.badge-tag.volt { background: rgba(175, 207, 1, 0.15); color: var(--volt); }

.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--volt);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.action-btn:hover {
  background: var(--volt);
  color: #0B0C0E;
  font-weight: 700;
}

/* ================= MODAL ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.25s ease-out;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}
.close-btn:hover {
  color: #fff;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ================= FOOTER ================= */
.bottom-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ================= ANIMATIONS ================= */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .nav-center {
    overflow-x: auto;
  }
  .nav-right {
    justify-content: space-between;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
