/* ============================================================
   OpenCard UI
   One stylesheet for: public cards (/c, /a), the admin app
   (/admin), auth pages, and the self-service portal (/me).
   ============================================================ */

:root {
  --primary: #1f6f43;            /* tenant accent (overridden per card) */
  --accent: #1F5BEA;             /* OpenCard admin accent (logo blue) */
  --accent-ink: #123A70;
  --text: #111827;
  --bg: #ffffff;

  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #eef0f2;
  --paper: #ffffff;
  --wash: #f4f5f7;
  --wash-2: #f9fafb;

  --ok-bg: #dcfce7; --ok-ink: #166534;
  --bad-bg: #fee2e2; --bad-ink: #991b1b;
  --warn-bg: #fffbeb; --warn-ink: #92400e;

  --radius: 10px;
  --radius-lg: 14px;
  --editor-pad-x: 24px; /* horizontal padding of editor cards (shrinks on phones) */
  --shadow-1: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --shadow-2: 0 4px 16px rgba(17, 24, 39, .07);
  --shadow-3: 0 12px 48px rgba(17, 24, 39, .12);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, #fff);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--wash);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.01em; }
code { background: var(--wash-2); border: 1px solid var(--line-soft); border-radius: 5px; padding: 1px 5px; font-size: .92em; }

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

/* ============================================================
   Public card
   ============================================================ */
.card-body { background: #e9ebee; }
.oc-source-footer { max-width: 460px; margin: 0 auto; padding: 14px 16px 24px; text-align: center; color: #627169; background: #e9ebee; font-size: 11px; }
.oc-source-footer a { color: inherit; text-underline-offset: 2px; }
.card {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font, var(--font-ui));
  box-shadow: 0 0 60px rgba(17, 24, 39, .10);
}
.hero { position: relative; background: var(--primary); }
.logo { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); max-height: 40px; max-width: 60%; object-fit: contain; }
.layout-minimal .logo { position: static; transform: none; display: block; margin: 18px auto 0; }
.layout-classic .hero { height: 220px; }
.layout-banner .hero { height: 160px; }
/* Minimal: no colored banner. The hero must size to its (static) logo/photo
   children — a fixed height of 0 made them spill over the name and bio. */
.layout-minimal .hero { height: auto; background: transparent; }
.photo {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover; border: 4px solid var(--bg);
  position: absolute; left: 50%; bottom: -60px; transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 6px 20px rgba(17, 24, 39, .16);
}
.photo-fallback {
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 700; color: var(--primary); background: #fff;
}
.layout-minimal .photo { position: static; transform: none; margin: 28px auto 0; display: block; }
/* Keep fallback initials centered in the minimal layout — the display:block
   above was overriding .photo-fallback's flex centering (initials sat top-left). */
.layout-minimal .photo-fallback { display: flex; }
.ident { text-align: center; padding: 72px 24px 8px; }
.layout-minimal .ident { padding-top: 16px; }
.ident h1 { margin: 0; font-size: 26px; }
.pronouns { color: var(--ink-3); margin: 2px 0; font-style: italic; }
.title { margin: 8px 0 2px; font-weight: 600; color: var(--primary); }
/* Derive from the template text color so dark themes stay legible (a fixed
   gray disappeared on dark backgrounds like the Midnight preset). */
.company { margin: 0; color: color-mix(in srgb, var(--text, #111827) 62%, transparent); }
.bio { padding: 8px 24px; text-align: center; color: var(--ink-2); }
.bio p { margin: 8px 0; }

/* ---------- Wave / hump layout ---------- */
.hero-wave { position: relative; width: 100%; line-height: 0; background: var(--primary); }
.hero-wave .hero-photo { width: 100%; display: block; max-height: 460px; object-fit: cover; }
.hero-photo-empty { height: 340px; background: var(--primary); }
.hero-wave .wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 84px; }
.hero-wave .wave-fill { fill: var(--bg); }
.hero-wave .wave-line { stroke: var(--primary); stroke-width: 8; vector-effect: non-scaling-stroke; }
/* Logo sits in the white band just below the wave, right-aligned (off the photo). */
/* Constrained to the white pocket right of the wave's descending curve so
   wide logos can't collide with the stroke or bleed past the card edge. */
.layout-wave .wave-logo-wrap { display: flex; justify-content: flex-end; padding: 0 24px; margin-top: -38px; position: relative; z-index: 2; }
.layout-wave .wave-logo-wrap img { max-height: 30px; max-width: 26%; object-fit: contain; object-position: right center; }

.layout-wave .ident { text-align: left; padding: 18px 24px 6px; }
.layout-wave .ident h1 { font-size: 28px; }
.layout-wave .pronouns { margin: 2px 0 10px; }
.layout-wave .title { margin: 0 0 2px; }
.layout-wave .bio {
  text-align: left; margin: 4px 24px; padding: 16px 0;
  border-top: 1px solid #ececec; border-bottom: 1px solid #ececec;
}
.layout-wave .contacts { padding: 8px 24px; }
.layout-wave .row { border-bottom: none; gap: 16px; }
.layout-wave .row-ic {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: #f1efe9; /* fallback */
  background: color-mix(in srgb, var(--primary) 14%, #ffffff);
}

/* ---------- Split layout: compact gradient band, offset square avatar ---------- */
.layout-split { border-left: 6px solid var(--primary); }
.layout-split .hero {
  height: 96px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #000));
}
.layout-split .logo { left: auto; right: 16px; transform: none; }
.layout-split .photo {
  left: 24px; transform: none; bottom: -56px;
  width: 112px; height: 112px; border-radius: 22px;
}
.layout-split .ident { text-align: left; padding: 70px 24px 8px; }
.layout-split .ident h1 { font-size: 28px; }
.layout-split .title { margin: 6px 0 2px; }
.layout-split .bio { text-align: left; }
.layout-split .contacts { padding: 8px 24px; }
.layout-split .row { border-bottom: none; }

/* ---------- Spotlight layout: full-bleed photo hero, name overlaid ---------- */
.layout-spotlight .hero { height: 320px; overflow: hidden; }
.layout-spotlight .hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.62));
}
.layout-spotlight .photo {
  position: absolute; inset: 0; transform: none;
  width: 100%; height: 100%; border-radius: 0; border: none; box-shadow: none;
  object-fit: cover;
}
.layout-spotlight .photo-fallback {
  font-size: 72px; color: rgba(255,255,255,.85);
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #000));
}
.layout-spotlight .logo { z-index: 2; }
.layout-spotlight .ident {
  /* Pull the whole identity block (name, pronouns, title, company) onto the
     photo — -92px left the last line dangling below the hero edge. */
  margin-top: -136px; position: relative; z-index: 2;
  text-align: left; padding: 0 24px 16px;
  color: #fff; text-shadow: 0 1px 10px rgba(0,0,0,.5);
}
.layout-spotlight .ident h1 { font-size: 30px; }
.layout-spotlight .title, .layout-spotlight .company, .layout-spotlight .pronouns { color: #fff; opacity: .88; }
.layout-spotlight .bio { text-align: left; padding-top: 14px; }

/* ---------- Frame layout: hairline accent frame, medallion photo ---------- */
.layout-frame {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent),
              0 0 60px rgba(17, 24, 39, .10);
}
.layout-frame .hero { height: auto; background: transparent; padding-top: 30px; }
.layout-frame .logo { position: static; transform: none; display: block; margin: 0 auto; }
.layout-frame .photo {
  position: static; transform: none; display: block; margin: 24px auto 0;
  border: 3px solid var(--primary); padding: 5px; background: var(--bg);
}
.layout-frame .photo-fallback { display: flex; }
.layout-frame .ident { padding-top: 18px; }
.layout-frame .ident h1 { font-size: 24px; letter-spacing: .02em; }
.layout-frame .title {
  text-transform: uppercase; letter-spacing: .16em;
  font-size: 12px; font-weight: 600; margin-top: 10px;
}
.layout-frame .ident::after {
  content: ""; display: block; width: 46px; height: 3px;
  background: var(--primary); margin: 16px auto 0; border-radius: 2px;
}

.contacts { padding: 8px 16px; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 10px; text-decoration: none; color: inherit;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 8px;
  transition: background-color .15s ease;
}
.row:hover { background: color-mix(in srgb, var(--primary) 5%, #fff); }
.row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.row-ic { font-size: 20px; width: 28px; text-align: center; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-val { font-weight: 600; overflow-wrap: anywhere; }
.row-lbl { font-size: 12px; color: var(--ink-4); }

.socials { display: flex; gap: 12px; justify-content: center; padding: 12px; flex-wrap: wrap; }
.social {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; text-decoration: none; font-weight: 700; font-size: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.social:hover { transform: translateY(-2px); box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.social:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, #fff); }

.cta {
  display: block; margin: 16px 24px; padding: 16px;
  background: var(--primary); color: #fff; text-align: center;
  border-radius: 12px; text-decoration: none; font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 28%, transparent);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.cta:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 32%, transparent); }
.cta:focus-visible { outline: none; box-shadow: var(--focus-ring), 0 4px 14px color-mix(in srgb, var(--primary) 28%, transparent); }
.cta.secondary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.cta.secondary:hover { background: color-mix(in srgb, var(--primary) 7%, #fff); }

.dealer { margin: 4px 24px 8px; padding: 14px 0 4px; border-top: 1px solid var(--line-soft); }
.dealer-name { font-weight: 700; font-size: 14px; margin: 0 0 8px; color: var(--ink-2); }
.oem-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.oem {
  font-size: 12px; font-weight: 600; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 999px; padding: 3px 10px; background: transparent;
}
.dealer-ctas { display: flex; flex-direction: column; gap: 8px; }
.dealer-cta {
  display: block; margin: 0; padding: 13px; font-size: 15px; border-radius: 10px;
  background: transparent; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none;
}
.dealer-cta:hover { background: color-mix(in srgb, var(--primary) 7%, #fff); transform: none; }
.dealer-cta.cta-service { background: var(--primary); color: #fff; }
.dealer-cta.cta-service:hover { background: var(--primary); filter: brightness(1.05); }
.qr { text-align: center; padding: 8px 24px 16px; color: var(--ink-3); }
.qr img { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line-soft); }
.qr p { font-size: 13px; margin: 6px 0 0; }

.connect-toggle {
  display: block; width: calc(100% - 48px); margin: 0 24px 12px; padding: 12px;
  background: transparent; border: 1.5px solid var(--primary); color: var(--primary);
  border-radius: 10px; font-weight: 600; cursor: pointer; font: inherit; font-size: 15px;
  transition: background-color .15s ease;
}
.connect-toggle:hover { background: color-mix(in srgb, var(--primary) 7%, #fff); }
.connect-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.connect-disclosure > summary { list-style: none; text-align: center; }
.connect-disclosure > summary::-webkit-details-marker { display: none; }
.connect { max-height: 0; overflow: hidden; transition: max-height .3s ease; padding: 0 24px; }
.connect.open, .connect-disclosure[open] .connect { max-height: 1000px; padding-bottom: 16px; }
.connect form { display: flex; flex-direction: column; gap: 8px; }
.connect form > label:not(.chk-inline) { font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: left; margin-bottom: -3px; }
.connect form > label span { color: var(--ink-3); font-weight: 400; }
.connect input, .connect textarea, .connect select {
  padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit;
  background: #fff; transition: border-color .15s ease, box-shadow .15s ease;
}
.connect input:focus, .connect textarea:focus, .connect select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, #fff);
}
.connect .chk-inline {
  display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: #4b5563; text-align: left;
}
.connect .chk-inline input { width: auto; padding: 0; margin-top: 2px; }
.connect button[type=submit] {
  padding: 13px; background: var(--primary); color: #fff; border: 0; border-radius: 8px;
  font-weight: 700; cursor: pointer; font: inherit; font-size: 15px;
  transition: filter .15s ease;
}
.connect button[type=submit]:hover { filter: brightness(1.05); }
.disclaimer { color: var(--ink-4); font-size: 11px; line-height: 1.5; padding: 4px 24px 0; margin: 8px 0 0; text-align: center; }
.brand { text-align: center; color: var(--ink-4); padding: 24px; font-size: 13px; }

/* ============================================================
   Buttons (admin + auth)
   ============================================================ */
.btn {
  display: inline-block; padding: 8px 14px;
  background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: 8px;
  text-decoration: none; font-weight: 600; cursor: pointer;
  font: inherit; font-size: 14px; line-height: 1.45;
  box-shadow: var(--shadow-1);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(.97); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn.secondary {
  background: var(--paper); color: var(--ink-2); border-color: var(--line);
}
.btn.secondary:hover { filter: none; background: var(--wash-2); border-color: #d1d5db; color: var(--ink); }
.btn.danger { background: #b91c1c; color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
/* smaller buttons inside table rows */
td .btn { padding: 5px 10px; font-size: 13px; }

/* ============================================================
   Admin shell
   ============================================================ */
.site-head {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, #fff 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head-in {
  max-width: 1080px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px;
}
.site-logo { display: flex; align-items: center; text-decoration: none; }
.site-logo img { height: 38px; width: auto; display: block; }
.site-nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  display: inline-block; padding: 7px 12px; border-radius: 8px;
  color: var(--ink-3); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); background: var(--wash-2); }
.site-nav a.active { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 10%, #fff); }
.site-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.site-title { font-weight: 700; font-size: 15px; color: var(--ink); }

.admin { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.admin h1 { font-size: 22px; }
.admin h2 { font-size: 19px; margin: 0 0 4px; }
.admin h3 { font-size: 15px; color: var(--ink-2); margin: 28px 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.admin a { color: var(--accent); }
.admin a:hover { text-decoration-thickness: 2px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
/* Breadcrumb back-link above nested page titles. */
.crumb { margin: 0 0 8px; font-size: 13px; }
.crumb a { color: var(--ink-3); text-decoration: none; font-weight: 600; }
.crumb a:hover { color: var(--accent); text-decoration: underline; }
.topbar > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar h2 { margin: 0; }
/* `.admin a { color:accent }` must not bleed onto anchor-style buttons. */
.admin a.btn { color: #fff; text-decoration: none; }
.admin a.btn.secondary { color: var(--ink-2); }
.admin a.btn.secondary:hover { color: var(--ink); }
.dashboard-tools {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  padding: 16px 20px; margin: 0 0 20px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.dashboard-tools h3 { margin: 0 0 8px; font-size: 11px; color: var(--ink-3); }
.dashboard-tools a { display: inline-block; padding: 5px 12px 5px 0; font-size: 14px; text-decoration: none; }
.dashboard-tools a:hover { text-decoration: underline; }
.backup-restore-form { display: grid; gap: 14px; }
.backup-restore-form label { display: block; margin: 0 0 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.backup-restore-form select, .backup-restore-form input { display: block; width: 100%; }
.backup-restore-form p { margin: 2px 0 0; }

/* ============================================================
   Tables
   ============================================================ */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-1);
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: top; }
th {
  background: var(--wash-2); color: var(--ink-3);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-bottom-color: var(--line);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:not(:first-child):hover td { background: #fafbfc; }
td { font-variant-numeric: tabular-nums; }

/* ============================================================
   Pills / badges
   ============================================================ */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, #fff);
  margin: 1px 2px 1px 0;
}
.pill.on { background: var(--ok-bg); color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok-ink) 22%, #fff); }
.pill.off { background: var(--bad-bg); color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad-ink) 20%, #fff); }

/* ============================================================
   Forms
   ============================================================ */
form.editor {
  background: var(--paper); padding: 22px var(--editor-pad-x); border-radius: var(--radius-lg);
  max-width: 720px; border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
form.editor label { display: block; font-size: 13px; color: var(--ink-2); margin: 14px 0 5px; font-weight: 600; }
form.editor label:first-child { margin-top: 0; }
form.editor input, form.editor textarea, form.editor select {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit;
  background: #fff; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
form.editor input:focus, form.editor textarea:focus, form.editor select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
form.editor input[readonly] { background: var(--wash-2); color: var(--ink-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--ink-3); font-size: 13px; }

/* Section headings inside editor forms: full-bleed dividers that break a long
   form into scannable blocks (brand/location/card/template editors). */
form.editor h3 {
  margin: 28px calc(-1 * var(--editor-pad-x)) 6px; padding: 18px var(--editor-pad-x) 0;
  border-top: 1px solid var(--line-soft);
  font-size: 14.5px; font-weight: 700; color: var(--ink);
  text-transform: none; letter-spacing: 0;
}
form.editor h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }
form.editor h3 + .muted, form.editor h3 + p.muted { margin: 0 0 12px; }

/* Consistent action row at the end of a form. */
.form-actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 24px calc(-1 * var(--editor-pad-x)) 0; padding: 16px var(--editor-pad-x) 0;
  border-top: 1px solid var(--line-soft);
}
form.editor .form-actions button, form.editor .form-actions .btn { width: auto; }

/* Role/scope pickers that show or hide with the selected role. */
.scope-box { border: 1px solid var(--line-soft); background: var(--wash-2); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.scope-box > label:first-child { margin-top: 0; }

/* ============================================================
   Panels — titled sections for hub pages (integrations, marketing)
   ============================================================ */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); padding: 20px 22px; margin: 0 0 20px;
}
.panel > h3:first-child { margin: 0 0 4px; font-size: 15.5px; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; }
.panel > h3 + .muted, .panel > h3 + p.muted { margin: 0 0 14px; }
.panel table { box-shadow: none; }
.panel form.editor { border: none; box-shadow: none; padding: 0; margin-top: 16px; max-width: 620px; }
.panel form.editor h3 { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
.panel form.editor .form-actions { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }

/* Repeated editable cards inside a page (departments, assets, domains, CRM). */
.item-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-1);
}
form.editor.item-card { max-width: none; }
form.editor.item-card h3 { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }

/* ============================================================
   Stat cards / panels
   ============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat {
  background: var(--paper); padding: 16px 18px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.stat .n { font-size: 30px; font-weight: 700; color: var(--accent); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }

/* ---------- Danger zone (destructive actions) ---------- */
.danger-zone { border: 1px solid #fecaca; background: #fef2f2; border-radius: var(--radius-lg); padding: 18px 20px; margin-top: 24px; max-width: 720px; }
.danger-zone h3 { margin-top: 0; color: var(--bad-ink); text-transform: none; letter-spacing: 0; font-size: 15px; }
.danger-zone input { width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; margin: 6px 0 12px; }
.danger-zone input:focus { outline: none; border-color: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }

/* ============================================================
   Auth pages (login / signup / MFA)
   ============================================================ */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(700px 380px at 15% 0%, color-mix(in srgb, #1F5BEA 7%, transparent), transparent 70%),
    radial-gradient(700px 380px at 85% 100%, color-mix(in srgb, #25D1B3 8%, transparent), transparent 70%),
    var(--wash);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--paper); padding: 34px 32px;
  border-radius: 18px; box-shadow: var(--shadow-3); border: 1px solid var(--line-soft);
}
.auth-card.wide { max-width: 520px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 14px; background: var(--accent);
  color: #fff; font-weight: 800; font-size: 20px; letter-spacing: .5px;
}
.auth-brand h1 { margin: 14px 0 2px; font-size: 24px; }
.auth-sub { margin: 0; color: var(--ink-3); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }
.auth-form input, .auth-form select {
  width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 9px; font-size: 14px;
  font-family: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-form input:focus, .auth-form select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, #fff);
}
.auth-submit { margin-top: 20px; width: 100%; padding: 11px 14px; font-size: 15px; }
.auth-sso { display: block; text-align: center; width: 100%; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
  color: var(--ink-4); font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { text-align: center; margin: 18px 0 0; color: var(--ink-3); font-size: 14px; }
.auth-foot a, .auth-brand a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
.auth-banner { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; padding: 10px 12px; border-radius: 9px; font-size: 14px; margin: 0 0 14px; }
.auth-error { background: #fef2f2; color: var(--bad-ink); border: 1px solid #fecaca; padding: 10px 12px; border-radius: 9px; font-size: 14px; margin: 0 0 14px; }
.auth-breakglass { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.auth-breakglass summary { color: var(--ink-4); font-size: 13px; cursor: pointer; }
.auth-breakglass summary:hover { color: var(--ink-3); }
.auth-breakglass input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 9px; font-family: inherit; }
.auth-code {
  text-align: center; font-size: 24px; letter-spacing: .35em; font-variant-numeric: tabular-nums;
}
.auth-qr { text-align: center; margin: 6px 0 4px; }
.auth-qr img { border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; }

/* Default (unbranded) login palette — matches the OpenCard logo (blue -> cyan
   -> teal), scoped to .auth so the rest of the app keeps its own accent color.
   Client-branded logins override these via brandLoginStyle(). */
.auth .btn { background: linear-gradient(135deg, #1F5BEA 0%, #18AEE0 55%, #25D1B3 100%); color: #fff; border: 0; }
.auth .btn:hover { filter: brightness(0.96); }
.auth .btn.secondary { background: #fff; color: #1F5BEA; border: 1.5px solid #1F5BEA; }
.auth .btn.secondary:hover { background: color-mix(in srgb, #1F5BEA 8%, #fff); filter: none; }
.auth .auth-foot a, .auth .auth-brand a { color: #1F5BEA; }
.auth .auth-form input:focus, .auth .auth-breakglass input:focus { border-color: #1F5BEA; box-shadow: 0 0 0 3px color-mix(in srgb, #1F5BEA 20%, #fff); }
.auth .auth-divider { color: #7c8aa5; }
.auth .auth-banner { background: #eef4ff; color: #123A70; border-color: #c7d7fb; }

/* legacy .login container (kept for any straggler pages) */
.login { max-width: 400px; margin: 64px auto; background: #fff; padding: 32px; border-radius: 16px; box-shadow: var(--shadow-3); border: 1px solid var(--line-soft); }
.login h1 { margin-top: 0; }
.login input { width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 9px; font-size: 14px; }
.login input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, #fff); }
.login label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }

/* ============================================================
   Plan & usage
   ============================================================ */
.usage { border-collapse: collapse; width: 100%; max-width: 420px; margin-top: 8px; border: none; box-shadow: none; border-radius: 0; }
.usage td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }

/* ============================================================
   Visual design editor (live preview)
   ============================================================ */
.design-editor { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.design-controls { flex: 1 1 320px; min-width: 280px; }
/* Rendered markdown docs (API reference). */
.md-doc h1 { font-size: 24px; margin: 4px 0 12px; }
.md-doc h2 { font-size: 19px; margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.md-doc h3 { font-size: 15px; margin: 18px 0 6px; }
.md-doc pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.md-doc pre code { background: none; border: none; color: inherit; padding: 0; }
.md-doc table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.md-doc th, .md-doc td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.md-doc th { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.md-doc blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--wash-2); border-radius: 0 8px 8px 0; color: var(--ink-2); }
.md-doc ul { padding-left: 22px; }
.md-doc hr { border: none; border-top: 1px solid var(--line-soft); margin: 20px 0; }

/* Card editor: form + sticky live phone preview side by side. */
.card-editor-flex { display: flex; gap: 28px; align-items: flex-start; }
.card-live-rail { flex: 0 0 296px; position: sticky; top: 16px; }
@media (max-width: 1100px) { .card-live-rail { display: none; } }

.design-preview-wrap { flex: 0 0 296px; text-align: center; }
.device { width: 280px; height: 520px; border-radius: 26px; overflow: hidden; border: 8px solid #111827; background: #fff; margin: 0 auto; box-shadow: 0 16px 40px rgba(17, 24, 39, .22); }
.device iframe { width: 100%; height: 100%; border: 0; display: block; }
.layout-thumbs { display: flex; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.layout-thumb { position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 7px 7px 4px; cursor: pointer; width: 64px; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.layout-thumb:hover { border-color: #d1d5db; }
.layout-thumb.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, #fff); }
.layout-thumb input { position: absolute; opacity: 0; pointer-events: none; }
.layout-thumb svg { width: 40px; height: 60px; color: var(--accent); display: block; margin: 0 auto 4px; }
.layout-thumb span { font-size: 11px; color: var(--ink-3); text-transform: capitalize; display: block; text-align: center; }
input.color { width: 100%; height: 40px; padding: 2px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; cursor: pointer; }

/* template gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tpl-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; box-shadow: var(--shadow-1); transition: box-shadow .15s ease; }
.tpl-card:hover { box-shadow: var(--shadow-2); }
.tpl-card .tpl-frame { width: 100%; height: 300px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-soft); background: #fff; }
.tpl-card .tpl-frame iframe { width: 170%; height: 170%; border: 0; transform: scale(0.588); transform-origin: top left; pointer-events: none; }
.tpl-card .tpl-name { font-weight: 600; margin-top: 8px; }
.tpl-pick { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; }
.tpl-pick label { position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 6px; width: 120px; cursor: pointer; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.tpl-pick label:hover { border-color: #d1d5db; }
.tpl-pick label.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, #fff); }
.tpl-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-pick .tpl-mini { width: 100%; height: 160px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-soft); }
.tpl-pick .tpl-mini iframe { width: 200%; height: 200%; border: 0; transform: scale(0.5); transform-origin: top left; pointer-events: none; }
.tpl-pick .tpl-cap { font-size: 12px; color: var(--ink-2); text-align: center; margin-top: 4px; }

/* ============================================================
   Photo cropper
   ============================================================ */
.cropper { margin: 12px 0; padding: 14px; background: var(--wash-2); border: 1px solid var(--line); border-radius: 10px; }
.crop-stage {
  position: relative; width: 300px; height: 300px; max-width: 100%;
  overflow: hidden; border-radius: 50%; background: var(--line);
  touch-action: none; cursor: grab; margin: 0 auto;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; user-select: none; -webkit-user-drag: none; }
.crop-controls { display: flex; align-items: center; gap: 18px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.crop-zoom { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.crop-zoom input[type=range] { width: 160px; }
.nudge { display: grid; grid-template-columns: repeat(4, 36px); gap: 6px; }
.nudge button {
  width: 36px; height: 36px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px;
  font-size: 16px; cursor: pointer;
}
.nudge button:hover { background: var(--wash); }

/* ============================================================
   Editor row widgets
   ============================================================ */
.social-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.social-row { display: flex; gap: 8px; align-items: center; }
.social-row .social-type { flex: 0 0 140px; }
.social-row .social-url { flex: 1; }
.social-row .social-remove { flex: 0 0 auto; padding: 8px 12px; line-height: 1; }

.labeled-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lr-row { display: flex; gap: 8px; align-items: center; }
.lr-row .lr-label { flex: 0 0 130px; }
.lr-row .lr-value { flex: 1; }
.lr-row .lr-remove { flex: 0 0 auto; padding: 8px 12px; line-height: 1; }

/* ---------- Self-service field checkboxes ---------- */
.self-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; margin: 6px 0 4px; }
.self-fields .chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 400; }
.self-fields .chk input { width: auto; }
.self-fields .self-inherit { grid-column: 1 / -1; }
.self-fields .self-inherit > span { min-width: 0; }
/* standalone checkboxes (QR toggle, template default, etc.) inside editor forms */
.chk { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
form.editor .chk input { width: auto; accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* ============================================================
   Small screens (phones + small tablets)
   ============================================================ */
@media (max-width: 720px) {
  :root { --editor-pad-x: 14px; }
  .admin { padding: 16px 12px 48px; }
  .admin h2 { font-size: 17px; }

  /* Keep every primary destination visible: identity/actions on the first row,
     navigation on its own full-width row. */
  .site-head-in {
    padding: 6px 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
  }
  .site-logo { grid-column: 1; grid-row: 1; min-height: 44px; }
  .site-logo img { height: 28px; }
  .site-nav {
    grid-column: 1 / -1; grid-row: 2;
    width: 100%; gap: 0; overflow: visible;
    justify-content: space-between;
  }
  .site-nav a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 7px 6px; font-size: 13px;
  }
  .site-actions { grid-column: 2; grid-row: 1; }
  .site-actions .btn { padding: 6px 10px; font-size: 13px; }

  /* Page headers stack: title block above the action buttons. */
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .topbar > div { justify-content: flex-start; }
  .topbar .btn { padding: 7px 11px; font-size: 13px; }
  .dashboard-tools { grid-template-columns: 1fr; gap: 12px; padding: 14px; }

  .grid2 { grid-template-columns: 1fr; }

  /* Tables scroll sideways instead of crushing their columns. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 8px 10px; font-size: 13px; }

  /* List tables marked .rsp become stacked cards instead: each row is a
     card, each cell shows its column name (from data-label) on the left. */
  table.rsp { display: block; border: none; box-shadow: none; background: transparent; overflow: visible; }
  table.rsp tr:has(> th) { display: none; }
  table.rsp tbody { display: block; }
  table.rsp tr {
    display: block; background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); margin-bottom: 10px; padding: 4px 14px;
    box-shadow: var(--shadow-1);
  }
  table.rsp tr:hover td { background: transparent; }
  table.rsp td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    border-bottom: 1px solid var(--line-soft); padding: 9px 0; font-size: 13.5px;
    text-align: right; white-space: normal !important;
  }
  table.rsp td:last-child { border-bottom: none; }
  table.rsp td::before {
    content: attr(data-label); flex: 0 0 auto;
    color: var(--ink-3); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em; text-align: left;
  }
  table.rsp td[data-label=""], table.rsp td:not([data-label]) { justify-content: flex-start; text-align: left; }
  table.rsp td[data-label=""]::before, table.rsp td:not([data-label])::before { content: none; }
  table.rsp td.rsp-actions { justify-content: flex-end; gap: 8px; }
  table.rsp td.rsp-actions::before { content: none; }
  table.rsp td.rsp-actions .btn { padding: 7px 12px; }
  table.rsp td.rsp-actions a:not(.btn) {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px; padding: 0 2px;
  }

  form.editor { padding: 16px var(--editor-pad-x); border-radius: var(--radius); }
  .panel { padding: 14px; }
  .item-card { padding: 12px; }
  .danger-zone { padding: 14px; }

  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .n { font-size: 24px; }

  .self-fields { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .design-preview-wrap { flex: 1 1 100%; }

  .auth { padding: 14px; align-items: flex-start; padding-top: 8vh; }
  .auth-card { padding: 24px 18px; }

  /* Bigger tap targets and no iOS zoom-on-focus (needs >=16px inputs). */
  form.editor input, form.editor textarea, form.editor select,
  .auth-form input, .auth-form select, .connect input, .connect textarea, .connect select {
    min-height: 44px; font-size: 16px;
  }
  form.editor label.chk {
    display: flex; align-items: center; min-height: 44px;
  }
  .btn { min-height: 44px; }
  .lr-remove, .social-remove { min-width: 44px; }
}

@media (max-width: 400px) {
  /* Tiny phones: labeled-value editor rows stack their dropdown + input. */
  .lr-row, .social-row { flex-wrap: wrap; }
  .lr-row .lr-label, .social-row .social-type { flex: 1 1 100%; }
}
