/* Castaneda Management Group — Internal Portal
   Dark dashboard theme: deep navy, amber accent, multicolor chart palette. */

:root {
  /* Surfaces */
  --bg: #0A0E1F;
  --bg-2: #0E1428;
  --surface: #181E36;
  --surface-2: #1F2746;
  --surface-3: #262F52;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --text: #E8ECF7;
  --text-mid: #A8B0C8;
  --text-dim: #6B7493;
  --text-faint: #4A5170;

  /* Brand + chart series */
  --amber: #F59E0B;
  --amber-2: #FBBF24;
  --rose: #F43F5E;
  --rose-2: #FB7185;
  --cyan: #06B6D4;
  --violet: #A855F7;
  --emerald: #10B981;
  --orange: #FB923C;
  --indigo: #6366F1;

  /* Status */
  --good: #10B981;
  --warn: #F59E0B;
  --bad: #F43F5E;

  /* Effects */
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.55);
  --glow-amber: 0 0 30px rgba(245, 158, 11, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(245, 158, 11, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(168, 85, 247, 0.10), transparent 55%),
    var(--bg);
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-2); }

/* ============ LOGIN ============ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
@media (max-width: 880px) { .login-shell { grid-template-columns: 1fr; } }

.login-hero {
  position: relative;
  overflow: hidden;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(800px 400px at 80% 20%, rgba(245, 158, 11, 0.25), transparent 60%),
    radial-gradient(700px 400px at 20% 90%, rgba(168, 85, 247, 0.18), transparent 60%),
    linear-gradient(135deg, #0F1530 0%, #0A0E1F 100%);
  color: var(--text);
}
.login-hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(6, 182, 212, 0.12) 0%, transparent 30%),
    radial-gradient(circle at 90% 70%, rgba(244, 63, 94, 0.10) 0%, transparent 35%);
  pointer-events: none;
}
.login-hero::after {
  /* subtle grid */
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 30%, transparent 80%);
  pointer-events: none;
}
.login-hero > * { position: relative; z-index: 1; }

.brand-mark {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--text);
}
.brand-mark .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: var(--glow-amber);
}
.brand-mark span { color: var(--amber); }

.hero-headline {
  font-size: 52px; line-height: 1.05; margin: 0 0 18px;
  background: linear-gradient(135deg, #FFFFFF 0%, #C6CDE6 60%, #8B95B8 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-tag {
  font-size: 17px; line-height: 1.55;
  color: var(--text-mid);
  margin: 0 0 36px;
  max-width: 460px;
}
.hero-stats {
  display: flex; gap: 32px; flex-wrap: wrap;
  margin-top: 24px;
}
.hero-stat { min-width: 0; }
.hero-stat .num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px; font-weight: 600;
  color: var(--amber);
}
.hero-stat .lab {
  font-size: 12px; color: var(--text-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.hero-foot {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
}

.login-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 64px 56px;
  background: var(--bg-2);
}
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 30px; margin: 0 0 8px; }
.login-card .subtitle { color: var(--text-mid); margin: 0 0 32px; font-size: 15px; }

.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-dim); margin-bottom: 8px;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.field input {
  width: 100%; padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
  background: var(--surface-2);
}

.btn-primary {
  width: 100%; padding: 14px 18px;
  background: linear-gradient(135deg, var(--amber), #D97706);
  color: #1A1106;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: 8px;
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.30);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 10px 24px rgba(245, 158, 11, 0.42); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  background: rgba(244, 63, 94, 0.10);
  color: #FCA5A5;
  border: 1px solid rgba(244, 63, 94, 0.30);
  padding: 10px 12px; border-radius: 8px;
  font-size: 14px; margin-bottom: 16px;
  display: none;
}
.error-msg.show { display: block; }
.turnstile-wrap { margin: 6px 0 14px; min-height: 0; }
.turnstile-wrap:empty { margin: 0; }

/* ============ APP SHELL (sidebar + main) ============ */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.sidebar {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand-mark {
  padding: 4px 8px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.sidebar-section {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 12px 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--text-mid);
  font-size: 14px; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.03));
  color: var(--text);
  position: relative;
}
.nav-link.active::before {
  content: '';
  position: absolute; left: -18px; top: 25%; bottom: 25%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--amber);
  box-shadow: var(--glow-amber);
}
.nav-link .icon {
  width: 18px; height: 18px; flex-shrink: 0;
  opacity: 0.85;
}
.nav-link.active .icon { opacity: 1; color: var(--amber); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-mid);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--rose));
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: #1A1106;
  flex-shrink: 0;
}
.sidebar-foot .meta { min-width: 0; flex: 1; }
.sidebar-foot .meta .name { color: var(--text); font-weight: 500; font-size: 13px; }
.sidebar-foot .meta .role { font-size: 11px; color: var(--text-dim); }
.sidebar-foot button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 4px 8px; border-radius: 6px;
}
.sidebar-foot button:hover { color: var(--text); background: var(--surface); }

