/* Engagify Intelligence Hub - brand palette from spec section 04 */
:root {
  --navy: #061410;
  --navy-2: #0C2019;
  --navy-3: #12382B;
  --blue: #008F63;
  --cyan: #D4AF37;
  --violet: #E9D49C;
  --ink: #0A1A14;
  --text: #1F2E28;
  --muted: #5A6D64;
  --line: #E1E8E4;
  --bg: #F5F7F4;
  --card: #FFFFFF;
  --ok: #138A5B;
  --warn: #B7791F;
  --bad: #C53030;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(6, 20, 16, .06), 0 4px 16px rgba(6, 20, 16, .05);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
code { background: #EEF2EF; padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #D6E4DC; padding: 1.25rem .9rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 .4rem 1.1rem; color: #fff; }
.brand img { width: 34px; height: 34px; }
.brand strong { display: block; font-size: .95rem; letter-spacing: .04em; }
.brand span { display: block; font-size: .7rem; letter-spacing: .14em; color: var(--cyan); }
.scraper-cta {
  display: block; margin: 0 .2rem .6rem; padding: .7rem .9rem; border-radius: 10px; color: #fff; font-weight: 600;
  background: linear-gradient(90deg, var(--blue), var(--cyan)); color: #061410; text-align: center; box-shadow: 0 4px 14px rgba(212, 175, 55, .35);
}
.scraper-cta:hover { text-decoration: none; filter: brightness(1.08); }
.nav-group { margin-bottom: 1rem; }
.nav-group h4 { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #8AA597; margin: 0 .5rem .35rem; }
.nav-link {
  display: flex; justify-content: space-between; align-items: center; padding: .45rem .6rem; border-radius: 8px;
  color: #D6E4DC; font-size: .9rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(212, 175, 55, .14); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav-link .soon { font-size: .62rem; color: #8AA597; border: 1px solid #2F5A48; border-radius: 99px; padding: 0 .4rem; }

.main { min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1.75rem;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .who { color: var(--muted); font-size: .85rem; }
.badge-internal { font-size: .68rem; letter-spacing: .12em; font-weight: 700; color: var(--violet); border: 1px solid var(--violet); border-radius: 99px; padding: .1rem .55rem; }
.content { padding: 1.75rem; max-width: 1280px; }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; color: var(--navy); cursor: pointer; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: 2fr 1fr; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-size: 2rem; font-weight: 700; color: var(--ink); }
.stat.accent { border-top: 3px solid var(--cyan); }
.stat.accent-2 { border-top: 3px solid var(--blue); }
.stat.accent-3 { border-top: 3px solid var(--violet); }
.stat.accent-4 { border-top: 3px solid var(--navy); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: .55rem 1rem; font-weight: 600; font-size: .9rem; cursor: pointer;
  background: var(--blue); color: #fff; font-family: inherit;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.block { width: 100%; padding: .75rem; }
.link-btn { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
td { padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: #EEF2EF; color: var(--navy-3); white-space: nowrap; }
.pill.high, .pill.completed, .pill.published, .pill.succeeded, .pill.build { background: #E3F5EC; color: var(--ok); }
.pill.medium, .pill.partial, .pill.running, .pill.validate, .pill.watch { background: #FDF3E1; color: var(--warn); }
.pill.low, .pill.failed, .pill.reject, .pill.canceled { background: #FCE8E8; color: var(--bad); }
.pill.engine { background: rgba(212, 175, 55, .14); color: #7A6118; }
.score { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--muted); padding: 2.25rem 1rem; }
.empty strong { display: block; color: var(--ink); margin-bottom: .25rem; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input, .filters select, .form-row input {
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; font: inherit; background: #fff; color: var(--text);
}
.filters input[type=search] { min-width: 260px; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; color: var(--muted); font-size: .85rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; background: #E3F5EC; color: var(--ok); margin-bottom: .5rem; }
.messages li.error { background: #FCE8E8; color: var(--bad); }
.errorlist { list-style: none; padding: 0; margin: .3rem 0 0; color: var(--bad); font-size: .85rem; }
.notice { border-left: 3px solid var(--cyan); background: #FBF6E4; padding: .8rem 1rem; border-radius: 6px; color: var(--navy-3); }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ---------- auth screens ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(circle at 20% 15%, rgba(0, 143, 99, .28), transparent 40%),
              radial-gradient(circle at 85% 80%, rgba(212, 175, 55, .2), transparent 45%), var(--navy);
}
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-card .brand { color: var(--navy); padding: 0 0 1.4rem; }
.auth-card .brand span { color: var(--blue); }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--ink); }
.form-row input { width: 100%; padding: .65rem .8rem; }
.form-row input:focus, .filters input:focus, .filters select:focus { outline: 2px solid var(--cyan); outline-offset: 1px; border-color: transparent; }
.qr { display: flex; justify-content: center; padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: 1rem 0; }
.qr svg { width: 200px; height: 200px; }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .72rem; letter-spacing: .12em; color: #9DB6A8; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
}

/* ---- Phase 2: forms, progress, sparklines ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-row select, .form-row textarea { width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.form-row input[type=checkbox] { width: auto; margin-right: .4rem; }
.form-row ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.form-row ul label { font-weight: 500; display: flex; align-items: center; }
.form-row .help { color: var(--muted); font-size: .78rem; margin-top: .25rem; }
.progress { height: 8px; background: #EEF2EF; border-radius: 99px; overflow: hidden; margin: .5rem 0 .25rem; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .4s; }
.spark { width: 120px; height: 28px; vertical-align: middle; }
.spark polyline { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linejoin: round; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chips a { font-size: .8rem; padding: .25rem .7rem; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--navy-3); text-decoration: none; }
.chips a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.warn-list { margin: .4rem 0 0; padding-left: 1.1rem; color: #8A5A00; font-size: .85rem; }
.inline-form { display: inline; }
.btn.danger { background: var(--bad); }
.stack > * + * { margin-top: 1rem; }

/* ---------- V3.1 dashboard: two primary functions ---------- */
.primary-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.primary-btn { display: block; padding: 1.6rem 1.5rem; border-radius: 16px; color: #fff; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  border: 1px solid rgba(212, 175, 55, .45); box-shadow: var(--shadow); }
.primary-btn:hover { text-decoration: none; border-color: var(--cyan); filter: brightness(1.08); }
.primary-btn strong { display: block; font-size: 1.25rem; letter-spacing: .02em; color: var(--violet); }
.primary-btn span { display: block; margin-top: .35rem; color: #D6E4DC; font-size: .92rem; }
.primary-btn small { display: block; margin-top: .8rem; color: var(--cyan); letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; }
.tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--line); margin: 1rem 0; }
.tabs a { padding: .55rem 1rem; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--ink); background: #fff; border: 1px solid var(--line); border-bottom-color: #fff; margin-bottom: -1px; }
.tag { display: inline-block; font-size: .68rem; padding: .05rem .5rem; border-radius: 99px; background: rgba(0, 143, 99, .12); color: var(--blue); font-weight: 600; margin-left: .3rem; }
.authorize { border: 2px solid var(--cyan); border-radius: 12px; padding: 1rem 1.2rem; background: #FFFDF5; margin-top: 1rem; }
