/* AI-Nappa — internal dashboard. Light theme: modernism · luxury · futurism.
   Vanilla CSS, no dependencies. Data-mark colors follow the validated data-viz
   palette (source hues = reference slots 1-3; violet accent for single-series). */

:root {
  color-scheme: light;

  /* Surfaces & ink */
  --page:       #f6f5f2;   /* warm porcelain plane */
  --surface:    #ffffff;
  --surface-2:  #faf9f6;   /* insets */
  --ink:        #14120f;   /* primary, warm near-black */
  --ink-2:      #56534d;   /* secondary */
  --muted:      #8a877f;   /* axis / labels */
  --hairline:   rgba(20,18,15,0.09);
  --hairline-2: rgba(20,18,15,0.05);

  /* Brand accents */
  --accent:      #4a3aa7;  /* violet — interactive + single-series data */
  --accent-ink:  #3a2d86;
  --accent-soft: #ece9f7;  /* meter tracks / chips / washes */
  --gold:        #b08d57;  /* luxury — decorative rules & marks only, never data */
  --gold-soft:   #efe6d6;

  /* Data-mark categorical (validated reference slots) — color follows entity */
  --src-hackernews: #eb6834;  /* orange (HN's own hue) */
  --src-github:     #2a78d6;  /* blue */
  --src-googlenews: #1baf7a;  /* aqua */
  --src-reddit:     #eda100;  /* yellow (when it comes online) */

  /* Chart chrome */
  --grid:      #ece9e2;
  --baseline:  #d9d6cd;

  --r:    18px;
  --r-sm: 11px;
  --shadow: 0 1px 2px rgba(20,18,15,.04), 0 10px 30px -16px rgba(20,18,15,.18);
  --shadow-lift: 0 2px 6px rgba(20,18,15,.06), 0 22px 48px -22px rgba(20,18,15,.26);

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(74,58,167,.06), transparent 60%),
    radial-gradient(900px 480px at 5% -12%, rgba(176,141,87,.07), transparent 55%),
    var(--page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }

/* ---------- Masthead ---------- */
.masthead { padding: 40px 0 22px; }
.masthead-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 0; font-size: 30px; font-weight: 680; letter-spacing: -.02em; }
.brand .dot { color: var(--gold); margin: 0 .12em; font-weight: 400; }
.brand .n { color: var(--ink); }
.eyebrow { text-transform: uppercase; font-size: 11px; letter-spacing: .16em; color: var(--muted); font-weight: 600; }
.tagline { margin-left: 14px; align-self: center; }
.status { text-align: right; font-size: 13px; color: var(--ink-2); }
.status b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 620; }
.status .live { display: inline-flex; align-items: center; gap: 7px; }
.status .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--src-googlenews); box-shadow: 0 0 0 3px rgba(27,175,122,.18); }
.rule { height: 1px; margin-top: 22px; background: linear-gradient(90deg, var(--gold) 0%, var(--hairline) 22%, var(--hairline-2) 100%); }

