/* ============================================================
   unlimitzCloud Design System — v2
   dark, clean, premium SaaS dashboard
   ============================================================ */
:root {
  --bg:         #0b0b0b;
  --bg-2:       #111111;
  --panel:      #161616;
  --panel-2:    #1c1c1c;
  --line:       #242424;
  --line-2:     #333;
  --text:       #ebebeb;
  --text-2:     #c0c0c0;
  --muted:      #7a7a7a;
  --muted-2:    #4a4a4a;
  /* Status colors */
  --ok:         #4ade80;
  --ok-dim:     rgba(74,222,128,.12);
  --ok-line:    rgba(74,222,128,.28);
  --fail:       #f87171;
  --fail-dim:   rgba(248,113,113,.10);
  --fail-line:  rgba(248,113,113,.28);
  --warn:       #fbbf24;
  --warn-dim:   rgba(251,191,36,.10);
  --warn-line:  rgba(251,191,36,.28);
  /* Geometry */
  --r: 12px;
  --r-sm: 8px;
  --r-xs: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }

/* ── Nav ──────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11,11,11,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex; align-items: center; gap: 0;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; letter-spacing: -.2px;
  margin-right: 28px; white-space: nowrap;
}
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.nav-links {
  display: flex; align-items: center; gap: 2px; flex: 1;
}
.nav-links a {
  display: inline-flex; align-items: center;
  padding: 6px 11px; border-radius: var(--r-xs);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: var(--panel-2); }
.nav-links a.active { color: var(--text); background: var(--panel-2); }
.nav-links a.admin-only { display: none; }

/* ── Nav user section (right side) ───────────────── */
.nav-user {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto; padding-left: 16px; position: relative;
}
.balance-chip {
  font-size: 12.5px; font-weight: 600;
  color: var(--ok); background: var(--ok-dim);
  border: 1px solid var(--ok-line); border-radius: 99px;
  padding: 3px 10px; cursor: default; white-space: nowrap;
}
.user-pill {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); border-radius: 99px;
  padding: 4px 12px 4px 6px;
  cursor: pointer; transition: border-color .15s;
  user-select: none;
}
.user-pill:hover { border-color: #4a4a4a; }
.avatar-sm {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-2); flex-shrink: 0;
}
.nav-username { font-size: 13px; font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 160px; background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  overflow: hidden; z-index: 100;
}
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; padding: 9px 14px;
  font-size: 13px; color: var(--text-2); text-align: left;
  background: none; border: none; cursor: pointer;
  transition: background .12s, color .12s;
}
.user-dropdown a:hover, .user-dropdown button:hover {
  background: var(--line); color: var(--text);
}
.user-dropdown .dd-sep { height: 1px; background: var(--line); margin: 3px 0; }

/* ── Layout ───────────────────────────────────────── */
.container {
  max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px;
}

/* ── Hero header ──────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-header p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ── Grid ─────────────────────────────────────────── */
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }

/* ── Card ─────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.card-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-2); margin: 0 0 14px;
  text-transform: uppercase; letter-spacing: .06em;
}

/* ── Stat cards ───────────────────────────────────── */
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px;
}
.stat-card .kicker {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 30px; font-weight: 700; line-height: 1; }

/* ── Forms ────────────────────────────────────────── */
label {
  display: block; margin-bottom: 5px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
input, select, textarea {
  width: 100%; background: var(--bg-2);
  border: 1px solid var(--line-2); color: var(--text);
  border-radius: var(--r-sm); padding: 9px 11px;
  outline: none; font-size: 13.5px; font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: #555; }
textarea { min-height: 88px; resize: vertical; }
.form-group { display: flex; flex-direction: column; gap: 0; }

/* ── Buttons ──────────────────────────────────────── */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-sm); padding: 8px 14px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, opacity .15s; border: 1px solid transparent;
  font-family: inherit; line-height: 1;
}
button, .btn { background: var(--text); color: #000; border-color: var(--text); }
button:hover, .btn:hover { opacity: .88; }
button.ghost, .btn.ghost {
  background: transparent; color: var(--text-2); border-color: var(--line-2);
}
button.ghost:hover, .btn.ghost:hover { border-color: #555; color: var(--text); background: var(--panel-2); }
button.danger, .btn.danger {
  background: transparent; color: var(--fail); border-color: var(--fail-line);
}
button.danger:hover, .btn.danger:hover { background: var(--fail-dim); }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12px; }

/* ── Filter bar ───────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px;
}
.filter-bar input, .filter-bar select {
  flex: 1; min-width: 140px; max-width: 240px;
}
.filter-bar label { display: none; }

/* ── Table ────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: auto; background: var(--panel);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead tr { border-bottom: 1px solid var(--line-2); }
tbody tr { border-bottom: 1px solid var(--line); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }
th {
  padding: 9px 12px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}
td { padding: 9px 12px; font-size: 13.5px; color: var(--text-2); }
td.primary { color: var(--text); font-weight: 500; }

/* ── Inline editable cells ────────────────────────── */
.cell-edit {
  cursor: pointer; position: relative;
  padding: 7px 12px !important;
}
.cell-edit:hover { background: rgba(255,255,255,.04); }
.cell-edit .edit-val { display: inline-flex; align-items: center; gap: 5px; }
.cell-edit .edit-val::after {
  content: "✎";
  font-size: 11px; color: var(--muted-2);
  opacity: 0; transition: opacity .15s;
}
.cell-edit:hover .edit-val::after { opacity: 1; }
.cell-edit input, .cell-edit select {
  width: 100%; min-width: 80px; max-width: 160px;
  padding: 4px 8px; font-size: 13px; background: var(--bg);
  border: 1px solid #555; border-radius: var(--r-xs);
}

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  border-radius: 99px; padding: 2px 9px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--line-2); color: var(--text-2);
}
.badge.ok  { background: var(--ok-dim);   border-color: var(--ok-line);   color: var(--ok); }
.badge.fail{ background: var(--fail-dim); border-color: var(--fail-line); color: var(--fail); }
.badge.warn{ background: var(--warn-dim); border-color: var(--warn-line); color: var(--warn); }

/* ── Misc helpers ─────────────────────────────────── */
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ── Toast ────────────────────────────────────────── */
#toast-container { position: fixed; right: 16px; bottom: 16px; z-index: 999; display: flex; flex-direction: column; gap: 6px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 11px 15px;
  max-width: 340px; font-size: 13px; color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: toast-in .2s ease; opacity: 1; transition: opacity .3s;
}
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 24px; min-width: 320px; max-width: 480px;
  width: 90vw; box-shadow: 0 16px 48px rgba(0,0,0,.7);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .nav-links a { font-size: 12.5px; padding: 5px 8px; }
}
@media (max-width: 600px) {
  .brand span { display: none; }
  .nav-username { display: none; }
  .balance-chip { display: none; }
}
