/* ============================================================================
   Automatic AEO — Agency Portal
   "Lightship" system, matched to the marketing site: warm cream canvas,
   near-monochrome, one sage accent, DM Sans with tight negative tracking.
   Light minimal side nav, hairline borders, no shadows, pill interactives.
   ========================================================================== */

:root {
  /* surfaces — card and canvas share the cream; separation is the soft lift
     (shadow) alone, no color shift between box and background */
  --bg: #faf6ef;          /* brand cream canvas */
  --surface: #faf6ef;     /* card: same cream, defined only by its shadow */
  --surface-2: #f2ede1;   /* subtle wash: table headers, row hover */
  --nav-active: #eef2e6;  /* sage-tinted active pill */

  /* text */
  --ink: #17181d;
  --muted: #6f6f6f;
  --faint: #a1a1a1;

  /* lines */
  --border: #e6e1d6;      /* warm hairline */
  --border-strong: #d9d4c8;

  /* accent + semantics */
  --primary: #4f6536;     /* camo-sage */
  --primary-deep: #3c4f29;
  --primary-soft: #e9eedf;
  --pos: #15803d;
  --pos-bg: #e7f3ec;
  --warn: #8a5a12;
  --warn-bg: #f6eddc;
  --neg: #b42318;
  --neg-bg: #fbeae7;

  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 100px;
  /* soft-lift: warm, diffuse — does all the work now that card == canvas tone */
  --shadow: 0 1px 3px rgba(60,50,30,.07), 0 12px 30px rgba(60,50,30,.11);
  --shadow-hover: 0 2px 5px rgba(60,50,30,.08), 0 18px 42px rgba(60,50,30,.14);
  --shadow-float: 0 24px 60px rgba(40,34,20,.22);  /* modals/toasts */
  --ring: 0 0 0 3px rgba(79,101,54,.30);

  --ui: 'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.3px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-deep); }

.boot { padding: 80px; text-align: center; color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- brand --------------------------------------------------------------- */
/* text wordmark = the everyday logo / home link */
.wordmark {
  font-size: 13px; font-weight: 700; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--ink); white-space: nowrap;
}
.wordmark .o { color: var(--primary); margin: 0 1px; }
/* the square mark — reserved for moments we truly need a logo (auth card) */
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: #000; display: grid; place-items: center; flex: none; }
.logo-mark span { width: 12px; height: 12px; border-radius: 4px; background: var(--primary); display: block; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 11px 20px;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink); }
.btn-danger { background: transparent; color: var(--neg); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--neg-bg); border-color: var(--neg); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 38px; padding: 8px 15px; font-size: 13px; }

/* ---- auth screen --------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 38px;
}
.auth-back { display: inline-block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 22px; text-decoration: none; letter-spacing: -0.2px; }
.auth-back:hover { color: var(--ink); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-card h1 { font-size: 26px; letter-spacing: -0.04em; font-weight: 700; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; line-height: 1.4; }
.auth-toggle { margin-top: 20px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---- forms --------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; letter-spacing: -0.2px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.4; }
.input, .select, textarea.input {
  width: 100%;
  font-family: var(--ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  min-height: 44px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.form-err { color: var(--neg); font-size: 13px; margin: 4px 0 12px; min-height: 18px; }

/* cost acknowledgment (shown when a new client changes the bill) */
.cost-notice { margin: 4px 0 12px; padding: 12px 14px; border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary); border-radius: var(--radius-sm); background: var(--primary-soft); }
.cost-notice-h { font-size: 13px; font-weight: 700; color: var(--primary-deep); letter-spacing: -0.2px; }
.cost-notice p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.cost-notice-free { border-left-color: var(--pos); background: var(--pos-bg); }
.cost-notice-free .cost-notice-h { color: var(--pos); }

