/* Napoleon Viral — design system */
:root {
  color-scheme: light dark;
  --bg: #fff;
  --bg-elev: #f7f8fa;
  --bg-card: #fff;
  --fg: #0b1220;
  --fg-soft: #4a5468;
  --muted: #6b7280;
  --rule: #e6e8ec;
  --rule-strong: #d0d4dc;
  --accent: #0B1220;
  --brand: #5BD0F4;
  --brand-2: #2EA8D6;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-elev: #0f1830;
    --bg-card: #121a2b;
    --fg: #e9edf2;
    --fg-soft: #b9c1cd;
    --muted: #8693a8;
    --rule: #1f2733;
    --rule-strong: #2a3445;
    --accent: #5BD0F4;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--brand); }

/* ---- App shell ---- */
.app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--rule);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 10;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  display: grid; place-items: center; color: #0b1220; font-weight: 800;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }

.content { padding: 16px; max-width: 960px; margin: 0 auto; width: 100%; }

/* Bottom nav (mobile) */
.bottomnav {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg-elev); border-top: 1px solid var(--rule);
  z-index: 10;
}
.bottomnav a {
  padding: 10px 4px; text-align: center; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none;
}
.bottomnav a .ic { font-size: 18px; line-height: 1; }
.bottomnav a.active { color: var(--brand); }

@media (min-width: 800px) {
  .app { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; grid-template-areas: "top top" "side main"; }
  .topbar { grid-area: top; }
  .sidenav { grid-area: side; border-right: 1px solid var(--rule); padding: 16px 8px; background: var(--bg-elev); display: block; }
  .content { grid-area: main; max-width: none; padding: 24px; }
  .bottomnav { display: none; }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--fg-soft); text-decoration: none; margin-bottom: 2px; }
  .sidenav a:hover { background: rgba(127,127,127,.08); color: var(--fg); }
  .sidenav a.active { background: rgba(91,208,244,.12); color: var(--brand); }
}
@media (max-width: 799px) {
  .sidenav { display: none; }
}

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .cards { grid-template-columns: 1fr 1fr 1fr 1fr; } }

.card {
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card .v { font-size: 22px; font-weight: 700; line-height: 1.2; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Sections ---- */
.section { margin: 24px 0; }
.section-head { display: flex; align-items: end; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .desc { color: var(--muted); font-size: 13px; }
.section-head .spacer { flex: 1; }

/* ---- Forms ---- */
.form { display: grid; gap: 14px; max-width: 640px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--fg-soft); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field input[type="text"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm); background: var(--bg); color: var(--fg);
  font: inherit; font-size: 15px; -webkit-appearance: none;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(91,208,244,.2);
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: rgba(127,127,127,.08); color: var(--fg-soft); padding: 4px 10px; border-radius: 999px; font-size: 12px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; transition: .15s;
  min-height: 40px; touch-action: manipulation;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #0b1220; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); color: #fff; }
.btn-ghost { background: transparent; color: var(--fg-soft); border-color: var(--rule-strong); }
.btn-ghost:hover { background: rgba(127,127,127,.08); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; }

/* ---- Status pills ---- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: var(--success-bg); color: #065f46; }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-muted { background: rgba(127,127,127,.12); color: var(--muted); }

/* ---- Lists ---- */
.list { display: grid; gap: 8px; }
.list-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--r);
}
.list-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .actions { margin-left: auto; }

/* ---- Empty state ---- */
.empty {
  text-align: center; padding: 40px 24px; color: var(--muted);
  background: var(--bg-card); border: 1px dashed var(--rule-strong); border-radius: var(--r);
}
.empty .em-title { color: var(--fg-soft); font-weight: 600; margin: 4px 0 6px; }

/* ---- Toast ---- */
#toasts { position: fixed; bottom: 80px; right: 16px; z-index: 1000; display: grid; gap: 8px; }
@media (min-width: 800px) { #toasts { bottom: 16px; } }
.toast {
  padding: 10px 14px; border-radius: var(--r); background: var(--fg); color: var(--bg);
  font-size: 13px; max-width: 360px; box-shadow: var(--shadow);
  animation: in .2s ease-out;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok  { background: var(--success); color: #fff; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Skeleton / loading ---- */
.skeleton { background: linear-gradient(90deg, rgba(127,127,127,.08) 0%, rgba(127,127,127,.18) 50%, rgba(127,127,127,.08) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); height: 1em; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Login screen ---- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elev) 100%);
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 28px; width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.dev-warn {
  background: var(--warn-bg); color: var(--warn); padding: 10px 12px;
  border-radius: var(--r-sm); font-size: 12px; margin-bottom: 16px; border: 1px solid #fde68a;
}

/* ---- Misc ---- */
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }
.divider { height: 1px; background: var(--rule); margin: 16px 0; }
code, kbd { background: rgba(127,127,127,.12); padding: 1px 6px; border-radius: 4px; font-size: 90%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
[hidden] { display: none !important; }

/* ---- Matriz de Viralização ---- */
.matriz-cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .matriz-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .matriz-cards { grid-template-columns: 1fr 1fr 1fr; } }

.matriz-card {
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.matriz-card .mc-head { display: flex; align-items: center; gap: 12px; }
.matriz-card .mc-icon {
  font-size: 22px; line-height: 1; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: var(--r-sm);
  background: rgba(91,208,244,.10); color: var(--brand-2);
}
.matriz-card .mc-name { font-size: 15px; font-weight: 700; line-height: 1.2; }
.matriz-card .mc-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

.mc-stage { display: grid; gap: 6px; }
.mc-stage label { font-size: 12px; font-weight: 600; color: var(--fg-soft); }
.mc-stage select {
  padding: 8px 10px; border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: var(--bg); color: var(--fg); font: inherit; font-size: 14px;
}
.mc-stage select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(91,208,244,.2); }
.mc-stage-meta { font-size: 11px; color: var(--muted); min-height: 14px; }

/* ---- Project switcher (topbar) ---- */
.project-switcher { position: relative; margin-right: 10px; }
.ps-trigger {
  background: var(--bg-card); border: 1px solid var(--rule-strong);
  color: var(--fg); padding: 6px 10px; border-radius: var(--r-sm);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
}
.ps-trigger:hover { background: rgba(127,127,127,.08); }
.ps-chev { font-size: 10px; opacity: .6; }
.ps-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-card); border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow);
  min-width: 220px; padding: 6px; z-index: 100;
}
.ps-section { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.ps-item {
  background: transparent; border: 0; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--fg); font: inherit; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.ps-item:hover { background: rgba(91,208,244,.10); }
.ps-item.active { background: rgba(91,208,244,.18); color: var(--brand-2); font-weight: 600; }
.ps-tag {
  background: var(--success-bg); color: #065f46;
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
}
.ps-new {
  width: 100%; margin-top: 6px; padding: 8px 10px;
  background: var(--brand); color: #0b1220; border: 0; border-radius: var(--r-sm);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ps-new:hover { background: var(--brand-2); color: #fff; }
@media (max-width: 600px) {
  .project-switcher { margin-right: 6px; }
  .ps-trigger { font-size: 12px; padding: 5px 8px; }
  .ps-menu { right: -40px; }
}
