/* base.css — shared variables, reset, buttons, cards, forms. Loaded by every zone (plan.md §9). */

:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: #eff6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 24px rgba(15, 23, 42, .10);
  --header-h: 62px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-weight: 800; line-height: 1.2; }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
  cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 14px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.eyebrow {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-light); padding: 4px 11px; border-radius: 999px; margin-bottom: 10px;
}

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); }

/* Cards */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 5px; }
.field .error { font-size: .78rem; color: var(--danger); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: .92rem; transition: border-color .15s, box-shadow .15s;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.input.has-error { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 100px; }
.otp-input { letter-spacing: .5em; font-size: 1.3rem; text-align: center; font-weight: 700; }

/* Alerts / flash messages */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: .86rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--accent-light); color: #1e40af; border-color: #dbeafe; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state img, .empty-state svg { margin: 0 auto 14px; }
.empty-state h4 { color: var(--ink); font-size: 1rem; margin-bottom: 4px; }
.empty-state p { font-size: .86rem; }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; max-width: 320px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .84rem; box-shadow: var(--shadow-lg); }

/* Skeleton loaders */
.skeleton { background: linear-gradient(90deg, var(--bg-soft) 25%, #eef2f7 37%, var(--bg-soft) 63%); background-size: 400% 100%; animation: skeleton-wave 1.4s ease infinite; border-radius: 6px; }
@keyframes skeleton-wave { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* On-scroll reveal (vanilla-JS intersection observer hook — assets/js/main.js) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }

/* Tables that stack to cards below 480px */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th, table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; }
table.data-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }

@media (max-width: 480px) {
  table.data-table thead { display: none; }
  table.data-table, table.data-table tbody, table.data-table tr, table.data-table td { display: block; width: 100%; }
  table.data-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 8px 0; }
  table.data-table td { border-bottom: none; display: flex; justify-content: space-between; gap: 10px; }
  table.data-table td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: .74rem; text-transform: uppercase; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ====================================================================
   Contextual guidance: page-level hint banners + inline tooltips.
   Used across Super Admin + Org Admin so every screen can explain what
   it does and how to use it (plan.md UI-overhaul pass).
   ==================================================================== */

.page-hint {
  display: flex; gap: 10px; align-items: flex-start; background: var(--accent-light);
  border: 1px solid rgba(37, 99, 235, .16); color: #1e3a5f; border-radius: var(--radius-sm);
  padding: 12px 15px; font-size: .83rem; line-height: 1.55; margin-bottom: 20px;
}
.page-hint .icon { color: var(--accent); margin-top: 2px; }
.page-hint strong { color: var(--ink); }
.page-hint a { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.help-dot {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg-soft); color: var(--muted); font-size: .66rem; font-weight: 800;
  border: 1px solid var(--border); cursor: help; flex-shrink: 0; line-height: 1;
}
.help-dot:hover, .help-dot:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

/* CSS-only tooltip: add data-tip="text" (and, for touch/a11y fallback, a matching title="text")
   to any element. Positions above the element by default. */
[data-tip] { position: relative; }
[data-tip]::after, [data-tip]::before {
  opacity: 0; visibility: hidden; transition: opacity .15s ease, transform .15s ease;
  position: absolute; bottom: 100%; left: 50%; z-index: 80; pointer-events: none;
}
[data-tip]::after {
  content: attr(data-tip); transform: translate(-50%, 4px); background: var(--ink); color: #fff;
  font-size: .72rem; font-weight: 600; line-height: 1.4; padding: 6px 10px; border-radius: 6px;
  width: max-content; max-width: 220px; text-align: center; box-shadow: var(--shadow-lg); margin-bottom: 8px;
}
[data-tip]::before {
  content: ''; transform: translate(-50%, 4px); border: 5px solid transparent; border-top-color: var(--ink);
  margin-bottom: 3px;
}
[data-tip]:hover::after, [data-tip]:hover::before,
[data-tip]:focus-visible::after, [data-tip]:focus-visible::before { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
@media (hover: none) { [data-tip]::after, [data-tip]::before { display: none; } }

/* ====================================================================
   Admin shell — shared by Super Admin + Org Admin (plan.md §9).
   Fixed sidebar (never scrolls with the page), fixed topbar, independently
   scrolling content area. Mobile: sidebar collapses to a sticky horizontal bar.
   ==================================================================== */

.admin-body { background: var(--bg-soft); }

.admin-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--ink); color: #e2e8f0; display: flex; flex-direction: column;
  z-index: 50; overflow-y: auto;
}
.admin-sidebar .brand { display: flex; align-items: center; gap: 9px; padding: 18px 18px; font-weight: 800; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-sidebar .brand .logo-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: .82rem; }
.admin-nav { flex: 1; padding: 10px 10px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: .87rem; font-weight: 600; color: #cbd5e1; margin-bottom: 2px;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-sidebar .zone-tag { padding: 12px 18px; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }

.admin-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--border);
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
}
.admin-topbar .crumbs { font-size: .84rem; color: var(--muted); }
.admin-topbar .crumbs b { color: var(--ink); }
.admin-topbar .top-actions { display: flex; align-items: center; gap: 14px; }
.admin-user { display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; }
.admin-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .78rem; }
.admin-content { padding: 24px; flex: 1; }

