/* ============================================================
   Widgetly — design system
   Light SaaS theme · emerald brand accent · dark slate sidebar
   ============================================================ */

:root {
  /* brand */
  --brand: #087657;
  --brand-600: #065f46;
  --brand-700: #064e3b;
  --brand-soft: #e6f7f0;
  --brand-glow: rgba(15, 157, 114, 0.32);

  /* accent secondary (warm) for charts / highlights */
  --amber: #f5a524;
  --violet: #7c5cff;
  --rose: #f4527a;
  --sky: #2e90fa;

  /* neutrals — light */
  --bg: #f6f7f9;
  --bg-grid: #eef0f3;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --line: #e7eaee;
  --line-strong: #d7dce2;
  --ink: #0d1b16;
  --ink-2: #3d4a45;
  --muted: #56636b;
  --muted-2: #66737b;

  /* dark sidebar */
  --sb-bg: #0f1714;
  --sb-bg-2: #14201b;
  --sb-line: #233029;
  --sb-ink: #e8efeb;
  --sb-muted: #a9b8b1;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(13, 27, 22, 0.06), 0 1px 3px rgba(13, 27, 22, 0.04);
  --shadow-md: 0 4px 14px rgba(13, 27, 22, 0.07), 0 2px 6px rgba(13, 27, 22, 0.05);
  --shadow-lg: 0 22px 50px -18px rgba(13, 27, 22, 0.28);
  --shadow-pop: 0 30px 60px -22px rgba(13, 27, 22, 0.35);

  --font-display: "Bricolage Grotesque", "Plus Jakarta Sans", sans-serif;
  --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --sb-w: 248px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

::selection { background: var(--brand); color: #fff; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; min-height:44px; }
input, select, textarea { font-family: inherit; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.58; }
:focus-visible { outline: 3px solid #1677c8; outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6dc; border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b6bfc7; }

/* ============================================================
   Layout shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background:
    radial-gradient(120% 80% at 0% 0%, #16241d 0%, transparent 60%),
    var(--sb-bg);
  border-right: 1px solid var(--sb-line);
  color: var(--sb-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  gap: 6px;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--brand) 0%, #16c98e 100%);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -4px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,0.35);
  flex: none;
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: #fff;
}
.brand-name span { color: #4fe0aa; }
.brand-tag {
  font-size: 10.5px;
  color: var(--sb-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sb-muted);
  padding: 14px 12px 6px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--sb-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s var(--ease);
  position: relative;
  min-height:44px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { color: var(--sb-ink); background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(100deg, rgba(15,157,114,0.22), rgba(15,157,114,0.05));
  box-shadow: inset 0 0 0 1px rgba(15,157,114,0.28);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  background: rgba(15,157,114,0.18);
  color: #4fe0aa;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.sb-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--sb-line); }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 12px;
  transition: background 0.15s;
}
.sb-user:hover { background: rgba(255,255,255,0.04); }
.sb-ava {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--violet), var(--sky));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.sb-user .nm { font-size: 13px; font-weight: 700; color: #fff; }
.sb-user .em { font-size: 11px; color: var(--sb-muted); }

/* upgrade card */
.sb-upsell {
  margin: 4px 4px 12px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(15,157,114,0.16), rgba(15,157,114,0.03));
  border: 1px solid rgba(15,157,114,0.22);
}
.sb-upsell h4 { margin: 0 0 4px; font-size: 13px; color: #fff; font-weight: 700; }
.sb-upsell p { margin: 0 0 10px; font-size: 11.5px; color: var(--sb-muted); line-height: 1.4; }
.sb-upsell .bar { height: 6px; border-radius: 20px; background: rgba(255,255,255,0.08); overflow: hidden; }
.sb-upsell .bar i { display: block; height: 100%; width: 62%; background: linear-gradient(90deg, var(--brand), #2fe3a0); border-radius: 20px; }
.sb-upsell small { display: block; margin-top: 7px; font-size: 10.5px; color: var(--sb-muted); }

/* ---- Main ---- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 30px;
  background: rgba(246,247,249,0.82);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.topbar .grow { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 13px; width: 280px;
  box-shadow: var(--shadow-sm);
  transition: border 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search svg { width: 16px; height: 16px; color: var(--muted-2); }
.search input { border: 0; outline: 0; background: none; font-size: 13.5px; width: 100%; color: var(--ink); }
.search kbd {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}

.content { padding: 30px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 11px;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  transition: all 0.16s var(--ease); white-space: nowrap;
  background: var(--surface); color: var(--ink); border-color: var(--line);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(150deg, var(--brand), var(--brand-600));
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 20px -6px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:hover { box-shadow: 0 12px 26px -6px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,0.25); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; min-height: 44px; }
.btn-icon { padding: 9px; min-width: 44px; min-height: 44px; }
.btn-icon svg { width: 17px; height: 17px; }

/* ============================================================
   Cards / generic
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--ic, var(--brand-soft)); opacity: 0.16; filter: blur(4px);
}
.stat .ic {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 12px;
}
.stat .ic svg { width: 17px; height: 17px; }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .val { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat .delta { font-size: 11.5px; font-weight: 700; margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.stat .delta svg { width: 13px; height: 13px; transform: rotate(-45deg); }
.delta.down svg { transform: rotate(45deg); }
.delta.up { color: var(--brand-600); }
.delta.down { color: var(--rose); }

/* ============================================================
   Catalog
   ============================================================ */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border 0.2s;
  display: flex; flex-direction: column;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.cat-thumb {
  height: 168px; position: relative; overflow: hidden;
  display: grid; place-items: center; padding: 18px;
  background: radial-gradient(120% 120% at 50% 0%, #fff 0%, var(--bg-grid) 100%);
  border-bottom: 1px solid var(--line);
}
.cat-thumb::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 22px 22px; opacity: 0.4; mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 80%);
}
.cat-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.cat-body h3 { margin: 0; font-family: var(--font-display); font-size: 16.5px; font-weight: 600; letter-spacing: -0.015em; }
.cat-body p { margin: 5px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.cat-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.cat-foot .use { margin-left: auto; color: var(--brand-600); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; transition: gap 0.15s; }
.cat-card:hover .cat-foot .use { gap: 9px; }
.tagpill { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--bg); border: 1px solid var(--line); padding: 3px 9px; border-radius: 20px; }

/* ============================================================
   Widget list (dashboard)
   ============================================================ */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); transition: all 0.15s; }
.seg button.on { background: var(--brand-soft); color: var(--brand-700); }

.wlist { display: flex; flex-direction: column; gap: 12px; }
.wrow {
  display: grid; grid-template-columns: 52px 1.6fr 1fr 1fr auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow-sm); transition: border 0.15s, box-shadow 0.15s, transform 0.15s;
}
.wrow:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.wtype-ic { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; }
.wtype-ic svg { width: 21px; height: 21px; }
.wrow .nm { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.wrow .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; }
.tbadge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.mini-stat { text-align: left; }
.mini-stat .n { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.mini-stat .k { font-size: 11px; color: var(--muted); font-weight: 600; }
.row-actions { display: flex; gap: 5px; }
.spark { width: 96px; height: 34px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); display: inline-block; }
.dot.paused { background: var(--muted-2); }

/* status pill */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--brand-700); }
.status.off { color: var(--muted); }

