:root {
  --bg: #080d18;
  --bg-elev: #0f172a;
  --bg-card: #131d33;
  --bg-hover: #1a2744;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff9900;
  --accent-soft: rgba(255, 153, 0, 0.14);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.14);
  --amber: #f59e0b;
  --purple: #a855f7;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top right, #14213d 0%, var(--bg) 52%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login Overlay */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 34px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
}
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 153, 0, 0.35);
  margin-bottom: 14px;
}

/* Main App Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 262px;
  background: rgba(10, 16, 30, 0.96);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #ff9900, #f59e0b);
  color: #080d18;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 17px;
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  border: 1px solid transparent;
  margin-bottom: 4px;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(255, 153, 0, 0.32);
}
.nav-pill {
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 13, 24, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.content {
  padding: 24px 26px 50px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

/* Cards & Grids */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 1.45fr 1fr; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.kpi-card {
  background: linear-gradient(180deg, rgba(25, 37, 66, 0.72), rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 700; }
.kpi-value { font-size: 25px; font-weight: 800; margin: 5px 0 3px; color: #fff; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: var(--emerald-soft); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-amber { background: var(--accent-soft); color: #fbbf24; border: 1px solid rgba(255, 153, 0, 0.35); }
.badge-blue { background: var(--blue-soft); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.32); }
.badge-red { background: var(--rose-soft); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.35); }
.badge-slate { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.22); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #ff9900, #f59e0b); color: #0b1120; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-green { background: #10b981; color: #052e16; }
.btn-green:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(244, 63, 94, 0.16); color: #fb7185; border-color: rgba(244, 63, 94, 0.35); }
.btn-danger:hover { background: rgba(244, 63, 94, 0.28); }
.btn-ghost { background: rgba(148, 163, 184, 0.1); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.2); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

.input, select, textarea {
  width: 100%;
  background: #0a1120;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label.lbl { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.field { margin-bottom: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: rgba(8, 13, 24, 0.45);
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* Alert banner */
.banner {
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
}
.banner-warn { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.38); color: #fde68a; }
.banner-ok { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.35); color: #a7f3d0; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}
.toast {
  background: #0f172a;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.toast.ok { border-left-color: var(--emerald); }
.toast.err { border-left-color: var(--rose); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.img-preview { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.opp-card { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }

@media (max-width: 1120px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; gap: 6px; }
  .sidebar-logo { display: none; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
}
