/* Farquaad — Strategy Trader CRM · luxe dark theme (matches rt-trader-ui) */

:root {
  --bg: #181A1F;
  --panel: #1F2229;
  --panel-2: #252932;
  --border: #2C2F35;
  --primary: #20D6CC;
  --primary-600: #19AEA6;
  --text: rgb(239, 243, 244);
  --muted: #9B9B9B;
  --green: #20CF90;
  --red-bright: #EB5555;
  --orange: #FFA462;
  --gold: #FDD65B;
  --purple: #6277E1;
  --platinum: #AEE8FF;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--panel);
  border: 1px solid rgba(32, 214, 204, 0.12);
  border-radius: 16px;
  box-shadow: 0 0 32px rgba(32, 214, 204, 0.04);
  transition: border-color 0.25s ease;
}
.card:hover { border-color: rgba(32, 214, 204, 0.25); }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--primary);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease;
}
.toast-success { border-inline-start-color: var(--primary); }
.toast-error   { border-inline-start-color: var(--red-bright); }
.toast-warn    { border-inline-start-color: var(--orange); }
.toast.out {
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Login ---------- */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 40px 32px 34px;
  text-align: center;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 700;
}
.login-card p {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
}
.login-card input {
  width: 100%;
  text-align: center;
  margin-bottom: 14px;
}
.login-card .btn { width: 100%; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
.shake { animation: shake 0.45s ease; }

/* ---------- Header / nav ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  background: rgba(24, 26, 31, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
}
.brand::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(32, 214, 204, 0.8);
  margin-inline-end: 10px;
}
nav { display: flex; gap: 4px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 10px;
  transition: all 0.2s ease;
}
nav a:hover { color: var(--text); }
nav a.active {
  color: var(--primary);
  background: rgba(32, 214, 204, 0.1);
}
#logout-btn { margin-inline-start: auto; }

/* ---------- Layout ---------- */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Dashboard stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}
.stat { padding: 22px 24px; }
.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.35;
}
.stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .search { width: 280px; max-width: 100%; }
.toolbar .btn { margin-inline-start: auto; }

/* ---------- Inputs / selects / textarea ---------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: linear-gradient(145deg, rgba(37, 41, 50, 0.9), rgba(31, 34, 41, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 9px 14px;
  outline: none;
  transition: all 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(32, 214, 204, 0.1);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 84px; }
select { cursor: pointer; }
select option { background: var(--panel-2); color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  background: var(--primary);
  color: #122726;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn:hover { background: var(--primary-600); }

.btn-ghost {
  font: inherit;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  color: var(--primary);
  background: rgba(32, 214, 204, 0.08);
}
.icon-btn.danger:hover {
  color: var(--red-bright);
  background: rgba(235, 85, 85, 0.08);
}

.btn-sm {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  background: rgba(32, 214, 204, 0.12);
  color: var(--primary);
  border: 1px solid rgba(32, 214, 204, 0.3);
  border-radius: 8px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--primary); color: #122726; }

.btn:focus-visible, .btn-ghost:focus-visible,
.icon-btn:focus-visible, .btn-sm:focus-visible {
  outline: 2px solid rgba(32, 214, 204, 0.5);
  outline-offset: 2px;
}

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}
th {
  text-align: start;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: background 0.2s ease; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
td.empty {
  text-align: center;
  color: var(--muted);
  padding: 44px 16px;
}
.actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.duloc-ok { color: var(--primary); display: inline-flex; }
.settled-ok { color: var(--green); display: inline-flex; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.8;
}
.chip-green    { background: rgba(32, 207, 144, 0.12);  color: var(--green); }
.chip-red      { background: rgba(235, 85, 85, 0.12);   color: var(--red-bright); }
.chip-teal     { background: rgba(32, 214, 204, 0.12);  color: var(--primary); }
.chip-orange   { background: rgba(255, 164, 98, 0.13);  color: var(--orange); }
.chip-purple   { background: rgba(98, 119, 225, 0.15);  color: var(--purple); }
.chip-muted    { background: rgba(155, 155, 155, 0.12); color: var(--muted); }
.chip-gold     { background: rgba(253, 214, 91, 0.12);  color: var(--gold); }
.chip-platinum { background: rgba(174, 232, 255, 0.12); color: var(--platinum); }

/* ---------- Dialog ---------- */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(32, 214, 204, 0.15);
  border-radius: 16px;
  padding: 0;
  width: min(620px, 92vw);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
dialog::backdrop {
  background: rgba(10, 11, 13, 0.65);
  backdrop-filter: blur(3px);
}
dialog[open] { animation: modal-in 0.25s ease; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
#modal-form { padding: 24px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span { font-size: 12px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Responsive (desktop-first) ---------- */
@media (max-width: 768px) {
  header { gap: 12px; padding: 0 14px; }
  nav a { padding: 7px 10px; font-size: 13px; }
  main { padding: 16px; }
  .toolbar .search { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 26px; }
}

/* ---------- Funnel ---------- */
.funnel-h {
  margin: 0;
  padding: 14px 16px 0;
  font-size: 14px;
  font-weight: 600;
}
.funnel-h small {
  font-weight: 400;
  color: var(--muted);
}
.funnel-drop .stat-value {
  font-size: 16px;
  line-height: 1.4;
}
/* A bar rather than a bare number: the shape of the drop-off is the point,
   and 254 → 4 does not read as a cliff in a column of digits. */
.funnel-bar {
  position: relative;
  min-width: 160px;
  height: 22px;
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
}
.funnel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-600), var(--primary));
  opacity: 0.55;
}
.funnel-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-inline-start: 8px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
