:root{
  --bg:#f6f8fc;
  --card:#ffffff;
  --text:#0f172a;         /* slate-900 */
  --muted:#64748b;        /* slate-500 */
  --line:#e2e8f0;         /* slate-200 */
  --primary:#0b5ed7;      /* kait-like blue */
  --primary-2:#3b82f6;    /* brighter blue */
  --primary-soft:#e8f1ff; /* light blue */
  --danger:#b00020;
  --danger-soft:#ffe8ee;
  --shadow: 0 10px 26px rgba(15,23,42,.08);
  --radius:16px;
  --radius2:12px;
  --focus: 0 0 0 4px rgba(11,94,215,.16);
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  background: radial-gradient(900px 420px at 20% 0%, var(--primary-soft) 0%, var(--bg) 55%);
  color:var(--text);
}

.container{
  max-width: 1240px;
  margin: 26px auto;
  padding: 0 16px;
}

.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 14px;
}

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:48px;
  height:48px;
  object-fit:contain;
}
.brand h1{ font-size: 20px; margin:0; letter-spacing:.2px; }
.brand p{ margin:2px 0 0; color:var(--muted); font-size: 12px; }

.card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar{
  padding: 14px;
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  align-items:end;
}

.field{ display:flex; flex-direction:column; gap:6px; }
label{ color: var(--muted); font-size: 12px; }

input{
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border:1px solid var(--line);
  outline:none;
  background: #fff;
  color: var(--text);
}
input::placeholder{ color: rgba(100,116,139,.7); }
input:focus{ box-shadow: var(--focus); border-color: rgba(11,94,215,.4); }

.btn{
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border:1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor:pointer;
  transition: transform .06s ease, filter .12s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  line-height:1.2;
  font: inherit;
  vertical-align:middle;
  white-space:nowrap;
}
.btn:hover{ filter: brightness(1.02); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.45; cursor:not-allowed; }

.btn.primary{
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color:#fff;
  border-color: rgba(11,94,215,.35);
}
.btn.danger{
  background: var(--danger-soft);
  border-color: rgba(176,0,32,.25);
  color: var(--danger);
}

.meta{
  display:flex;
  gap:10px;
  align-items:center;
  padding: 0 14px 12px;
}

.badge{
  padding: 6px 10px;
  border-radius: 999px;
  border:1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background:#fff;
}

.cards{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:12px;
  padding: 0 14px 14px;
}
.kcard{
  background: #fff;
  border:1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  padding: 14px;
}
.klabel{ color: var(--muted); font-size: 12px; }
.kvalue{ font-size: 30px; font-weight: 800; margin-top: 8px; }
.ksub{ color: var(--muted); font-size: 12px; margin-top: 6px; }

.charts{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:12px;
  padding: 0 14px 14px;
}
.chart{ padding: 14px; }
.chart-title{ font-weight: 700; margin-bottom: 10px; }