/* "set up billing" prompt shown in place of a next-audit date when the agency hasn't paid */
.link-setup { color: var(--primary-deep); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.link-setup:hover { text-decoration: underline; }

/* chip / tag input (type then add) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 44px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: text; }
.chips:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.chip-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--ink); background: var(--nav-active); border-radius: var(--radius-pill); padding: 5px 6px 5px 13px; }
.chip-x { border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted); width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; padding: 0; min-height: 0; }
.chip-x:hover { color: var(--ink); background: rgba(0,0,0,.07); }
.chip-text { flex: 1; min-width: 130px; border: none; outline: none; background: transparent; font-family: var(--ui); font-size: 14px; color: var(--ink); padding: 5px 4px; min-height: 32px; }
.chip-text::placeholder { color: var(--faint); }

/* logo uploader — preview shown on the report's dark cover tone */
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 150px; height: 70px; border-radius: var(--radius-sm); background: #17150f; display: grid; place-items: center; overflow: hidden; padding: 10px; flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; }
.logo-clear { background: transparent; color: var(--neg); border-color: var(--border-strong); }
.logo-clear:hover { background: var(--neg-bg); border-color: var(--neg); }

/* ---- branding: form + live report preview -------------------------------- */
.brand-grid { display: grid; grid-template-columns: minmax(0, 620px) 360px; gap: 32px; align-items: start; }
.brand-preview-col { position: sticky; top: 24px; }
.rp-cap { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }
.rp-frame { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #f5f2ec; }
.rp-cover { background: #17150f; color: #fff; padding: 26px 22px; }
.rp-kicker { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.rp-cat { font-size: 10px; color: #a8a296; margin-top: 10px; letter-spacing: .04em; }
.rp-pct { font-size: 52px; font-weight: 800; line-height: 1; margin-top: 18px; letter-spacing: -.02em; }
.rp-pctlabel { font-size: 9px; color: #a8a296; text-transform: uppercase; letter-spacing: .1em; margin-top: 6px; }
.rp-prepared { margin-top: 26px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.14); }
.rp-prepared-lbl { font-size: 8px; color: #a8a296; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.rp-brandmark img { max-height: 26px; max-width: 160px; object-fit: contain; display: block; }
.rp-word { font-size: 14px; font-weight: 800; letter-spacing: .02em; color: #fff; }
.rp-tagline { font-size: 10px; color: #c9c3b7; margin-top: 6px; }
.rp-content { padding: 22px; color: #1a1714; }
.rp-seclabel { font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.rp-ctitle { font-size: 16px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 16px; color: #1a1714; }
.rp-prow { margin-bottom: 14px; }
.rp-prow:last-child { margin-bottom: 0; }
.rp-prow-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; }
.rp-score { font-weight: 700; }
.rp-bar { height: 6px; border-radius: 4px; background: #e2ddd2; margin-top: 7px; overflow: hidden; }
.rp-barfill { display: block; height: 100%; border-radius: 4px; }
@media (max-width: 1080px) { .brand-grid { grid-template-columns: 1fr; } .brand-preview-col { position: static; max-width: 360px; } }

/* ---- app layout ---------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; padding: 26px 24px 22px; }
.nav { padding: 10px 14px; display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 14px; font-weight: 500; letter-spacing: -0.2px;
  padding: 11px 14px; border-radius: var(--radius-sm); text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--nav-active); color: var(--ink); font-weight: 600; }
.nav a.active .ic { color: var(--primary); }
.nav .ic { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--faint); }
.sidebar .foot { margin-top: auto; padding: 18px 24px; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar .foot .who { color: var(--ink); font-weight: 600; }
.sidebar .foot .org { color: var(--muted); margin-top: 1px; }
.sidebar .foot .signout { background: none; border: none; color: var(--muted); font-family: var(--ui); font-size: 13px; cursor: pointer; padding: 8px 0 0; }
.sidebar .foot .signout:hover { color: var(--ink); text-decoration: underline; }

.content { padding: 36px 44px 72px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: 30px; letter-spacing: -0.04em; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 5px; }
.head-meta { display: flex; align-items: baseline; white-space: nowrap; }

/* ---- cards / stats ------------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 26px 28px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 32px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 26px; }
.stat .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .val { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: -0.04em; margin-top: 10px; }
.stat .val.accent { color: var(--primary); }

.section-title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; margin: 8px 0 14px; }

/* ---- per-month deliverables ---------------------------------------------- */
.deliv-body { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line, #ece9e1);
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 28px; }
.deliv-group .deliv-h { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); margin-bottom: 7px; }
.deliv-list { list-style: none; margin: 0; padding: 0; }
.deliv-list li { font-size: 13px; line-height: 1.5; padding: 3px 0 3px 14px; position: relative; color: var(--ink, #1a1a1a); }
.deliv-list li::before { content: "›"; position: absolute; left: 0; color: var(--primary); }
@media (max-width: 640px) { .deliv-body { grid-template-columns: 1fr; } }

/* ---- tables -------------------------------------------------------------- */
.tbl-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 13px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tbl td { padding: 15px 20px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.cell-strong { font-weight: 600; color: var(--ink); }

/* ---- badges -------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: var(--radius-pill); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-active { color: var(--pos); background: var(--pos-bg); }
.badge-paused { color: var(--warn); background: var(--warn-bg); }
.badge-canceled { color: var(--neg); background: var(--neg-bg); }
.badge-soon { color: var(--warn); background: var(--warn-bg); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; color: var(--muted); background: #f0efe9; border-radius: var(--radius-pill); padding: 3px 11px; }

/* ---- misc ---------------------------------------------------------------- */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 14px; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(23,24,29,.42); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 24px; z-index: 50; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-float); max-height: 90vh; overflow: auto; }
.modal header { padding: 22px 26px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { font-size: 19px; letter-spacing: -0.03em; font-weight: 700; }
.modal .body { padding: 26px; }
.modal .foot { padding: 18px 26px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.x:hover { color: var(--ink); }

/* popups (working / failed) */
.modal-sm { max-width: 420px; }
.pop { padding: 36px 30px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.pop h2 { font-size: 19px; letter-spacing: -.02em; font-weight: 700; }
.pop p { font-size: 14px; line-height: 1.5; max-width: 36ch; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pop-x { width: 40px; height: 40px; border-radius: 50%; background: var(--neg-bg); color: var(--neg); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; padding: 13px 20px; border-radius: var(--radius-pill); box-shadow: var(--shadow-float); z-index: 100; }
.toast.err { background: var(--neg); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar .brand { padding: 16px 18px; }
  .nav { flex-direction: row; padding: 10px; }
  .sidebar .foot { display: none; }
  .content { padding: 24px 18px 56px; }
  .page-head h1 { font-size: 25px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .row-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
