:root {
  --bg: #F5F3EF;
  --surface: #FFFFFF;
  --ink: #1A1A1A;
  --ink-soft: #55606B;
  --red: #BE1E2D;
  --red-dark: #8F1621;
  --red-soft: #F4DEDF;
  --line: #E2DDD3;
  --good: #2F7D4F;
  --good-bg: #E5F1E9;
  --warn: #9A6B00;
  --warn-bg: #FBF0DA;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 30px rgba(20, 15, 15, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314; --surface: #1D1F21; --ink: #EDEBE7; --ink-soft: #9BA3AB;
    --red: #E1545E; --red-dark: #BE1E2D; --red-soft: #3A2426; --line: #2C2E31;
    --good: #6FBF8B; --good-bg: #1C2B22; --warn: #D9A441; --warn-bg: #2E2712;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- animated background (auth pages) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(18,14,13,0.90), rgba(18,14,13,0.96)), url('img/auth-hero.jpg') center/cover no-repeat, #14100f;
}
.auth-shell::before, .auth-shell::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.55; z-index: 0;
}
.auth-shell::before {
  width: 520px; height: 520px; background: var(--red);
  top: -160px; left: -120px;
  animation: float1 16s ease-in-out infinite;
}
.auth-shell::after {
  width: 420px; height: 420px; background: #3a5b7a;
  bottom: -140px; right: -100px;
  animation: float2 20s ease-in-out infinite;
}
@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.12); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.08); }
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-lg);
  padding: 34px 30px 28px;
  color: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: cardIn 0.5s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .fmark { width: 168px; height: auto; border-radius: 10px; box-shadow: 0 6px 22px rgba(0,0,0,0.35); }
.auth-brand .name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.auth-brand .sub { font-size: 12.5px; color: rgba(255,255,255,0.65); }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: rgba(255,255,255,0.7); margin-bottom: 6px; font-weight: 600;
}
.auth-card input, .auth-card select {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22); background: rgba(0,0,0,0.22); color: #fff;
  font-size: 14.5px; font-family: 'Inter', sans-serif;
}
.auth-card input::placeholder { color: rgba(255,255,255,0.4); }
.auth-card input:focus, .auth-card select:focus { outline: none; border-color: var(--red); background: rgba(0,0,0,0.32); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 11px; padding: 12px 18px;
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 14.5px; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; box-shadow: 0 6px 20px rgba(190,30,45,0.35);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(190,30,45,0.5); }
.btn-primary:disabled { opacity: 0.55; cursor: default; box-shadow: none; }
.btn-block { width: 100%; }
.btn-ghost {
  background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.25);
}
.btn-ghost:hover { background: rgba(255,255,255,0.14); }
.btn-outline {
  background: transparent; color: var(--red); border: 1.5px solid var(--red);
}
.btn-outline:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger.armed { background: var(--red-dark); }

.auth-msg { min-height: 18px; font-size: 13px; margin-top: 10px; text-align: center; }
.auth-msg.err { color: #ff9aa2; font-weight: 600; }
.auth-msg.ok { color: #8ee6ac; font-weight: 600; }
.auth-foot { text-align: center; font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 18px; }
.auth-foot a { color: #fff; font-weight: 700; text-decoration: underline; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.spinner.dark { border-color: var(--line); border-top-color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell (post-login) ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--red); color: #fff; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between; height: 58px;
  position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; }
.topbar .fmark { height: 26px; width: auto; border-radius: 5px; }
.topbar .brand span { font-size: 15px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: rgba(255,255,255,0.85); text-decoration: none; font-weight: 600; font-size: 13.5px;
  padding: 8px 12px; border-radius: 8px; transition: background 0.15s;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,0.18); color: #fff; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .who .pill {
  background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.topbar .logout-btn {
  background: rgba(0,0,0,0.18); color: #fff; border: none; padding: 7px 12px; border-radius: 8px;
  font-weight: 600; font-size: 12.5px; cursor: pointer;
}
.topbar .logout-btn:hover { background: rgba(0,0,0,0.3); }

main.container { max-width: 900px; margin: 0 auto; padding: 22px 20px 60px; width: 100%; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.note { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.note strong { color: var(--ink); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: none; background: none; padding: 10px 14px; font-weight: 600; font-size: 13.5px;
  color: var(--ink-soft); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--red); border-bottom-color: var(--red); }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.admin { background: var(--red-soft); color: var(--red); }
.badge.sales { background: var(--good-bg); color: var(--good); }
.badge.active { background: var(--good-bg); color: var(--good); }
.badge.suspended { background: var(--red-soft); color: var(--red); }
.badge.open { background: var(--warn-bg); color: var(--warn); }
.badge.won { background: var(--good-bg); color: var(--good); }
.badge.lost { background: var(--red-soft); color: var(--red); }

.toast-wrap { position: fixed; bottom: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); animation: toastIn 0.25s ease; max-width: 320px;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--good); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  font-family: 'Inter', sans-serif; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--red); }
label.f-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); margin-bottom: 4px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }

@media (max-width: 640px) {
  .topbar nav { display: none; }
  .topbar { padding: 0 12px; }
}
