/* ──────────────────────────────────────────────────────────────────
   NovaStormIT Partner Dashboard — light theme
   ────────────────────────────────────────────────────────────────── */

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

:root {
  --nvs-purple: #7c4dff;
  --nvs-purple-light: #b388ff;
  --nvs-purple-dim: #5e3dcc;
  --nvs-purple-50: #f5f1ff;
  --nvs-purple-100: #ebe4ff;
  --nvs-accent: #2E9BDA;

  --bg-base: #fafbfd;
  --bg-1: #ffffff;
  --bg-2: #f5f6fa;
  --bg-3: #eef0f6;
  --surface: #ffffff;
  --surface-hover: #f7f8fc;
  --surface-elev: #ffffff;

  --border: #e4e7ee;
  --border-strong: #d4d8e2;
  --border-subtle: #eef0f4;

  --text: #0e1230;
  --text-dim: #5b6079;
  --text-faint: #8a90a8;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;

  --shadow-soft: 0 1px 2px rgba(14, 18, 48, 0.04), 0 4px 12px rgba(14, 18, 48, 0.06);
  --shadow-elev: 0 12px 32px rgba(14, 18, 48, 0.12), 0 4px 12px rgba(14, 18, 48, 0.08);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 1px 2px rgba(14, 18, 48, 0.04);
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 0% 0%, rgba(124, 77, 255, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 35% at 100% 100%, rgba(46, 155, 218, 0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body { position: relative; }
body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

a { color: var(--nvs-purple); text-decoration: none; }
a:hover { color: var(--nvs-purple-dim); }

/* ── Login screen ───────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  box-shadow: var(--shadow-elev);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.75rem;
}
.login-logo img {
  height: 52px;
  width: auto;
  object-fit: contain;
  max-width: 100%;
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 6px;
  text-align: center;
}
.login-card .subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 1.75rem;
  text-align: center;
}

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input, .field select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--nvs-purple);
  box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--nvs-purple), var(--nvs-purple-dim));
  color: white;
  box-shadow: 0 4px 14px rgba(124, 77, 255, 0.32);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(124, 77, 255, 0.44); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn-secondary {
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-2); border-color: var(--border-strong); }

.btn-danger {
  background: var(--bg-1);
  color: var(--danger);
  border: 1px solid var(--border);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.error-msg {
  padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 1rem;
}
.error-msg:empty { display: none; }

/* ── App shell ───────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 24px;
  box-shadow: var(--shadow-card);
}

.topbar-brand { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-brand img { height: 44px; width: auto; object-fit: contain; }
.topbar-brand .pill {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  background: var(--nvs-purple-100);
  color: var(--nvs-purple-dim);
  border-radius: 999px;
}

.topbar-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.topbar-nav a {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 8px;
  transition: all 0.15s;
}
.topbar-nav a:hover { color: var(--nvs-purple-dim); background: var(--nvs-purple-50); }
.topbar-nav a.active { color: var(--nvs-purple-dim); background: var(--nvs-purple-100); }

.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; flex-shrink: 0; }
.topbar-user .who { color: var(--text-dim); }
.topbar-user .who strong { color: var(--text); }
.topbar-user .wl-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  background: var(--info-bg);
  color: var(--info);
  border-radius: 6px;
}

/* ── Stat strip ─────────────────────────────────────────────────── */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 24px 28px 8px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--nvs-purple);
}
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 600;
}
.stat .value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.1;
}
.stat.green::after { background: var(--success); }
.stat.green .value { color: var(--success); }
.stat.amber::after { background: var(--warning); }
.stat.amber .value { color: var(--warning); }
.stat.blue::after { background: var(--info); }

