/* ===================================================================
   Neuraforz Digital Marketing Tracker — styles
   =================================================================== */
:root {
  --bg: #0b1020;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --line: #e6e8f0;
  --ink: #1a1c2b;
  --ink-soft: #5b6076;
  --ink-faint: #8b90a6;
  --brand: #6d28d9;
  --brand-2: #4f46e5;
  --brand-3: #06b6d4;
  --brand-grad: linear-gradient(135deg, #6d28d9 0%, #4f46e5 45%, #06b6d4 100%);
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #2563eb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 22, 50, .12);
  --shadow-sm: 0 2px 8px rgba(20, 22, 50, .08);
  --sidebar-w: 268px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
code {
  background: rgba(109, 40, 217, .1);
  color: var(--brand);
  padding: 1px 7px;
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 600;
}

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--brand-grad);
  color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 6px 16px rgba(109, 40, 217, .35);
}
.brand.small .brand-mark { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; letter-spacing: .14em; }
.brand-text span { font-size: 11.5px; color: var(--ink-faint); letter-spacing: .02em; }

/* =================================================================
   LOGIN
   ================================================================= */
.login-view {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 15% -10%, #1e1b4b, transparent),
              radial-gradient(1000px 700px at 110% 110%, #0e7490, transparent),
              var(--bg);
}
.login-bg { position: absolute; inset: 0; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.orb-1 { width: 340px; height: 340px; background: #7c3aed; top: -80px; left: -60px; animation: float 12s ease-in-out infinite; }
.orb-2 { width: 300px; height: 300px; background: #06b6d4; bottom: -70px; right: -40px; animation: float 15s ease-in-out infinite reverse; }
.orb-3 { width: 220px; height: 220px; background: #4f46e5; top: 40%; left: 55%; animation: float 18s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(28px,-24px); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } }

.login-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: rgba(255,255,255,.98);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 20px;
  padding: 34px 32px 26px;
  box-shadow: 0 30px 70px rgba(0,0,0,.45);
  animation: rise .5s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.login-title { margin: 22px 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 11px;
  background: var(--surface-2); color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 4px rgba(109,40,217,.14);
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.eye-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 8px; border-radius: 9px;
  color: var(--ink-faint); display: grid; place-items: center;
  transition: color .15s, background .15s;
}
.eye-btn:hover { color: var(--brand); background: rgba(109,40,217,.08); }

.login-error {
  color: var(--bad); font-size: 13px; font-weight: 600;
  min-height: 18px; margin: -6px 0 12px;
}

.btn-primary {
  background: var(--brand-grad); color: #fff; border: none;
  padding: 13px 18px; border-radius: 11px; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 10px 22px rgba(79,70,229,.35);
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 14px 28px rgba(79,70,229,.45); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { filter: grayscale(.3) brightness(.95); cursor: default; }
.btn-block { width: 100%; }

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-hint {
  margin-top: 22px; padding: 13px 15px;
  background: linear-gradient(135deg, rgba(109,40,217,.07), rgba(6,182,212,.07));
  border: 1px dashed rgba(109,40,217,.35);
  border-radius: 12px;
  display: flex; gap: 12px; align-items: center;
}
.login-hint p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.login-hint strong { color: var(--ink); }
.hint-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-3); flex: none; box-shadow: 0 0 0 4px rgba(6,182,212,.18); }
.login-foot { position: relative; z-index: 1; margin-top: 26px; color: rgba(255,255,255,.65); font-size: 12px; text-align: center; }

/* =================================================================
   APP SHELL
   ================================================================= */
.app-view { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: #0f1226;
  color: #cfd3e6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
  z-index: 40;
}
.sidebar-head {
  padding: 18px 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-head .brand-text span { color: #8890b5; }
.sidebar-search { padding: 12px 14px 8px; }
.sidebar-search input {
  width: 100%; padding: 9px 12px; font-size: 13px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05); color: #e7e9f5;
}
.sidebar-search input::placeholder { color: #6f759a; }
.sidebar-search input:focus { outline: none; border-color: var(--brand); background: rgba(255,255,255,.09); }

.menu { flex: 1; overflow-y: auto; padding: 6px 10px 14px; }
.menu::-webkit-scrollbar { width: 8px; }
.menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0; border-radius: 10px;
  color: #b7bcd8; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; width: 100%; text-align: left; background: none;
  transition: background .13s, color .13s;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active {
  background: linear-gradient(135deg, rgba(109,40,217,.35), rgba(6,182,212,.22));
  color: #fff; border-color: rgba(139,92,246,.5);
}
.menu-item .mi-icon { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 14px; }
.menu-item.active .mi-icon { background: rgba(255,255,255,.2); }
.menu-item .mi-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-empty { color: #6f759a; font-size: 13px; padding: 14px; text-align: center; }

.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: var(--brand-grad);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 13.5px; color: #fff; }
.user-meta span { font-size: 11px; color: #8890b5; }

.icon-btn {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #cfd3e6; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; transition: background .13s, color .13s;
}
.icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px; display: flex; align-items: center; gap: 14px;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar-titles h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-titles p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.table-search input {
  padding: 9px 13px; font-size: 13px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; width: 190px; max-width: 40vw;
}
.table-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,40,217,.12); }
.btn-ghost {
  background: #fff; border: 1.5px solid var(--line); color: var(--ink-soft);
  padding: 9px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  transition: border-color .13s, color .13s, background .13s;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.topbar .btn-primary { padding: 10px 16px; font-size: 13.5px; box-shadow: var(--shadow-sm); }

.content { padding: 22px; flex: 1; }
.loading { color: var(--ink-faint); padding: 40px; text-align: center; }

/* =================================================================
   TABLE (editable grid)
   ================================================================= */
.table-meta { color: var(--ink-faint); font-size: 12.5px; margin-bottom: 12px; }
.table-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; min-width: max-content; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--ink-soft);
  font-weight: 700; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase;
  text-align: left; padding: 11px 13px; white-space: nowrap;
  border-bottom: 2px solid var(--line);
}
table.grid tbody td {
  padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.grid tbody tr:hover { background: #faf9ff; }
table.grid .section-row td {
  background: linear-gradient(90deg, rgba(109,40,217,.1), transparent);
  font-weight: 800; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand); padding: 10px 13px;
}
.cell-input {
  width: 100%; min-width: 90px; border: 1px solid transparent; background: transparent;
  padding: 7px 8px; font: inherit; color: var(--ink); border-radius: 7px;
  transition: border-color .12s, background .12s;
}
.cell-input:hover { border-color: var(--line); }
.cell-input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(109,40,217,.12); }
.cell-input.dirty { background: #fffbeb; border-color: #fcd34d; }
.cell-input.saved { background: #ecfdf5; border-color: #6ee7b7; }

td.row-actions { white-space: nowrap; text-align: center; }
.del-btn {
  background: none; border: none; color: var(--ink-faint); padding: 6px; border-radius: 8px;
  display: inline-grid; place-items: center; transition: color .12s, background .12s;
}
.del-btn:hover { color: var(--bad); background: rgba(220,38,38,.1); }
.rownum { color: var(--ink-faint); font-size: 12px; text-align: center; padding: 0 6px; user-select: none; }

/* status/priority pills auto-applied by JS */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill-green { background: #dcfce7; color: #15803d; }
.pill-amber { background: #fef3c7; color: #b45309; }
.pill-red { background: #fee2e2; color: #b91c1c; }
.pill-blue { background: #dbeafe; color: #1d4ed8; }
.pill-grey { background: #eef0f5; color: #565c72; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-faint); }
.empty-state svg { opacity: .5; margin-bottom: 10px; }

/* =================================================================
   DASHBOARD / KPI cards
   ================================================================= */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-grad); }
.kpi-card .k-label { font-size: 12px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .k-value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }

.section-title { font-size: 14px; font-weight: 800; letter-spacing: .02em; margin: 26px 0 12px; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 3px; background: var(--brand-grad); }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }

.kpi-section-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 18px;
}
.kpi-section-card .kpi-section-head {
  padding: 12px 16px; font-weight: 800; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--brand-grad);
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #10141f; color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 100;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #7f1d1d; }

/* =================================================================
   RESPONSIVE
   ================================================================= */
.sidebar-overlay { display: none; }
.only-mobile { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100dvh;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .app-view.menu-open .sidebar { transform: translateX(0); }
  .sidebar-overlay {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(6,8,20,.55); opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .app-view.menu-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .topbar { padding: 12px 14px; }
  .content { padding: 14px; }
  .table-search input { width: 140px; }
}
@media (max-width: 560px) {
  .topbar-actions .btn-ghost { display: none; }
  .table-search input { width: 120px; }
  .kpi-card .k-value { font-size: 22px; }
  .login-card { padding: 26px 20px 22px; }
}