/* ============ TOPBAR ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 36px 0;
  gap: 24px;
}
.topbar h1 {
  font-size: 28px; margin: 0;
  font-weight: 600;
}
.topbar .sub {
  font-size: 13px; color: var(--text-dim);
  margin-top: 2px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text-mid);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); border-color: rgba(255, 255, 255, 0.2); }
.chip.is-active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber-2);
}

/* ============ DASHBOARD GRID ============ */
.dash {
  padding: 28px 36px 60px;
}
.grid {
  display: grid;
  gap: 20px;
}
.grid.kpis {
  grid-template-columns: repeat(4, 1fr);
}
.grid.row-chart {
  grid-template-columns: 2fr 1fr;
  margin-top: 20px;
}
.grid.row-table {
  grid-template-columns: 1.55fr 1fr;
  margin-top: 20px;
}
@media (max-width: 1180px) {
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.row-chart, .grid.row-table { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.card .card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card .card-head h3 {
  font-size: 14px; font-weight: 500;
  color: var(--text-mid);
  margin: 0;
  letter-spacing: 0.04em;
}
.card .card-head .more {
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.card .card-head .more:hover { color: var(--text); background: var(--surface-3); }

.kpi .big {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 34px; font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.05;
}
.kpi .big .unit { font-size: 18px; color: var(--text-dim); font-weight: 500; margin-left: 4px; }
.kpi .delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500;
  margin-top: 8px;
}
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }
.kpi .delta .since { color: var(--text-dim); margin-left: 6px; font-weight: 400; }
.kpi .sub-line { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.kpi.is-feature {
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(245, 158, 11, 0.02) 60%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-color: rgba(245, 158, 11, 0.28);
}
.kpi.is-feature .big { color: var(--amber-2); }

/* Card with a chart inside */
.card.chart-card { padding: 22px 22px 16px; }
.card.chart-card h2 {
  font-size: 18px; font-weight: 600;
  margin: 0 0 4px;
}
.card.chart-card .chart-sub {
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 18px;
}
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 320px; }
.chart-wrap.donut { height: 280px; }

.legend {
  display: flex; flex-wrap: wrap; gap: 14px 22px;
  margin-top: 14px;
  font-size: 13px; color: var(--text-mid);
}
.legend .item { display: inline-flex; align-items: center; gap: 8px; }
.legend .dot {
  width: 10px; height: 10px; border-radius: 50%;
}

/* ============ TABLE ============ */
.table-wrap { overflow: auto; }
table.dash-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px;
}
table.dash-table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 12px 14px;
  border-bottom: 1px solid var(--border);
}
table.dash-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-mid);
  vertical-align: middle;
}
table.dash-table tr:last-child td { border-bottom: none; }
table.dash-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
table.dash-table .vendor {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 500;
}
table.dash-table .vendor .vlogo {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
table.dash-table .amount {
  color: var(--text); font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}
table.dash-table .prop {
  color: var(--text-mid);
}
table.dash-table .pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.pill.good { background: rgba(16, 185, 129, 0.12); color: #34D399; }
.pill.warn { background: rgba(245, 158, 11, 0.14); color: var(--amber-2); }
.pill.bad  { background: rgba(244, 63, 94, 0.12); color: #FB7185; }

/* ============ PROPERTIES LIST ============ */
.props-card .prop-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.props-card .prop-row:hover { background: var(--surface-3); }
.props-card .prop-row .label {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.props-card .prop-row .label .name {
  color: var(--text); font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.props-card .prop-row .label .sub {
  color: var(--text-dim); font-size: 12px;
}
.props-card .prop-row .amount {
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}
.props-card .scroll { max-height: 380px; overflow-y: auto; padding-right: 4px; }
.props-card .scroll::-webkit-scrollbar { width: 6px; }
.props-card .scroll::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ============ PORTAL HUB ============ */
.hub-wrap { padding: 36px 36px 80px; }
.hub-head h1 { font-size: 36px; margin: 0 0 6px; }
.hub-head p { color: var(--text-mid); font-size: 16px; margin: 0 0 32px; }

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.agent-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px 22px;
  min-height: 200px;
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative; overflow: hidden;
}
.agent-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
  border-color: rgba(245, 158, 11, 0.35);
}
.agent-card .agent-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.30), rgba(244, 63, 94, 0.20));
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.agent-card h3 { margin: 0 0 6px; font-size: 19px; }
.agent-card p { color: var(--text-mid); font-size: 14px; line-height: 1.55; margin: 0; flex-grow: 1; }
.agent-card .card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 4px;
  background: rgba(16, 185, 129, 0.14); color: #34D399;
}
.badge.soon { background: rgba(255, 255, 255, 0.06); color: var(--text-dim); }
.last-visit { font-size: 12px; color: var(--text-dim); }
.agent-card.soon { opacity: 0.7; }

/* ============ BACK TO PORTAL PILL ============ */
.cmg-portal-nav {
  position: fixed; bottom: 18px; left: 18px;
  z-index: 2147483647;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 16px 9px 14px;
  border-radius: 999px;
  font: 600 13px 'Inter', system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.cmg-portal-nav:hover { background: var(--surface-3); color: var(--amber-2); }

/* ============ SCROLLBAR (global) ============ */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); }
