/* ══════════════════════════════════════════════════════════
   InfraOps — Dark Terminal Industrial Theme
   ══════════════════════════════════════════════════════════ */

:root {
  --bg-base:      #0a0b0e;
  --bg-surface:   #0f1117;
  --bg-elevated:  #161922;
  --bg-hover:     #1c2030;
  --bg-input:     #12151f;
  --border:       #1e2535;
  --border-light: #252d42;

  --text-primary:   #e2e8f8;
  --text-secondary: #7a8aaa;
  --text-muted:     #3d4a66;
  --text-accent:    #4d9fff;

  --accent:       #4d9fff;
  --accent-dim:   #1a3a6e;
  --accent-glow:  rgba(77, 159, 255, 0.15);

  --green:        #00d18c;
  --green-dim:    #003d29;
  --orange:       #ff8c42;
  --orange-dim:   #3d2200;
  --red:          #ff4444;
  --red-dim:      #3d0000;
  --yellow:       #ffd166;

  --sidebar-w:    220px;
  --topbar-h:     56px;
  --radius:       6px;
  --radius-sm:    4px;

  --font-mono:  'JetBrains Mono', monospace;
  --font-ui:    'Syne', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.brand-icon {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.nav-list {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-left-color: var(--border-light);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  padding: 8px 0;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--red); }

/* ── Main Content ────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.topbar-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.content-body {
  padding: 28px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.accent::before  { background: var(--accent); }
.stat-card.green::before   { background: var(--green); }
.stat-card.orange::before  { background: var(--orange); }
.stat-card.red::before     { background: var(--red); }
.stat-card.yellow::before  { background: var(--yellow); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.stat-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ── Tables ──────────────────────────────────────────────── */

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface);
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

td.muted { color: var(--text-secondary); }
td.mono  { font-family: var(--font-mono); }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.badge-green   { background: var(--green-dim);  color: var(--green);  }
.badge-orange  { background: var(--orange-dim); color: var(--orange); }
.badge-red     { background: var(--red-dim);    color: var(--red);    }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }
.badge-unknown { background: #1a1e2e; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #3a8ae8; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-hover); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red-dim);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Forms ───────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

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

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

input::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }

select option { background: var(--bg-elevated); }

/* ── Flash Messages ──────────────────────────────────────── */

.flash {
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 12px;
  border-left: 3px solid;
}

.flash-success { background: var(--green-dim);  border-color: var(--green);  color: var(--green); }
.flash-error   { background: var(--red-dim);    border-color: var(--red);    color: var(--red);   }
.flash-info    { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Section Header ──────────────────────────────────────── */

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

.section-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Alert / Warning Boxes ───────────────────────────────── */

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 12px;
  font-size: 12px;
}
.alert-red    { background: var(--red-dim);    border-color: var(--red);    color: var(--text-primary); }
.alert-orange { background: var(--orange-dim); border-color: var(--orange); color: var(--text-primary); }
.alert-accent { background: var(--accent-dim); border-color: var(--accent); color: var(--text-primary); }

.alert strong { color: inherit; }

/* ── Dashboard Grid ──────────────────────────────────────── */

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

@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* ── Progress Bar ────────────────────────────────────────── */

.progress-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

.progress-fill.green  { background: var(--green); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.red    { background: var(--red); }

/* ── Login Page ──────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(77, 159, 255, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 209, 140, 0.03) 0%, transparent 50%);
}

.login-box {
  width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  font-size: 36px;
  color: var(--accent);
  display: block;
  margin-bottom: 10px;
}

.login-logo h1 {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 8px; }

.login-error {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 16px;
}

/* ── Inline Tag List ─────────────────────────────────────── */

.tag { display: inline-block; background: var(--bg-hover); border: 1px solid var(--border-light); color: var(--text-secondary); padding: 1px 7px; border-radius: 3px; font-size: 10px; margin: 1px; }

/* ── Toolbar (filter row) ────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input, .toolbar select { max-width: 220px; }

/* ── Provider Balance Bar ────────────────────────────────── */

.balance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.balance-row:last-child { border-bottom: none; }
.balance-meta { flex: 1; }
.balance-name { font-weight: 700; font-size: 12px; color: var(--text-primary); }
.balance-amount { font-size: 22px; font-weight: 800; font-family: var(--font-ui); }
.balance-runway { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.balance-amount.ok     { color: var(--green); }
.balance-amount.warn   { color: var(--orange); }
.balance-amount.danger { color: var(--red); }

/* ── Deposit History ─────────────────────────────────────── */

.deposit-list { font-size: 12px; }
.deposit-item {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.deposit-item:last-child { border-bottom: none; }
.deposit-amount { color: var(--green); font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: min(700px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title { font-family: var(--font-ui); font-size: 14px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Scrollbar ───────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utility ─────────────────────────────────────────────── */

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }
.text-accent { color: var(--accent); }
.font-mono   { font-family: var(--font-mono); }
.nowrap      { white-space: nowrap; }
.w-full      { width: 100%; }
.d-flex      { display: flex; gap: 10px; align-items: center; }
.flex-end    { justify-content: flex-end; }
