/* ===========================================================
   Vyral Authority Page Builder — app shell

   Light admin theme with a fixed navy sidebar, matching the
   Vyral Leads app so the two read as one set of tools.

   Palette sampled from that app:
     sidebar  #223d63    stat tile  #1d3657
     page     #f5f6f8    cards      #ffffff
     borders  #e3e7ec    track      #eaedf1
   =========================================================== */

:root {
  --navy:        #223d63;
  --navy-deep:   #1d3657;
  --navy-dark:   #1a3052;
  --navy-soft:   #2c4a73;

  --page:        #f5f6f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafb;
  --track:       #eaedf1;
  --line:        #e3e7ec;
  --line-soft:   #eef1f4;

  --ink:         #111827;
  --ink-2:       #37435a;
  --ink-dim:     #6b7688;
  --ink-faint:   #98a2b3;
  --on-navy:     #ffffff;
  --on-navy-dim: #8498b0;

  --accent:      #1d4ed8;
  --good:        #0f7d57;
  --good-bg:     #e8f6f0;
  --warn:        #9a6a05;
  --warn-bg:     #fdf6e6;
  --bad:         #b3291f;
  --bad-bg:      #fdeceb;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(16,24,40,.05);
  --shadow-2: 0 4px 14px rgba(16,24,40,.07);

  --side-w: 240px;

  --font-ui: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont,
             "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ============================================================ layout */
.shell { display: flex; align-items: stretch; min-height: 100dvh; }

/* ---------------------------------------------------------- sidebar */
.side {
  position: fixed; inset: 0 auto 0 0;
  width: var(--side-w);
  background: var(--navy);
  color: var(--on-navy);
  display: flex; flex-direction: column;
  padding: 22px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
}
.side-logo { padding: 2px 8px 24px; }
.side-logo img { width: 124px; height: auto; display: block; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: block;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: var(--on-navy-dim);
  font-size: 14.5px; font-weight: 600;
  text-decoration: none;
  transition: background .14s, color .14s;
}
.side-nav a:hover { background: var(--navy-soft); color: #fff; text-decoration: none; }
.side-nav a.on {
  background: #fff; color: var(--navy);
  font-weight: 800;
  box-shadow: var(--shadow-1);
}

.side-foot { margin-top: auto; padding-top: 18px; }
.side-foot .rule { height: 1px; background: rgba(255,255,255,.16); margin-bottom: 14px; }
.side-who { padding: 0 8px 12px; min-width: 0; }
.side-who b {
  display: block; font-size: 13.5px; font-weight: 700; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-who span {
  display: block; font-size: 12px; font-weight: 700; color: var(--on-navy-dim);
  text-transform: capitalize;
}
.side-who small {
  display: block; font-size: 11.5px; color: var(--on-navy-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-out {
  display: block; width: 100%; text-align: center;
  padding: 11px 14px; border-radius: var(--r-md);
  background: #fff; color: var(--navy);
  font: 800 14px/1 var(--font-ui); border: 0; cursor: pointer;
  text-decoration: none;
}
.side-out:hover { background: #eef2f7; text-decoration: none; }

/* ---------------------------------------------------------- main */
.main {
  flex: 1; min-width: 0;
  margin-left: var(--side-w);
  padding: 34px 40px 80px;
}
.main.narrow { max-width: 760px; }

/* Narrow: the sidebar becomes a two-row bar — logo and Sign out on the first
   row, the nav across the second — rather than three stacked rows. */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side {
    position: static; inset: auto; width: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "logo gap out" "nav nav nav";
    align-items: center; row-gap: 10px; column-gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .side-logo { grid-area: logo; padding: 0; }
  .side-logo img { width: 96px; }
  .side-nav {
    grid-area: nav;
    flex-direction: row; flex-wrap: wrap; gap: 4px;
  }
  .side-nav a { padding: 8px 12px; font-size: 13.5px; }
  .side-foot {
    grid-area: out; margin: 0; padding: 0;
    display: flex; align-items: center; gap: 12px;
  }
  .side-foot .rule { display: none; }
  .side-who { padding: 0; text-align: right; }
  .side-who small { display: none; }
  .side-out { width: auto; padding: 8px 14px; }
  .main { margin-left: 0; padding: 24px 18px 70px; }
}
@media (max-width: 560px) {
  .side-who { display: none; }
  .page-head .btn { width: 100%; }
}

/* ============================================================ headings */
.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 {
  margin: 0; font-size: 28px; font-weight: 800;
  letter-spacing: -.03em; color: var(--ink);
}
.page-head p { margin: 5px 0 0; color: var(--ink-dim); font-size: 14.5px; }
.page-head .spacer { flex: 1; }

h2.block-h {
  margin: 30px 0 12px; font-size: 13px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint);
}

/* ============================================================ stat tiles */
.stats-row {
  display: grid; gap: 16px; margin-bottom: 26px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px 20px;
}
.stat-tile .k { font-size: 13px; color: var(--ink-dim); font-weight: 600; }
.stat-tile .v {
  font-size: 38px; font-weight: 800; letter-spacing: -.035em;
  line-height: 1.1; margin-top: 4px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-tile .sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.stat-tile.primary {
  background: var(--navy-deep); border-color: var(--navy-deep); color: #fff;
}
.stat-tile.primary .k { color: #a9bcd4; }
.stat-tile.primary .v { color: #fff; }
.stat-tile.primary .sub { color: #a9bcd4; }

/* ============================================================ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card > .card-h {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.card > .card-h h2 { margin: 0; font-size: 15.5px; font-weight: 800; letter-spacing: -.012em; }
.card > .card-h p { margin: 0; color: var(--ink-faint); font-size: 13px; }
.card > .card-h .spacer { flex: 1; }
.card > .card-b { padding: 20px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.editor-split { display: grid; grid-template-columns: minmax(0,1fr) 420px; gap: 20px; align-items: start; }
@media (max-width: 1240px) { .editor-split { grid-template-columns: minmax(0,1fr); } }

/* ============================================================ list cards
   The grouped pattern from the Leads app: a header row carrying the name
   and its count, then one indented row per item. */
.listcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 16px;
  overflow: hidden;
}
.listcard .lhead {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px 16px;
}
.listcard .lhead .t { min-width: 0; }
.listcard .lhead .t b {
  display: block; font-size: 16px; font-weight: 800; letter-spacing: -.015em;
  color: var(--ink);
}
.listcard .lhead .t span {
  display: block; margin-top: 7px; padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-faint);
  max-width: 220px;
}
.listcard .lhead .n {
  margin-left: auto; font-size: 22px; font-weight: 800;
  color: var(--navy); font-variant-numeric: tabular-nums;
}

.listrow {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  text-decoration: none; color: inherit;
}
.listrow:hover { background: var(--surface-2); text-decoration: none; }
.listrow .t { min-width: 0; flex: 1; }
.listrow .t b {
  display: block; font-size: 14.5px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.listrow .t span {
  display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.listrow .n {
  font-size: 17px; font-weight: 800; color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.listrow .chev { color: var(--ink-faint); font-size: 17px; line-height: 1; }
.listrow .acts { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .listcard .lhead, .listrow { padding-left: 16px; padding-right: 16px; }
  .listrow { flex-wrap: wrap; }
  .listrow .acts { width: 100%; }
}

/* ============================================================ chips */
.statuschip {
  display: inline-block; font-size: 10.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: var(--r-pill);
}
.statuschip.draft { background: var(--track); color: var(--ink-dim); }
.statuschip.final { background: var(--good-bg); color: var(--good); }

.rolechip {
  display: inline-block; font-size: 10.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: var(--r-pill);
  background: var(--track); color: var(--ink-2);
}
.rolechip.admin  { background: var(--warn-bg); color: var(--warn); }
.rolechip.editor { background: #e8eefc; color: #1d4ed8; }
.rolechip.viewer { background: var(--track); color: var(--ink-dim); }

/* ============================================================ forms */
label.f { display: block; margin-bottom: 16px; }
label.f > span {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--ink-2);
}
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
  width: 100%;
  /* 16px minimum stops iOS Safari auto-zooming on focus */
  font: 500 16px/1.45 var(--font-ui);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #d6dbe3;
  border-radius: var(--r-md);
  padding: 10px 13px;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 150px; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  border-color: var(--navy); box-shadow: 0 0 0 3px rgba(34,61,99,.12); outline: none;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.counter { float: right; font-size: 11.5px; color: var(--ink-faint); font-weight: 700; }
.counter.over { color: var(--warn); }

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 13.5px/1 var(--font-ui);
  padding: 11px 17px; border-radius: var(--r-md);
  border: 1px solid #d6dbe3;
  background: var(--surface); color: var(--ink-2);
  cursor: pointer; text-decoration: none;
  transition: background .14s, border-color .14s, transform .08s;
}
.btn:hover { background: var(--surface-2); border-color: #c3cad5; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 800;
}
.btn.primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover { background: var(--track); border-color: transparent; }
.btn.danger { color: var(--bad); border-color: #eccac7; background: var(--bad-bg); }
.btn.danger:hover { background: #fbdedc; }
.btn.sm { padding: 8px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btnrow .spacer { flex: 1; }

/* ============================================================ alerts */
.alert {
  border-radius: var(--r-md); padding: 13px 16px; margin-bottom: 18px;
  font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface);
}
.alert.ok   { border-color: #bfe5d5; background: var(--good-bg); color: #0b6044; }
.alert.err  { border-color: #eccac7; background: var(--bad-bg);  color: #8e211a; }
.alert.warn { border-color: #eddfb8; background: var(--warn-bg); color: #7a5504; }

/* ============================================================ tables */
.tscroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th {
  text-align: left; padding: 11px 14px;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.t td {
  padding: 13px 14px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; color: var(--ink-2);
}
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t td b, table.t td strong { color: var(--ink); }

/* ============================================================ listing rows (editor) */
.lrow {
  display: grid; gap: 12px; align-items: start;
  grid-template-columns: 96px minmax(0,1fr) 34px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); margin-bottom: 12px;
}
.lrow .lfields {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  min-width: 0;
}
.lrow .thumb {
  width: 96px; height: 66px; border-radius: var(--r-sm); overflow: hidden;
  background: var(--track); border: 1px dashed #c8cfd9;
  display: grid; place-items: center; cursor: pointer; position: relative;
}
.lrow .thumb img { width: 100%; height: 100%; object-fit: cover; }
.lrow .thumb span { font-size: 10.5px; color: var(--ink-faint); font-weight: 700; text-align: center; padding: 4px; }
.lrow label.f { margin-bottom: 0; }
.lrow input, .lrow select { font-size: 16px; padding: 8px 10px; }
.lrow .kill {
  align-self: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid #eccac7; background: var(--bad-bg);
  color: var(--bad); cursor: pointer; font-weight: 800; line-height: 1;
}

/* ============================================================ image pickers */
.pick {
  display: flex; align-items: center; gap: 14px;
  padding: 13px; border: 1px dashed #c8cfd9; border-radius: var(--r-md);
  background: var(--surface-2);
}
.pick .prev {
  width: 84px; height: 56px; border-radius: var(--r-sm); overflow: hidden;
  background: var(--track); display: grid; place-items: center; flex: none;
}
.pick .prev.round { width: 56px; height: 56px; border-radius: 50%; }
.pick .prev img { width: 100%; height: 100%; object-fit: cover; }
.pick .prev em { font-size: 10.5px; color: var(--ink-faint); font-style: normal; font-weight: 700; }
.pick .body { min-width: 0; flex: 1; }
.pick .body b { display: block; font-size: 13.5px; color: var(--ink); }
.pick .body small { color: var(--ink-faint); font-size: 12px; }
.drop-on { border-color: var(--navy) !important; background: #eef2f7 !important; }

/* ============================================================ preview */
.previewbox { position: sticky; top: 24px; }

/* ============================================================ login */
.loginwrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--page); }
.logincard { width: 100%; max-width: 430px; padding: 32px; }
.logincard .lg { background: var(--navy); border-radius: var(--r-md); padding: 14px 18px; display: inline-block; line-height: 0; }
.logincard .lg img { width: 128px; height: auto; display: block; }
.logincard h1 { margin: 22px 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.logincard p.lead { margin: 0 0 24px; color: var(--ink-dim); font-size: 14px; }
.gwrap { display: grid; place-items: center; min-height: 46px; }
.or {
  display: flex; align-items: center; gap: 12px; margin: 22px 0;
  color: var(--ink-faint); font-size: 11px; font-weight: 800; letter-spacing: .1em;
}
.or::before, .or::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ============================================================ misc */
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.empty {
  text-align: center; padding: 58px 22px; color: var(--ink-dim);
  border: 1px dashed #ccd3dd; border-radius: var(--r-lg); background: var(--surface);
}
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 18px; font-weight: 800; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 18px; border-radius: var(--r-md);
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: #8e211a; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