.sub-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.sub-tabs a { padding: 10px 14px; font-size: .86rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.sub-tabs a.active, .sub-tabs a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .label { font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; }
.stat-card a { display: block; margin-top: 8px; font-size: .78rem; color: var(--accent); font-weight: 600; }

@media (max-width: 960px) {
  :root { --sidebar-w: 0px; }
  .admin-sidebar {
    position: sticky; top: 0; left: auto; bottom: auto; width: 100%; height: auto;
    flex-direction: row; overflow-x: auto; overflow-y: hidden; z-index: 60;
  }
  .admin-sidebar .brand, .admin-sidebar .zone-tag { display: none; }
  .admin-nav { display: flex; padding: 8px; flex: none; }
  .admin-nav a { white-space: nowrap; margin-bottom: 0; margin-right: 4px; }
  .admin-main { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}

/* Generic responsive grids for ad-hoc form/card layouts (plan.md §9 — 360px is non-negotiable;
   never override these with an inline grid-template-columns, which would beat these media queries). */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: end; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; }
.form-grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: end; }
@media (max-width: 760px) {
  .form-grid-3, .form-grid-4, .form-grid-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .form-grid-2, .form-grid-3, .form-grid-4, .form-grid-6 { grid-template-columns: 1fr; }
}

/* ====================================================================
   Shared components: filter chips, template gallery cards, pricing cards.
   Used by the public site (§6), the Super Admin template gallery (§5.5) and
   the Org Admin subscription/checkout page (§7.7) — written once per §9.
   ==================================================================== */

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: .82rem; font-weight: 600; color: var(--muted); }
.filter-chip.active, .filter-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.tmpl-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; }
.tmpl-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.tmpl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tmpl-thumb { height: 130px; position: relative; background: var(--accent-light); display: flex; align-items: center; justify-content: center; padding: 10px; }
.tmpl-thumb img { height: 100%; object-fit: contain; }
.tmpl-thumb .tag { position: absolute; top: 8px; left: 8px; background: #fff; color: var(--ink); font-size: .64rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); }
.tmpl-thumb .tag.featured { background: var(--accent); color: #fff; border-color: var(--accent); }
.tmpl-info { padding: 12px 14px 15px; }
.tmpl-info h4 { font-size: .92rem; margin-bottom: 2px; }
.tmpl-info p { color: var(--muted); font-size: .78rem; }
@media (max-width: 960px) { .tmpl-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 520px) { .tmpl-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }

.gallery-carousel { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.gallery-carousel img { width: 220px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--accent-light); }

.pricing-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; align-items: stretch; max-width: 980px; margin: 0 auto; }
.plan-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 18px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; position: relative; font-size: .92rem;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.plan-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.plan-card.popular { border-color: var(--accent); box-shadow: 0 14px 30px -14px rgba(37,99,235,.35); }
@media (hover: hover) and (min-width: 961px) {
  .plan-card.popular { transform: scale(1.02); z-index: 1; }
  .plan-card.popular:hover { transform: scale(1.02) translateY(-4px); }
}
.plan-card .ribbon {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  font-size: .64rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
  padding: 5px 13px; border-radius: 999px; box-shadow: 0 6px 14px -4px rgba(37,99,235,.55);
}
.plan-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: 2px; }
.plan-card .price { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; margin: 8px 0 0; line-height: 1.1; }
.plan-card .price span { font-size: .76rem; font-weight: 500; color: var(--muted); margin-left: 1px; }
.plan-card .duration { color: var(--muted); font-size: .74rem; margin: 6px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.plan-card ul { margin-bottom: 16px; flex: 1; display: flex; flex-direction: column; gap: 9px; }
.plan-card li { display: flex; gap: 7px; align-items: flex-start; font-size: .77rem; line-height: 1.4; }
.plan-card li .tick { flex-shrink: 0; width: 15px; height: 15px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: .58rem; font-weight: 800; margin-top: 1px; }
.plan-card .btn { padding: 9px 12px; font-size: .82rem; width: 100%; margin-top: auto; border-radius: var(--radius-sm); }
.billing-toggle { display: flex; justify-content: center; gap: 0; margin-bottom: 20px; }
.billing-toggle button { padding: 8px 20px; border: 1px solid var(--border); background: #fff; font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s ease, color .2s ease, border-color .2s ease; }
.billing-toggle button:first-child { border-radius: 999px 0 0 999px; }
.billing-toggle button:last-child { border-radius: 0 999px 999px 0; margin-left: -1px; }
.billing-toggle button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 960px) {
  .pricing-grid { grid-template-columns: repeat(2,1fr); gap: 18px; }
}
@media (max-width: 680px) {
  .pricing-grid { grid-template-columns: 1fr; gap: 16px; max-width: 360px; margin: 0 auto; }
  .plan-card { padding: 24px 20px 20px; }
  .plan-card.popular { order: -1; }
  .billing-toggle { gap: 0; }
  .billing-toggle button { flex: 1 1 0; padding: 9px 10px; }
}
@media (max-width: 480px) {
  .plan-card .price { font-size: 1.4rem; }
  .plan-card ul { gap: 9px; }
}