/* empty */
.empty { text-align: center; padding: 70px 20px; }
.empty .ic { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 18px; }
.empty .ic svg { width: 30px; height: 30px; }
.empty h3 { font-family: var(--font-display); font-size: 20px; margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* ============================================================
   Builder
   ============================================================ */
.builder { display: grid; grid-template-columns: 372px 1fr; height: 100vh; }
.builder-main { min-width: 0; display: flex; flex-direction: column; }

/* config panel */
.cfg {
  background: var(--surface); border-right: 1px solid var(--line);
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.cfg-head { padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 5; }
.cfg-head .back { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.cfg-head .back:hover { color: var(--ink); }
.cfg-head .nm-edit { display: flex; align-items: center; gap: 8px; }
.cfg-head input.title {
  font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -0.02em;
  border: 1px solid transparent; background: transparent; width: 100%; border-radius: 8px; padding: 4px 6px; color: var(--ink);
}
.cfg-head input.title:hover { background: var(--bg); }
.cfg-head input.title:focus { outline: 0; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }

/* tabs */
.cfg-tabs { display: flex; gap: 2px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); position: sticky; top: 81px; background: var(--surface); z-index: 4; }
.cfg-tab {
  border: 0; background: none; padding: 9px 12px 12px; font-size: 12.5px; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px; transition: color 0.15s;
}
.cfg-tab svg { width: 15px; height: 15px; }
.cfg-tab:hover { color: var(--ink); }
.cfg-tab.on { color: var(--brand-700); border-bottom-color: var(--brand); }

.cfg-body { padding: 18px 20px 40px; flex: 1; }
/* ---- AI generate bar ---- */
.ai-gen { background: linear-gradient(135deg, var(--brand-soft), var(--bg)); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 18px; }
.ai-gen-row { display: flex; gap: 8px; align-items: stretch; }
.ai-gen .ai-brief { flex: 1; min-width: 0; }
.ai-gen .ai-go { white-space: nowrap; }
.ai-gen .ai-go svg { width: 15px; height: 15px; }
.ai-gen .ai-hint { font-size: 11px; color: var(--muted); margin-top: 7px; }
.ai-gen .ai-go[disabled] { opacity: 0.62; cursor: progress; transform: none; box-shadow: none; }
.ai-gen .ai-go.is-loading svg { animation: ai-spin 0.8s linear infinite; transform-origin: 50% 50%; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.cfg-pane { display: none; animation: fade 0.25s var(--ease); }
.cfg-pane.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 5px; }
.inp, .ta, .sel {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; background: var(--surface-2); color: var(--ink); transition: border 0.15s, box-shadow 0.15s;
  min-height: 44px;
}
.inp:focus, .ta:focus, .sel:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }
.ta { resize: vertical; min-height: 70px; line-height: 1.5; }
.sel { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7780' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; }

/* color swatches */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 44px; height: 44px; padding:0; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); cursor: pointer; transition: transform 0.12s; position: relative; }
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }
.sw.custom { display: grid; place-items: center; background: conic-gradient(from 0deg, #f4527a, #f5a524, #0f9d72, #2e90fa, #7c5cff, #f4527a); }
.sw.custom svg { width: 14px; height: 14px; color: #fff; mix-blend-mode: difference; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* segmented control inside config */
.optset { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.optset button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 9px 8px;
  font-size: 12px; font-weight: 600; color: var(--muted); transition: all 0.14s; display: grid; gap: 4px; place-items: center;
  min-height: 48px;
}
.optset button svg { width: 16px; height: 16px; }
.optset button:hover { border-color: var(--line-strong); color: var(--ink); }
.optset button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-700); }

/* toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-top: 1px solid var(--line); }
.toggle-row:first-child { border-top: 0; }
.toggle-row .t-lbl { font-size: 13px; font-weight: 600; }
.toggle-row .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.switch { position: relative; width: 48px; height: 44px; flex: none; display:inline-block; }
.switch input { position:absolute; inset:0; opacity:0; width:100%; height:100%; margin:0; }
.switch .track { position: absolute; left:2px; right:2px; top:10px; height:24px; background: #aeb7bd; border-radius: 20px; transition: background 0.2s; pointer-events:none; }
.switch .track::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform 0.2s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid #1677c8; outline-offset: 3px; }

/* range */
.range-wrap { display: flex; align-items: center; gap: 12px; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 5px; border-radius: 20px; background: var(--line-strong); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); cursor: pointer; box-shadow: 0 2px 6px var(--brand-glow), 0 0 0 3px #fff; transition: transform 0.12s; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink-2); min-width: 40px; text-align: right; }

.cfg-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 10px; }
.cfg-foot .btn { flex: 1; }