/* ── Toolbar / filters ──────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 28px;
  flex-wrap: wrap;
}
.toolbar input[type=text],
.toolbar input[type=search],
.toolbar select {
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.toolbar input[type=search] { flex: 1; min-width: 240px; }
.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--nvs-purple);
  box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.12);
}
.toolbar label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.toolbar .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s;
}
.toolbar .checkbox-label:hover { border-color: var(--border-strong); background: var(--bg-2); }
.toolbar .checkbox-label input { width: auto; margin: 0; accent-color: var(--nvs-purple); }
.toolbar .toolbar-spacer { flex: 1; }

/* ── Data table ─────────────────────────────────────────────────── */
.table-wrap {
  margin: 0 28px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.table-scroll { overflow: auto; max-height: calc(100vh - 320px); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: auto;
}
.data-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-2);
  z-index: 5;
}
.data-table th {
  text-align: left;
  padding: 12px 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.1s;
}
.data-table th:first-child { padding-left: 16px; }
.data-table th:last-child { padding-right: 16px; }
.data-table th:hover { color: var(--nvs-purple-dim); }
.data-table th.no-sort { cursor: default; }
.data-table th.no-sort:hover { color: var(--text-dim); }
.data-table th .arrow { margin-left: 4px; opacity: 0; font-size: 9px; }
.data-table th.sort-asc .arrow { opacity: 1; }
.data-table th.sort-asc .arrow::before { content: '▲'; color: var(--nvs-purple-dim); }
.data-table th.sort-desc .arrow { opacity: 1; }
.data-table th.sort-desc .arrow::before { content: '▼'; color: var(--nvs-purple-dim); }

.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text);
  white-space: nowrap;  /* default — overridden per cell where helpful */
}
.data-table td:first-child { padding-left: 16px; }
.data-table td:last-child { padding-right: 16px; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover td { background: var(--nvs-purple-50); }

/* Account name column — allow wrap so long names don't push the table wide */
.data-table td.col-account { white-space: normal; max-width: 220px; }
.data-table td.col-broker { white-space: normal; max-width: 180px; }

.cell-account { display: flex; flex-direction: column; gap: 2px; }
.cell-account .name { font-weight: 600; color: var(--text); line-height: 1.25; }
.cell-account .number { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-faint); }

.cell-ea { display: flex; flex-direction: column; gap: 2px; }
.cell-ea .name { font-weight: 600; color: var(--text); }
.cell-ea .ver { font-size: 10px; color: var(--text-faint); }

.cell-date { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.cell-date .d { font-size: 12px; color: var(--text); }
.cell-date .t { font-size: 10px; color: var(--text-faint); }

.cell-stale .d, .cell-stale .t { color: var(--warning); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-wl { background: var(--info-bg); color: var(--info); }
.badge-real { background: var(--success-bg); color: var(--success); }
.badge-demo { background: var(--warning-bg); color: var(--warning); }

.txt-pos { color: var(--success); font-weight: 600; }
.txt-neg { color: var(--danger); font-weight: 600; }
.txt-stale { color: var(--text-faint); }

.algo-on, .algo-off { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; }
.algo-dot { width: 7px; height: 7px; border-radius: 999px; }
.algo-on .algo-dot { background: var(--success); box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18); }
.algo-on { color: var(--success); }
.algo-off .algo-dot { background: var(--text-faint); }
.algo-off { color: var(--text-faint); }

.status-current { color: var(--success); font-weight: 600; }
.status-outdated { color: var(--warning); font-weight: 600; }
.status-pending { color: var(--info); font-weight: 600; }
.status-failed { color: var(--danger); font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

.statusbar {
  padding: 10px 28px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface);
}

/* ── Modals ──────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 18, 48, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-elev);
}
.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Loading spinner ─────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--nvs-purple);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { padding: 60px; text-align: center; color: var(--text-dim); }

/* ── Admin / user list ───────────────────────────────────────────── */
.user-row .role-admin { color: var(--nvs-purple-dim); font-weight: 700; text-transform: capitalize; }
.user-row .role-partner { color: var(--text-dim); text-transform: capitalize; }
.user-row.inactive { opacity: 0.55; }
.user-row.inactive td { font-style: italic; }

.action-cell { display: flex; gap: 6px; flex-wrap: nowrap; }

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 28px 28px 14px;
  color: var(--text);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .topbar-nav { order: 3; width: 100%; overflow-x: auto; justify-content: flex-start; }
  .stat-strip, .toolbar, .table-wrap, .section-title { padding-left: 16px; padding-right: 16px; }
  .table-wrap { margin-left: 16px; margin-right: 16px; }
  .stat .value { font-size: 22px; }
}
