
:root{
  --bg:#F9FAFB;
  --card:#FFFFFF;
  --border:#E5E7EB;
  --text:#111827;
  --muted:#6B7280;
  --primary:#2563EB;
  --primaryDark:#1E3A8A;
  --success:#059669;
  --danger:#DC2626;
  --radius:10px;
  --radiusSm:10px;
  --radiusMd:12px;
  --radiusLg:16px;
  --shadow:0 1px 2px rgba(17,24,39,.06);
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial;

  /* typography scale */
  --fsH1:40px;
  --fsH2:22px;
  --fsH3:16px;
  --fsSmall:14px;
  --fsLabel:12px;
  --lhTight:1.1;
  --lhNormal:1.45;

  /* spacing scale */
  --sp8:8px;
  --sp10:10px;
  --sp12:12px;
  --sp14:14px;
  --sp16:16px;
  --sp18:18px;
  --sp24:24px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:var(--font); color:var(--text); background:var(--bg);
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
}
a{color:var(--primary); text-decoration:none}
a:hover{text-decoration:underline}

.container{max-width:1120px; margin:0 auto; padding:20px}
.container.narrow{max-width:860px}
.card{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.row{display:flex; gap:16px; align-items:stretch; flex-wrap:wrap}
.col{flex:1 1 320px}
.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 12px; border-radius:999px;
  background:#EFF6FF; border:1px solid #BFDBFE; color:var(--primaryDark);
  font-size:12px; font-weight:800; letter-spacing:.02em;
}
.small{font-size:var(--fsSmall); color:var(--muted); line-height:var(--lhNormal)}
.label{font-size:var(--fsLabel); letter-spacing:.08em; color:var(--muted); font-weight:800}
.h1{font-size:var(--fsH1); line-height:var(--lhTight); margin:0}
.h2{font-size:var(--fsH2); margin:0; line-height:1.25}
.h3{font-size:var(--fsH3); margin:0; line-height:1.35}

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
  padding:14px 16px; border-radius:var(--radiusMd); border:1px solid var(--border);
  font-weight:900; letter-spacing:.02em; cursor:pointer; user-select:none;
  background:var(--card); color:var(--text);
}
.btn.primary{background:var(--primary); border-color:var(--primary); color:#fff}
.btn.danger{border-color:var(--danger); color:var(--danger); background:#fff}
.btn:disabled{opacity:.55; cursor:not-allowed}
.nav{
  display:flex; justify-content:space-between; align-items:center; gap:16px;
  padding:16px 18px;
}
.nav a{font-weight:800; color:var(--text)}
.nav .links{display:flex; gap:14px; align-items:center}
.hero{
  padding:34px 0 18px;
}
.heroGrid{display:grid; grid-template-columns:1.2fr .8fr; gap:18px}
@media (max-width:900px){
  .heroGrid{grid-template-columns:1fr}
}

.kpi{padding:16px}
.kpi .value{font-size:26px; font-weight:900}
.hr{height:1px; background:var(--border); margin:16px 0}
.footer{padding:30px 0; color:var(--muted); font-size:14px}
.footer a{color:var(--muted)}

.badgeGrid{display:grid; grid-template-columns:repeat(4,1fr); gap:10px}
@media (max-width:900px){.badgeGrid{grid-template-columns:repeat(2,1fr)}}
.badge{padding:14px; border:1px solid var(--border); border-radius:12px; background:#fff}
.badge b{display:block}

.input, select{
  width:100%; padding:14px 14px; border:1px solid var(--border); border-radius:12px;
  background:#fff; font-size:16px;
}
.field{display:flex; flex-direction:column; gap:8px}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px}
@media (max-width:700px){.grid2{grid-template-columns:1fr}}

.notice{
  padding:14px; border-radius:12px; border:1px solid #BFDBFE; background:#EFF6FF;
  color:var(--primaryDark); font-weight:700
}
.warn{
  padding:14px; border-radius:12px; border:1px solid #FECACA; background:#FEF2F2;
  color:#991B1B; font-weight:800
}

.appShell{max-width:1120px; margin:0 auto; padding:16px}
.appTop{display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap}
.tabs{display:flex; gap:8px; flex-wrap:wrap}
.tab{padding:10px 12px; border-radius:999px; border:1px solid var(--border); background:#fff; font-weight:900; color:var(--text)}
.tab.active{border-color:#BFDBFE; background:#EFF6FF; color:var(--primaryDark)}
.split{display:grid; grid-template-columns: 1.4fr .8fr; gap:16px}
@media (max-width:900px){.split{grid-template-columns:1fr}}

.modalOverlay{
  position:fixed; inset:0; background:rgba(17,24,39,.45); display:none; align-items:center; justify-content:center; padding:20px;
}
.modalOverlay.show{display:flex}
.modal{max-width:720px; width:100%; background:#fff; border:1px solid var(--border); border-radius:16px; box-shadow:0 16px 40px rgba(0,0,0,.22); padding:18px}
.modalHeader{display:flex; gap:12px; align-items:flex-start; margin-bottom:12px}
.modalIcon{width:40px; height:40px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-weight:900; border:1px solid var(--border); background:#F9FAFB}
.modalIcon.warn{border-color:#FECACA; background:#FEF2F2; color:#991B1B}
.modalIcon.info{border-color:#BFDBFE; background:#EFF6FF; color:var(--primaryDark)}
.modalTitle{font-size:20px; font-weight:950; margin:0; line-height:1.25}
.modalSub{margin-top:4px; color:var(--muted); line-height:1.55}
.modalBody{margin-top:10px}
.modal .actions{display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; margin-top:16px}

.progress{height:10px; background:var(--border); border-radius:999px; overflow:hidden}
.progress > div{height:100%; background:var(--success); width:0%}


.chip{display:inline-block;padding:2px 8px;border-radius:999px;border:1px solid #E5E7EB;background:#F9FAFB;font-size:12px;color:#374151;margin-right:6px}


/* accessibility */
:focus-visible{ outline: 3px solid rgba(17,24,39,.35); outline-offset: 2px; border-radius: 10px; }


/* utility helpers to avoid inline styles (CSP friendly) */
.flex{display:flex}
.flexCol{display:flex;flex-direction:column}
.alignCenter{align-items:center}
.alignStart{align-items:flex-start}
.justifyBetween{justify-content:space-between}
.justifyEnd{justify-content:flex-end}
.gap10{gap:10px}
.gap12{gap:12px}
.pad10x14{padding:10px 14px}
.pad12x14{padding:12px 14px}
.pad14{padding:14px}
.pad16{padding:16px}
.pad18{padding:18px}
.pad24{padding:24px}
.mt3{margin-top:3px}
.mt6{margin-top:6px}
.mt8{margin-top:8px}
.mt10{margin-top:10px}
.mt14{margin-top:14px}
.mt16{margin-top:16px}
.mt40{margin-top:40px}
.my18{margin:18px 0}
.my12{margin:12px 0}
.my10{margin:10px 0}
.block{display:block}
.m0{margin:0}
.center{text-align:center}
.lh17{line-height:1.7}
.pl18{padding-left:18px}
.fs18{font-size:18px}
.opacity80{opacity:.8}
.sp10{height:10px}
.sp12{height:12px}
.sp14{height:14px}
.sp16{height:16px}
.sp18{height:18px}
.sp24{height:24px}

/* SW update banner */
.swUpdate{
  display:none;
  position:fixed;
  left:16px; right:16px; bottom:16px;
  z-index:9999;
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px 14px;
  box-shadow:0 8px 24px rgba(0,0,0,.08);
}
.swUpdate.show{display:block}
.swUpdateRow{display:flex;align-items:center;justify-content:space-between;gap:12px}
.swUpdateText{font-size:13px;color:var(--text)}
.swUpdateMuted{color:var(--muted)}
.swUpdateActions{display:flex;align-items:center;gap:10px}
.swUpdateBtn{
  border:1px solid #D1D5DB;
  background:#111827;
  color:#fff;
  border-radius:10px;
  padding:8px 10px;
  font-size:13px;
  cursor:pointer;
}
.swUpdateBtn:hover{opacity:.92}

.swUpdateBtnSecondary{
  border:1px solid #D1D5DB;
  background:#fff;
  color:#111827;
  border-radius:10px;
  padding:8px 10px;
  font-size:13px;
  cursor:pointer;
}
.swUpdateBtnSecondary:hover{background:#F9FAFB}

.swUpdateIcon{
  width:34px;
  height:34px;
  line-height:32px;
  text-align:center;
  border-radius:10px;
  border:1px solid #E5E7EB;
  background:#fff;
  font-size:20px;
  cursor:pointer;
  color:#111827;
}
.swUpdateIcon:hover{background:#F9FAFB}

/* admin reauth banner */
.banner{
  border:1px solid #E5E7EB;
  background:#FFFFFF;
  border-radius:12px;
  padding:12px 14px;
}
.bannerWarn{border-color:#BFDBFE;background:#EFF6FF}
.bannerRow{display:flex;gap:10px;align-items:flex-start}

.minW140{min-width:140px}


/* more utilities for templates */
.wrapRow{display:flex;justify-content:flex-start;gap:8px;flex-wrap:wrap}
.preWrap{white-space:pre-wrap}
.minW260{min-width:260px}
.textRight{text-align:right}
.flex1{flex:1}
.cardInset{border:1px solid var(--border);border-radius:12px;padding:12px;background:#fff}
.skeletonBar{height:20px;border-radius:8px;background:var(--border)}
.muted6{margin-top:6px;color:var(--muted)}
.muted10{margin-top:10px;color:var(--muted)}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}
.hidden{display:none}
.hide{display:none !important}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.gap8{gap:8px}
.gap14{gap:14px}


.justifyStart{justify-content:flex-start}
.m0mb8{margin:0 0 8px 0}
.gridSpanAll{grid-column:1 / -1}
.w70{width:70%}


/* admin nav polish */
.adminFav .btn{ display:inline-flex; align-items:center; gap:8px; }
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
}
.badge.hide{ display:none; }

.opsHighlight{ padding:12px; margin-bottom:12px; }

/* breadcrumbs (SEO + UX) */
.breadcrumbs{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; font-size:13px; color:var(--muted); }
.breadcrumbs a{ color:var(--muted); text-decoration:none; }
.breadcrumbs a:hover{ text-decoration:underline; }
.breadcrumbs .sep{ opacity:0.6; }

/* responsive: admin nav grid */
@media (max-width: 720px){
  .grid2{ grid-template-columns: 1fr; }
  .adminFav{ gap:8px; }
}

/* micro UX polish */
.btn.tiny{padding:8px 10px;border-radius:10px;font-weight:900;font-size:12px}
tr.rowActive{outline:2px solid rgba(59,130,246,0.35); outline-offset:-2px}
tr.rowClick{cursor:pointer}
tr.rowClick:hover{background:rgba(0,0,0,0.03)}

/* subtle pulse for L/R indicator */
.skeletonBar{transition:background .18s ease, box-shadow .18s ease}
.skeletonBar.pulseOn{background:var(--primary); box-shadow:0 0 0 3px rgba(59,130,246,0.18)}

/* accessibility: focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline: 3px solid rgba(37,99,235,.35);
  outline-offset: 2px;
}

/* utilities for CSP-safe templates */
.hidden{display:none !important;}
.block{display:block;}
.flex1{flex:1;}
.w100{width:100%;}
.h120{height:120px;}
.hAuto{height:auto;}
.br12{border-radius:12px;}
.bgSoft{background:rgba(0,0,0,0.03);}
.bdSoft{border:1px solid rgba(0,0,0,.15);}
.mt3{margin-top:3px;}
.mt6{margin-top:6px;}
.mt8{margin-top:8px;}
.mt10{margin-top:10px;}
.mt12{margin-top:12px;}
.ml8{margin-left:8px;}
.gap8{gap:8px;}
.minW90{min-width:90px;}
.minW140{min-width:140px;}
.minW160{min-width:160px;}
.minW240{min-width:240px;}
.minW260{min-width:260px;}
.maxW920{max-width:920px;}
.minH34{min-height:34px;}
.minH120{min-height:120px;}
.minH360{min-height:360px;}
.maxH60vh{max-height:60vh;}
.overflowAuto{overflow:auto;}
.wrap{flex-wrap:wrap;}
.justifyBetween{justify-content:space-between;}
.justifyEnd{justify-content:flex-end;}
.itemsCenter{align-items:center;}
.labelRow{display:flex; gap:8px; align-items:flex-start;}
.colorSwatch{width:44px; padding:0;}
.logo16{height:16px; width:auto; border-radius:4px;}
.pad10{padding:10px;}
.gap12{gap:12px;}
.preWrap{white-space:pre-wrap;}

.skipLink{
  position:absolute;
  left:-9999px;
  top:8px;
  background:var(--card);
  border:1px solid var(--border);
  padding:10px 12px;
  border-radius:12px;
  box-shadow:var(--shadow);
  z-index:9999;
}
.skipLink:focus{left:8px;}

/* Accessibility: explicit focus states */
:focus {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  box-shadow:0 0 0 2px #fff, 0 0 0 5px rgba(0,95,204,0.35);
}

/* Privacy table responsive */
.tableResponsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tableResponsive table {
  min-width: 600px;
}

.mb10{margin-bottom:10px;}


/* Forms polish */
.field label{display:block;font-weight:600;margin-bottom:6px;}
.field .help{display:block;font-size:12px;opacity:.85;margin-top:6px;}
input:disabled,textarea:disabled,select:disabled{opacity:.6;cursor:not-allowed;}
button:disabled,.btn:disabled{opacity:.55;cursor:not-allowed;}
.btn.loading{position:relative;pointer-events:none;opacity:.75;}
.btn.loading:after{content:'…';position:relative;margin-left:6px;}


/* Print styles for legal pages */
@media print{
  nav, .btn, .skipLink, .card .label{display:none !important;}
  body{background:#fff;color:#000;}
  main{max-width:800px;margin:0 auto;}
  a:after{content:" (" attr(href) ")";font-size:12px;}
}


/* Toast */
.toastWrap{position:fixed;left:12px;right:12px;bottom:12px;z-index:9999;display:flex;flex-direction:column;gap:10px;pointer-events:none;}
@media(min-width:720px){.toastWrap{left:auto;right:16px;bottom:16px;max-width:420px;}}
.toast{pointer-events:auto;background:#fff;border-radius:16px;padding:12px 12px;box-shadow:0 10px 25px rgba(0,0,0,0.18);border:1px solid rgba(0,0,0,0.08);display:flex;gap:10px;align-items:flex-start;}
.toastIcon{width:24px;height:24px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-weight:800;flex:0 0 auto;}
.toastIcon.info{background:rgba(0,95,204,0.10);color:rgb(0,95,204);}
.toastIcon.warn{background:rgba(204,95,0,0.12);color:rgb(204,95,0);}
.toastIcon.ok{background:rgba(0,140,70,0.12);color:rgb(0,140,70);}
.toastTitle{font-weight:700;margin-top:1px;}
.toastMsg{font-size:13px;opacity:.92;margin-top:2px;line-height:1.3;}
.toastClose{margin-left:auto;flex:0 0 auto;border:none;background:transparent;opacity:.75;cursor:pointer;font-size:18px;line-height:1;padding:2px 6px;border-radius:10px;}
.toastClose:focus-visible{outline:none;box-shadow:0 0 0 2px #fff, 0 0 0 5px rgba(0,95,204,0.35);} 

/* ops metrics */
.taRight{text-align:right;}
.rowBetween{display:flex;align-items:center;justify-content:space-between;gap:10px;}