.sec-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 22px 0 12px; }
.sec-label:first-child { margin-top: 0; }

/* item list editor */
.item-edit { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; position: relative; }
.item-edit .del { position: absolute; top: 9px; right: 9px; border: 0; background: none; color: var(--muted); padding: 10px; width:44px; height:44px; border-radius: 9px; }
.item-edit .del:hover { color: var(--rose); background: #fdeef1; }
.item-edit .field:last-child { margin-bottom: 0; }
.add-item { width: 100%; border: 1.5px dashed var(--line-strong); background: none; border-radius: 11px; padding: 11px; color: var(--brand-700); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s; }
.add-item:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ---- Preview stage ---- */
.stage-bar { display: flex; align-items: center; gap: 14px; padding: 14px 26px; border-bottom: 1px solid var(--line); background: var(--surface); }
.stage-bar .grow { flex: 1; }
.device-toggle { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.device-toggle button { border: 0; background: none; padding: 7px 14px; min-height:44px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; }
.device-toggle button svg { width: 15px; height: 15px; }
.device-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.stage {
  flex: 1; overflow: auto; position: relative;
  background:
    radial-gradient(110% 90% at 50% 0%, #fff, transparent 70%),
    var(--bg);
  background-color: var(--bg);
  display: grid; place-items: center; padding: 40px;
}
.stage::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--line-strong) 1.1px, transparent 1.1px);
  background-size: 26px 26px; opacity: 0.5; pointer-events: none;
  mask-image: radial-gradient(100% 70% at 50% 40%, #000, transparent 80%);
}

/* device frame */
.frame {
  position: relative; z-index: 1;
  background: #fff; border-radius: 22px;
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--line);
  transition: width 0.4s var(--ease), max-width 0.4s var(--ease);
  width: 100%; max-width: 880px; overflow: hidden;
}
.frame.mobile { max-width: 390px; border-radius: 34px; padding: 11px; background: #0f1714; }
.frame .bar {
  height: 38px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 7px; padding: 0 14px; border-radius: 22px 22px 0 0;
}
.frame.mobile .bar { display: none; }
.frame .bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--line-strong); display: block; }
.frame .bar i:nth-child(1) { background: #ff5f57; }
.frame .bar i:nth-child(2) { background: #febc2e; }
.frame .bar i:nth-child(3) { background: #28c840; }
.frame .bar .url { margin-left: 10px; font-size: 11px; color: var(--muted); font-family: var(--font-mono); background: var(--bg); border-radius: 7px; padding: 4px 12px; flex: 1; }
.frame .viewport { background: #fff; min-height: 380px; padding: 30px; position: relative; overflow: hidden; }
.frame.mobile .viewport { border-radius: 26px; min-height: 540px; padding: 22px 16px; }
#preview.is-overlay { position: absolute; inset: 30px; }
.frame.mobile #preview.is-overlay { inset: 22px 16px; }
/* mobile device frame: reflow multi-column widgets as on a narrow screen */
.frame.mobile #preview .wgt-tgrid.layout-grid,
.frame.mobile #preview .wgt-tgrid.layout-masonry { grid-template-columns: 1fr; }
.frame.mobile #preview .wgt-cta.layout-banner { flex-direction: column; text-align: center; }
.frame.mobile #preview .wgt-cta.layout-banner .wgt-cta-btns { margin: 0; }
.frame.mobile #preview .wgt-cd:not(.layout-boxes) .wgt-cdsep { display: none; }
.frame.mobile #preview .wgt-cd { flex-wrap: wrap; gap: 8px; }
.frame.mobile #preview .wgt-announce { flex-wrap: wrap; }
.frame.mobile .notch { width: 110px; height: 22px; background: #0f1714; border-radius: 0 0 16px 16px; position: absolute; top: 11px; left: 50%; transform: translateX(-50%); z-index: 9; }

/* fake page content behind widget for context */
.faux { opacity: 0.5; pointer-events: none; user-select: none; }
.faux .h { height: 13px; border-radius: 6px; background: var(--bg-grid); margin-bottom: 9px; }
.faux .h.w1 { width: 55%; height: 19px; } .faux .h.w2 { width: 90%; } .faux .h.w3 { width: 80%; } .faux .h.w4 { width: 70%; }

/* ============================================================
   Embed code panel / drawer
   ============================================================ */
.code-block {
  background: #0f1714; border-radius: 14px; padding: 16px 18px; position: relative;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; color: #c7d4cd;
  overflow-x: auto; border: 1px solid var(--sb-line);
}
.code-block .tk-tag { color: #5fd8a8; }
.code-block .tk-attr { color: #f5c46b; }
.code-block .tk-str { color: #9ad0ff; }
.code-block .tk-com { color: #5c6d65; }
.code-copy { position: absolute; top: 12px; right: 12px; }

/* ============================================================
   Modal / drawer
   ============================================================ */
.overlay { position: fixed; inset: 0; background: rgba(13,27,22,0.45); backdrop-filter: blur(3px); z-index: 100; display: none; opacity: 0; transition: opacity 0.2s; }
.overlay.open { display: block; opacity: 1; }
.modal {
  position: fixed; z-index: 101; top: 50%; left: 50%; transform: translate(-50%, -46%);
  width: min(560px, calc(100vw - 40px)); background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-pop); border: 1px solid var(--line); opacity: 0;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease); pointer-events: none;
}
.modal.open { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.modal-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-family: var(--font-display); font-size: 18px; margin: 0; letter-spacing: -0.02em; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   Toast
   ============================================================ */
.toasts { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 11px; background: #0f1714; color: #fff;
  padding: 12px 16px 12px 14px; border-radius: 13px; box-shadow: var(--shadow-pop);
  font-size: 13.5px; font-weight: 600; border: 1px solid var(--sb-line);
  animation: toastIn 0.32s var(--ease); max-width: 90vw;
}
.toast.out { animation: toastOut 0.25s var(--ease) forwards; }
.toast .ti { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(15,157,114,0.2); color: #4fe0aa; flex: none; }
.toast .ti svg { width: 16px; height: 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ============================================================
   Analytics
   ============================================================ */
.an-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chart-card { padding: 20px 22px; }
.chart-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.chart-head h3 { font-family: var(--font-display); font-size: 16px; margin: 0; letter-spacing: -0.015em; }
.chart-head .grow { flex: 1; }
.legend { display: flex; gap: 16px; }
.legend span { font-size: 12px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.an-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.an-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.an-stat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.an-stat .v { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }

/* ============================================================
   Settings & Domains pages
   ============================================================ */
.set-content { max-width: 760px; }
.set-card { padding: 22px 24px; margin-bottom: 18px; }
.set-h { font-family: var(--font-display); font-size: 16px; margin: 0 0 16px; letter-spacing: -0.015em; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.set-grid .field { margin-bottom: 16px; }
.set-foot { display: flex; align-items: center; gap: 12px; padding: 4px 0 24px; }
.danger-card { border-color: #f4c2cf; }
.dom-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--line); }
.dom-row:first-child { border-top: 0; }
.dom-row .nm { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; display: flex; align-items: center; }
.dom-row .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .set-grid { grid-template-columns: 1fr; }
  .dom-row { flex-wrap: wrap; }
}

/* ============================================================
   Home hero (personalized dashboard greeting)
   ============================================================ */
.home-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.home-hero .hero-l { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.hero-ava {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--violet), var(--sky));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px;
  box-shadow: var(--shadow-sm);
}
.hero-greet { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.hero-sub { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
.hero-sub b { color: var(--ink-2); }

/* ============================================================
   Onboarding flow
   ============================================================ */
#ob-root { position: fixed; inset: 0; z-index: 500; }
.ob-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 0%, rgba(15,157,114,0.18), rgba(13,27,22,0.62));
  backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.32s var(--ease);
}
#ob-root.show .ob-overlay { opacity: 1; }
.ob-modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(0.97);
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border-radius: 24px; border: 1px solid var(--line);
  box-shadow: var(--shadow-pop); opacity: 0;
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease);
}
#ob-root.show .ob-modal { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ob-skip { position: absolute; top: 16px; right: 18px; z-index: 3; border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px; transition: all 0.15s; }
.ob-skip:hover { color: var(--ink); background: var(--bg); }
.ob-progress { display: flex; align-items: center; gap: 12px; padding: 18px 24px 0; }
.ob-track { display: flex; gap: 6px; flex: 1; }
.ob-dot { height: 5px; flex: 1; border-radius: 20px; background: var(--line-strong); transition: background 0.3s var(--ease); }
.ob-dot.done { background: var(--brand); }
.ob-step-n { font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ob-stage { transition: opacity 0.14s var(--ease); }
.ob-body, .ob-hero { padding: 24px 28px 8px; }
.ob-hero { text-align: center; padding-top: 30px; }
.ob-logo {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 16px;
  background: linear-gradient(150deg, var(--brand), #16c98e); display: grid; place-items: center;
  box-shadow: 0 12px 30px -8px var(--brand-glow);
}
.ob-logo svg { width: 30px; height: 30px; color: #fff; }
.ob-hero h1 { font-family: var(--font-display); font-size: 27px; letter-spacing: -0.03em; margin: 0 0 8px; }
.ob-hero p { font-size: 14px; color: var(--muted); max-width: 440px; margin: 0 auto 22px; line-height: 1.55; }
.ob-feats { display: grid; gap: 10px; text-align: left; }
.ob-feat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.ob-feat span { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.ob-feat span svg { width: 18px; height: 18px; }
.ob-feat b { font-size: 13.5px; display: block; }
.ob-feat small { font-size: 12px; color: var(--muted); }
.ob-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brand-700); background: var(--brand-soft); padding: 5px 11px; border-radius: 20px; margin-bottom: 14px; }
.ob-kicker svg { width: 13px; height: 13px; }
.ob-body h2 { font-family: var(--font-display); font-size: 22px; letter-spacing: -0.025em; margin: 0 0 6px; }
.ob-body > p { font-size: 13.5px; color: var(--muted); margin: 0 0 20px; line-height: 1.55; }
.ob-err { color: var(--rose); font-size: 12.5px; font-weight: 600; min-height: 16px; margin: 4px 0 0; }
.ob-types { display: grid; gap: 9px; max-height: 320px; overflow: auto; padding-right: 2px; }
.ob-type { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 13px; padding: 13px 15px; transition: all 0.15s var(--ease); }
.ob-type:hover { border-color: var(--line-strong); }
.ob-type.on { border-color: var(--brand); background: var(--brand-soft); }
.ob-type .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.ob-type .ic svg { width: 19px; height: 19px; }
.ob-type .tx { flex: 1; min-width: 0; }
.ob-type .tx b { font-size: 14px; display: block; letter-spacing: -0.01em; }
.ob-type .tx small { font-size: 12px; color: var(--muted); display: block; line-height: 1.4; }
.ob-check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; color: #fff; transition: all 0.15s; }
.ob-check svg { width: 14px; height: 14px; opacity: 0; transition: opacity 0.15s; }
.ob-type.on .ob-check { background: var(--brand); border-color: var(--brand); }
.ob-type.on .ob-check svg { opacity: 1; }
.ob-code { position: relative; background: #0f1714; border-radius: 13px; padding: 16px 18px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; color: #c7d4cd; overflow-x: auto; border: 1px solid var(--sb-line); margin-bottom: 16px; }
.ob-code-copy { position: absolute; top: 12px; right: 12px; color: var(--sb-muted); }
.ob-code-copy svg { width: 15px; height: 15px; }
.ob-ready { display: flex; align-items: center; gap: 13px; background: var(--brand-soft); border: 1px solid rgba(15,157,114,0.22); border-radius: 13px; padding: 14px 16px; }
.ob-ready .ic { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.ob-ready .ic svg { width: 18px; height: 18px; }
.ob-ready b { font-size: 13.5px; display: block; }
.ob-ready small { font-size: 12px; color: var(--ink-2); }
.ob-foot { display: flex; align-items: center; gap: 10px; padding: 16px 28px 24px; }

/* ============================================================
   Utility
   ============================================================ */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.hide { display: none !important; }
.mb-0 { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior:auto !important; } *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count:1 !important; transition-duration: 0.01ms !important; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  :root { --sb-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform 0.3s var(--ease); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex !important; }
  .builder { grid-template-columns: 1fr; height: auto; }
  .cfg { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .builder-main { height: auto; }
  .stage { padding: 24px 14px; min-height: 60vh; }
}
.menu-btn { display: none; }
@media (max-width: 640px) {
  .content { padding: 18px 16px; }
  .topbar { padding: 14px 16px; }
  .search { display: none; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
  .wrow { grid-template-columns: 44px 1fr auto; gap: 12px; }
  .wrow .mini-stat, .wrow .spark { display: none; }
  .an-stats, .an-grid { grid-template-columns: 1fr; }
  .home-hero { flex-direction: column; align-items: stretch; gap: 14px; }
  .home-hero .btn { width: 100%; }
  /* onboarding fills the small screen */
  .ob-modal { width: calc(100vw - 20px); max-height: calc(100vh - 24px); top: 12px; left: 10px; transform: translate(0, 0) scale(0.98); }
  #ob-root.show .ob-modal { transform: translate(0, 0) scale(1); }
  .ob-body, .ob-hero { padding: 20px 18px 6px; }
  .ob-hero { padding-top: 24px; }
  /* keep the step counter clear of the absolutely-positioned Skip button */
  .ob-progress { padding: 18px 92px 0 18px; }
  .ob-foot { padding: 14px 18px 20px; flex-wrap: wrap; }
  .ob-foot .btn { flex: 1; min-width: 130px; }
  .ob-hero h1 { font-size: 23px; }
  .ob-types { max-height: 42vh; }
}