.table-wrap{ overflow:auto; border-top:1px solid var(--line); }
table{ width:100%; border-collapse:collapse; min-width: 900px; }
th,td{ padding:12px 12px; border-bottom:1px solid var(--line); font-size: 13px; }
th{
  text-align:left;
  color: var(--muted);
  font-weight: 700;
  cursor:pointer;
  user-select:none;
  background: #fbfdff;
}
tr:hover td{ background: #f7fbff; }

.small-btn{
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border:1px solid var(--line);
  background: var(--primary-soft);
  color: var(--primary);
  cursor:pointer;
}

.drawer{
  position: fixed;
  top: 0; right: 0;
  width: 520px; max-width: 95vw;
  height: 100%;
  background: #fff;
  border-left:1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
  transform: translateX(110%);
  transition: transform .18s ease;
  overflow:auto;
}
.drawer.open{ transform: translateX(0); }
.drawer h3{ margin: 6px 0 10px; }
.drawer pre{
  white-space: pre-wrap;
  background: #fbfdff;
  border:1px solid var(--line);
  padding: 10px;
  border-radius: 12px;
  overflow:auto;
}

.row2{ display:flex; justify-content:space-between; align-items:center; gap: 10px; }

@media (max-width: 980px){
  .cards{ grid-template-columns: 1fr; }
  .charts{ grid-template-columns: 1fr; }
}

/* Date Range Picker (CSP-safe, local) */
.drp-backdrop{
  position:fixed; inset:0;
  background: rgba(10,16,28,.45);
  display:flex; align-items:center; justify-content:center;
  z-index:9999;
}
.drp{
  width:min(900px, 94vw);
  background:#fff;
  border-radius:16px;
  box-shadow:0 16px 60px rgba(10,16,28,.25);
  padding:16px;
}
.drp-head{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:12px; padding:6px 6px 14px;
}
.drp-title{ font-size:18px; font-weight:800; color:#0f172a; }
.drp-sub{ font-size:12px; color:#64748b; margin-top:2px; }
.drp-x{
  border:0; background:transparent; font-size:18px;
  cursor:pointer; padding:6px 10px; border-radius:10px;
}
.drp-x:hover{ background:#f1f5f9; }

.drp-calwrap{
  display:grid; grid-template-columns:1fr 1fr;
  gap:16px;
}
@media (max-width: 720px){
  .drp-calwrap{ grid-template-columns:1fr; }
}

.drp-cal{ border:1px solid #e2e8f0; border-radius:14px; padding:12px; }
.drp-cal-head{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:10px; gap:8px;
}
.drp-month{ font-weight:800; color:#0f172a; }
.drp-nav{
  border:1px solid #e2e8f0; background:#fff;
  border-radius:10px; padding:6px 10px;
  cursor:pointer;
}
.drp-nav:hover{ background:#f8fafc; }

.drp-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap:6px;
  user-select:none;
}
.drp-dow{
  font-size:11px; color:#64748b;
  text-align:center; padding:6px 0;
}
.drp-day{
  height:38px;
  border-radius:10px;
  border:1px solid transparent;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  color:#0f172a;
}
.drp-day:hover{ background:#f1f5f9; }
.drp-day.muted{ color:#94a3b8; cursor:default; }
.drp-day.muted:hover{ background:transparent; }

.drp-day.start, .drp-day.end{
  background:#2563eb; color:#fff;
}
.drp-day.inrange{
  background:#dbeafe; color:#0f172a;
}
.drp-day.start{ border-top-right-radius:10px; border-bottom-right-radius:10px; }
.drp-day.end{ border-top-left-radius:10px; border-bottom-left-radius:10px; }

.drp-foot{
  margin-top:14px;
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; flex-wrap:wrap;
}
.drp-range{ color:#0f172a; font-size:13px; }
.drp-actions{ display:flex; gap:8px; }

.btn.ghost{
  background:#fff;
  border:1px solid #e2e8f0;
}
.btn.ghost:hover{ background:#f8fafc; }
.btn.primary{
  background:#2563eb;
  border:1px solid #2563eb;
  color:#fff;
}
.btn.primary:disabled{
  opacity:.5; cursor:not-allowed;
}
.viewer-topbar{
  display:flex;
  justify-content:flex-start;
  align-items:center;
  margin-bottom:14px;
}

.form-card-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
}

.form-state-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  border:1px solid var(--line);
  white-space:nowrap;
}

.form-state-badge.done{
  background:#ecfdf3;
  color:#15803d;
  border-color:rgba(21,128,61,.18);
}

.form-state-badge.pending{
  background:#eff6ff;
  color:#1d4ed8;
  border-color:rgba(29,78,216,.18);
}

.form-state-note{
  margin-top:8px;
  font-size:12px;
  font-weight:600;
}

.form-state-note.done{
  color:#15803d;
}

.form-state-note.pending{
  color:#1d4ed8;
}

.form-card.form-state-done{
  border-color:rgba(21,128,61,.22);
  background:linear-gradient(180deg,#ffffff 0%, #f4fff8 100%);
}

.form-card.form-state-pending{
  border-color:rgba(29,78,216,.18);
  background:linear-gradient(180deg,#ffffff 0%, #f8fbff 100%);
}

.form-card.form-state-done:hover,
.form-card.form-state-pending:hover,
.form-card.form-state-done.active,
.form-card.form-state-pending.active{
  box-shadow:var(--shadow);
}
/* ---------- richer shared dashboard / builder visuals ---------- */

.header,
.toolbar-top{
  position: relative;
}

.header::after,
.toolbar-top::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:-10px;
  height:1px;
  background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(148,163,184,.08), rgba(59,130,246,.22));
}

.card{
  background:
    linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,251,255,.98) 100%);
}

.kcard{
  position:relative;
  overflow:hidden;
  border-color: rgba(59,130,246,.14);
  background:
    radial-gradient(120px 60px at 100% 0%, rgba(59,130,246,.09) 0%, transparent 70%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.kcard::before{
  content:"";
  position:absolute;
  inset:0 auto 0 0;
  width:4px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  opacity:.9;
}

.kcard:nth-child(2){
  background:
    radial-gradient(120px 60px at 100% 0%, rgba(16,185,129,.10) 0%, transparent 70%),
    linear-gradient(180deg, #ffffff 0%, #f6fffb 100%);
}
.kcard:nth-child(2)::before{
  background: linear-gradient(180deg, #34d399, #059669);
}

.kcard:nth-child(3){
  background:
    radial-gradient(120px 60px at 100% 0%, rgba(245,158,11,.12) 0%, transparent 70%),
    linear-gradient(180deg, #ffffff 0%, #fffaf2 100%);
}
.kcard:nth-child(3)::before{
  background: linear-gradient(180deg, #fbbf24, #d97706);
}

.chart.card{
  border-color: rgba(59,130,246,.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,251,255,.98) 100%);
}

.chart-title{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--text);
}

.chart-title::before{
  content:"";
  width:10px;
  height:10px;
  border-radius:999px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}

.badge{
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.badge.ok{
  color:#15803d;
  border-color:rgba(21,128,61,.18);
  background:#ecfdf3;
}

.table-wrap{
  border-top:1px solid var(--line);
  background: linear-gradient(180deg, rgba(248,251,255,.55) 0%, rgba(255,255,255,.98) 100%);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

thead th{
  position:sticky;
  top:0;
  z-index:1;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7ff 100%);
}

tr:hover td{
  background:#f3f8ff;
}

.detail-btn{
  height:32px;
  padding:0 12px;
  border-radius:10px;
  border:1px solid rgba(59,130,246,.18);
  background: var(--primary-soft);
  color: var(--primary);
  font: inherit;
  cursor:pointer;
}

.detail-btn:hover{
  filter: brightness(1.02);
}

.drawer{
  background:
    linear-gradient(180deg, rgba(255,255,255,.99) 0%, rgba(248,251,255,.99) 100%);
}

.drawer h3{
  color:var(--text);
}

.drawer pre{
  background: linear-gradient(180deg, #fbfdff 0%, #f8fbff 100%);
}

/* better form builder card tones */
.mini-card{
  position:relative;
  overflow:hidden;
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
}

.mini-card::before{
  content:"";
  position:absolute;
  inset:0 auto 0 0;
  width:4px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  opacity:.75;
}

.mini-card:hover,
.mini-card.active{
  transform: translateY(-1px);
}

.mini-card .pill{
  font-weight:700;
}

.mini-card .pill:has-text("published"){
  font-weight:700;
}

/* fallback explicit status styling via class hooks if later added */
.pill.status-published{
  color:#15803d;
  border-color:rgba(21,128,61,.18);
  background:#ecfdf3;
}
.pill.status-draft{
  color:#1d4ed8;
  border-color:rgba(29,78,216,.18);
  background:#eff6ff;
}
.pill.status-archived{
  color:#64748b;
  border-color:rgba(100,116,139,.16);
  background:#f8fafc;
}

.question{
  border-color: rgba(59,130,246,.14);
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 8px 20px rgba(15,23,42,.04);
}

.question strong{
  color: var(--text);
}

.option{
  padding:6px 4px;
  border-radius:12px;
}

.option:hover{
  background: rgba(59,130,246,.045);
}

input[type="radio"],
input[type="checkbox"]{
  accent-color: var(--primary-2);
}

.table-wrap{
  position: relative;
  z-index: 0;
}

thead th{
  position: sticky;
  top: 0;
  z-index: 2;
}

.drawer{
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1200;
}

.drawer.open{
  z-index: 1200;
}


.progress-gain-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:12px;
}

.progress-gain-card{
  background:linear-gradient(180deg,#ffffff 0%, #f8fbff 100%);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  box-shadow:0 8px 18px rgba(15,23,42,.04);
}

.progress-gain-title{
  font-weight:700;
  margin-bottom:10px;
}

.progress-gain-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  padding:10px 0;
  border-top:1px solid rgba(226,232,240,.9);
}

.progress-gain-row:first-of-type{
  border-top:0;
  padding-top:0;
}

.progress-gain-range{
  font-size:13px;
  font-weight:600;
}

.progress-gain-sub{
  margin-top:4px;
  font-size:12px;
  color:var(--muted);
}

.progress-gain-value{
  font-size:18px;
  font-weight:800;
  white-space:nowrap;
}