/* ---------- Sections ---------- */
main { padding-bottom: 64px; }
section { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-size: 15px; font-weight: 660; letter-spacing: -.01em; margin: 0; text-transform: uppercase; letter-spacing: .12em; }
.section-head .hint { font-size: 12.5px; color: var(--muted); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 30px; }
.tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile::after { content:""; position:absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .5; }
.tile .label { font-size: 12px; color: var(--ink-2); font-weight: 560; }
.tile .value { font-size: 46px; font-weight: 640; letter-spacing: -.03em; margin-top: 8px; line-height: 1; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tile.hero { background: linear-gradient(180deg, #ffffff, #fbfaff); }
.tile.hero .value { color: var(--accent-ink); }

/* ---------- Opportunity cards ---------- */
.cluster-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.cluster { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 22px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; transition: box-shadow .25s, transform .25s; }
.cluster:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.cluster-head { display: flex; gap: 18px; align-items: center; }
.cluster-head h3 { font-size: 18px; font-weight: 640; letter-spacing: -.015em; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; font-weight: 560; }
.problem { font-size: 13.5px; color: var(--ink-2); margin: 0; }
.subscores { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; }
.meter { display: grid; grid-template-columns: 88px 1fr 26px; align-items: center; gap: 10px; }
.meter .m-label { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.meter .m-track { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter .m-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter .m-val { font-size: 11.5px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.evidence { border-top: 1px solid var(--hairline-2); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ev { font-size: 12.5px; }
.ev a { color: var(--ink); text-decoration: none; font-weight: 560; border-bottom: 1px solid var(--hairline); }
.ev a:hover { border-color: var(--accent); color: var(--accent-ink); }
.ev .q { color: var(--muted); font-style: italic; display: block; margin-top: 2px; }
.ev .src { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.cluster-foot { font-size: 11.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }

/* Score ring */
.ring { flex: 0 0 auto; position: relative; width: 74px; height: 74px; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 680; letter-spacing: -.02em; color: var(--accent-ink); }

/* Business-plan button on cards */
.plan-btn { align-self: flex-start; margin-top: 2px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 580; padding: 8px 15px; border-radius: 10px; cursor: pointer; transition: background .18s, box-shadow .18s; }
.plan-btn:hover { background: var(--accent-ink); box-shadow: 0 6px 16px -8px rgba(74,58,167,.6); }

/* ---------- Plan modal ---------- */
.modal.plan-modal { max-width: 780px; }
.plan .eyebrow { color: var(--gold); }
.plan h3 { font-size: 22px; letter-spacing: -.02em; margin: 6px 0 6px; }
.plan .one-liner { font-size: 15px; color: var(--ink-2); margin: 0 0 8px; line-height: 1.5; }
.plan h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 24px 0 8px; }
.plan p { font-size: 13.5px; color: var(--ink); line-height: 1.6; margin: 0; }
.plan-market { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.mkt { border: 1px solid var(--hairline); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.mkt-tier { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.mkt-val { font-size: 22px; font-weight: 660; letter-spacing: -.02em; color: var(--accent-ink); margin: 4px 0 6px; }
.mkt-basis { font-size: 11.5px; color: var(--ink-2); line-height: 1.45; }
.prow { display: grid; grid-template-columns: 130px 100px 1fr; gap: 12px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--hairline-2); font-size: 13px; }
.pr-plan { font-weight: 600; }
.pr-price { color: var(--accent-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pr-detail { color: var(--ink-2); }
ul.feat, ul.risk { margin: 0; padding-left: 20px; }
ul.feat li, ul.risk li { font-size: 13px; color: var(--ink); margin: 6px 0; line-height: 1.5; }
ul.risk li { color: var(--ink-2); }
.stackchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filetree { background: #17161f; color: #d7d4ea; font: 12px/1.55 ui-monospace, "SF Mono", Menlo, monospace; padding: 16px 18px; border-radius: 12px; overflow-x: auto; margin: 0; white-space: pre; }
.fb-note { margin-top: 12px !important; color: var(--ink-2) !important; font-size: 12.5px !important; }
.scaffold-tag { margin-top: 12px; font-size: 12.5px; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid rgba(74,58,167,.18); border-radius: 10px; padding: 9px 13px; }
.scaffold-tag code { font: 12px ui-monospace, Menlo, monospace; background: rgba(74,58,167,.08); padding: 1px 6px; border-radius: 5px; }
.mile { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--hairline-2); font-size: 13px; }
.mi-when { font-weight: 600; color: var(--accent-ink); }
.mi-goal { color: var(--ink); }
.plan-foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--hairline); font-size: 11.5px; color: var(--muted); }

/* ---------- Two-column signals ---------- */
.two-col { display: grid; grid-template-columns: 1.05fr 1fr; gap: 22px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow); }
.panel h3 { font-size: 13px; font-weight: 620; margin: 0 0 4px; }
.panel .sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

/* Horizontal bar chart */
.hbar { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; border-radius: 8px; }
.hbar:hover { background: var(--surface-2); }
.hbar .hb-label { font-size: 12px; color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { position: relative; height: 20px; }
.hb-fill { height: 100%; background: var(--accent); border-radius: 3px 5px 5px 3px; min-width: 3px; }
.hb-val { position: absolute; top: 50%; transform: translateY(-50%); margin-left: 8px; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Signal table */
table.sig { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.sig th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 0 10px 9px; border-bottom: 1px solid var(--hairline); }
table.sig th.num, table.sig td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sig td { padding: 9px 10px; border-bottom: 1px solid var(--hairline-2); }
table.sig tr { cursor: pointer; }
table.sig tbody tr:hover { background: var(--surface-2); }
table.sig .term { color: var(--ink); font-weight: 540; }
.spark { width: 84px; height: 22px; display: block; }
.conf { color: var(--accent-ink); font-weight: 600; }

/* ---------- Sources ---------- */
.src-bar { height: 30px; border-radius: 8px; display: flex; overflow: hidden; gap: 2px; background: var(--surface-2); }
.src-seg { height: 100%; }
.src-legend { display: flex; gap: 22px; margin-top: 16px; flex-wrap: wrap; }
.src-legend .item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.src-legend .sw { width: 12px; height: 12px; border-radius: 4px; }
.src-legend b { font-variant-numeric: tabular-nums; }
.src-legend .pct { color: var(--muted); }

/* ---------- Tooltip & modal ---------- */
#tip { position: fixed; z-index: 50; pointer-events: none; background: #1b1a17; color: #fff; font-size: 12px; padding: 8px 11px; border-radius: 9px; box-shadow: var(--shadow-lift); opacity: 0; transform: translateY(4px); transition: opacity .12s; max-width: 260px; }
#tip.on { opacity: 1; transform: none; }
#tip .t-term { font-weight: 640; margin-bottom: 3px; }
#tip .t-row { color: #d6d4cc; }

.modal-back { position: fixed; inset: 0; background: rgba(20,18,15,.34); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 60; padding: 24px; }
.modal-back.on { display: grid; }
.modal { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lift); max-width: 640px; width: 100%; max-height: 82vh; overflow: auto; padding: 24px 26px; }
.modal h3 { margin: 0 0 2px; font-size: 17px; letter-spacing: -.01em; }
.modal .msub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; border: none; background: none; }
.mrow { padding: 11px 0; border-top: 1px solid var(--hairline-2); font-size: 13px; display: flex; gap: 10px; }
.mrow a { color: var(--ink); text-decoration: none; font-weight: 540; }
.mrow a:hover { color: var(--accent-ink); }
.mrow .meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--hairline); font-size: 12px; color: var(--muted); }
footer .note { max-width: 760px; }

.loading { color: var(--muted); font-size: 13px; padding: 20px 0; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cluster-grid, .two-col { grid-template-columns: 1fr; }
  .brand { font-size: 25px; }
}

/* ===================== Shared buttons ===================== */
.btn-solid { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 580; font-size: 13.5px; padding: 10px 18px; border-radius: 11px; border: 1px solid var(--accent); text-decoration: none; cursor: pointer; transition: background .18s, box-shadow .18s, transform .18s; }
.btn-solid:hover { background: var(--accent-ink); box-shadow: 0 10px 24px -12px rgba(74,58,167,.7); transform: translateY(-1px); }
.btn-ghost { display: inline-flex; align-items: center; justify-content: center; color: var(--ink); font-weight: 560; font-size: 13.5px; padding: 10px 18px; border-radius: 11px; border: 1px solid var(--hairline); background: var(--surface); text-decoration: none; cursor: pointer; transition: border-color .18s, color .18s; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-solid.lg, .btn-ghost.lg { padding: 13px 24px; font-size: 15px; border-radius: 13px; }

/* ===================== Masthead logout ===================== */
.mast-right { display: flex; align-items: flex-start; gap: 16px; }
.logout button { background: none; border: 1px solid var(--hairline); color: var(--ink-2); font-size: 12px; padding: 6px 12px; border-radius: 9px; cursor: pointer; transition: border-color .18s, color .18s; }
.logout button:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ===================== Landing ===================== */
.landing .wrap { max-width: 1080px; }
.lnav { display: flex; align-items: center; justify-content: space-between; padding: 26px 0; }
.lnav-links { display: flex; align-items: center; gap: 14px; }
.lnav-links a:not(.btn-solid):not(.btn-ghost) { color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
.lnav-links a:not(.btn-solid):not(.btn-ghost):hover { color: var(--ink); }

.notice { margin: 8px 0 0; background: var(--accent-soft); border: 1px solid rgba(74,58,167,.2); color: var(--accent-ink); padding: 12px 16px; border-radius: 12px; font-size: 13.5px; }

.hero { text-align: center; padding: 64px 0 46px; }
.hero h1 { font-size: 58px; line-height: 1.04; letter-spacing: -.035em; font-weight: 680; margin: 14px 0 0; }
.hero .lede { max-width: 680px; margin: 22px auto 0; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-top: 30px; }
.hero-note { margin-top: 20px; font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }

.offer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 30px; }
.ocard { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r); padding: 24px; box-shadow: var(--shadow); position: relative; }
.ocard .onum { font-size: 12px; font-weight: 680; color: var(--gold); letter-spacing: .1em; }
.ocard h3 { font-size: 17px; letter-spacing: -.01em; margin: 10px 0 8px; }
.ocard p { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; margin: 0; }

.how { margin-top: 64px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.step { background: var(--surface-2); border: 1px solid var(--hairline-2); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.step .sidx { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 640; }
.step b { font-size: 14px; }
.step span:last-child { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

.access { margin-top: 64px; }
.access-card { background: linear-gradient(180deg, #ffffff, #fbfaff); border: 1px solid var(--hairline); border-radius: 22px; box-shadow: var(--shadow-lift); padding: 40px; max-width: 720px; margin: 0 auto; text-align: center; }
.access-card h2 { font-size: 30px; letter-spacing: -.025em; margin: 8px 0 8px; }
.access-card > p { color: var(--ink-2); font-size: 14.5px; max-width: 480px; margin: 0 auto 22px; }
.access-form { display: flex; flex-direction: column; gap: 12px; max-width: 460px; margin: 0 auto; }
.access-form .frow { display: flex; gap: 12px; }
.access-form input, .access-form textarea, .login-form input {
  width: 100%; border: 1px solid var(--hairline); border-radius: 11px; padding: 12px 14px;
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); }
.access-form input:focus, .access-form textarea:focus, .login-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.access-form textarea { resize: vertical; }
.access-form button { margin-top: 4px; }

.lfooter { margin-top: 72px; padding: 28px 0 48px; border-top: 1px solid var(--hairline); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.brand.small { font-size: 18px; }

/* ===================== Admin ===================== */
.adminlink { color: var(--ink-2); text-decoration: none; font-size: 12.5px; border: 1px solid var(--hairline); padding: 6px 12px; border-radius: 9px; }
.adminlink:hover { border-color: var(--accent); color: var(--accent-ink); }
.admin-msg { margin: 0 0 14px; padding: 11px 14px; border-radius: 11px; font-size: 13px; }
.admin-msg.ok { background: var(--accent-soft); border: 1px solid rgba(74,58,167,.2); color: var(--accent-ink); }
.admin-msg.err { background: #fdecec; border: 1px solid #f3c2c2; color: #b3261e; }
.admin-table td, .admin-table th { vertical-align: middle; }
.admin-table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--hairline); color: var(--ink-2); }
.badge.admin { background: var(--accent-soft); border-color: rgba(74,58,167,.2); color: var(--accent-ink); font-weight: 560; }
.btn-mini { font-size: 11.5px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.btn-mini:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-mini.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-mini.primary:hover { background: var(--accent-ink); }
.btn-mini.danger:hover { border-color: #d03b3b; color: #b3261e; }
.addpanel { margin-top: 18px; }
.addpanel h3 { font-size: 13px; margin: 0 0 12px; }
.addform { display: flex; flex-direction: column; gap: 10px; }
.addform .frow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.addform input[type=text], .addform input[type=email] { flex: 1; min-width: 180px; border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13.5px; }
.addform input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.addform .chk { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }

/* ===================== Login ===================== */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: 20px; box-shadow: var(--shadow-lift); padding: 34px 32px; text-align: center; }
.login-card .brand { font-size: 24px; text-decoration: none; color: var(--ink); display: inline-block; margin-bottom: 6px; }
.login-card .eyebrow { display: block; margin-bottom: 20px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { font-size: 12px; color: var(--ink-2); font-weight: 560; display: flex; flex-direction: column; gap: 6px; }
.login-form button { margin-top: 6px; }
.login-card .back { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 12.5px; text-decoration: none; }
.login-card .back:hover { color: var(--ink-2); }
.err { background: #fdecec; border: 1px solid #f3c2c2; color: #b3261e; font-size: 13px; padding: 10px 13px; border-radius: 10px; margin-bottom: 16px; text-align: left; }

@media (max-width: 820px) {
  .offer, .steps { grid-template-columns: 1fr; }
  .hero h1 { font-size: 40px; }
  .access-form .frow { flex-direction: column; }
}
