/* Shared UI kit for WeCodeNCraft demos — plain CSS, no external deps */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #5b5bd6;
  --accent-600: #4a4ac4;
  --accent-50: #eef0ff;
  --accent-100: #e0e3ff;
  --green: #059669; --green-50: #ecfdf5;
  --amber: #b45309; --amber-50: #fffbeb;
  --red: #dc2626; --red-50: #fef2f2;
  --blue: #2563eb; --blue-50: #eff6ff;
  --violet: #7c3aed; --violet-50: #f5f3ff;
  --slate-50: #f1f5f9;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg { flex-shrink: 0; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Demo banner */
.demo-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 7px 16px; background: #0f172a; color: #e2e8f0; font-size: 12.5px; position: relative; z-index: 60; }
.demo-banner b { color: #fff; font-weight: 600; }
.demo-banner .db-actions { display: flex; gap: 8px; align-items: center; }
.demo-banner a.db-cta { background: #fff; color: #0f172a; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.demo-banner a.db-mail { color: #cbd5e1; font-size: 12px; }
.demo-banner a.db-mail:hover { color: #fff; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 36px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: calc(100vh - 36px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 12px 10px 4px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-weight: 500; white-space: nowrap; }
.nav-item:hover { background: var(--slate-50); color: var(--text); }
.nav-item.active { background: var(--accent-50); color: var(--accent-600); }
.nav-item .nav-badge { margin-left: auto; font-size: 11px; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 18px; font-weight: 650; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.view { display: none; flex-direction: column; gap: 20px; min-width: 0; }
.view.active { display: flex; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-100); color: var(--accent-600); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h3 { font-size: 14.5px; font-weight: 600; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.g-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; }

/* KPI */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.delta-up { color: var(--green); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }
.kpi.flash .k-value { animation: flash 1s ease; }
@keyframes flash { 0% { color: var(--accent); transform: scale(1.04); } 100% { color: inherit; transform: none; } }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 550; font-size: 13px; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: #c4c9d2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-600); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--slate-50); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, .select { height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; background: var(--surface); min-width: 0; }
.input:focus, .select:focus, .btn:focus-visible { outline: 2px solid var(--accent-100); border-color: var(--accent); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 32px; width: 240px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label.field .input, label.field .select { width: 100%; color: var(--text); font-weight: 400; }

/* Chips & badges */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 550; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .c-count { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--slate-50); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.b-green { background: var(--green-50); color: var(--green); }
.b-amber { background: var(--amber-50); color: var(--amber); }
.b-red { background: var(--red-50); color: var(--red); }
.b-blue { background: var(--blue-50); color: var(--blue); }
.b-violet { background: var(--violet-50); color: var(--violet); }
.b-gray { background: var(--slate-50); color: var(--text-2); }
.b-accent { background: var(--accent-50); color: var(--accent-600); }

/* Segmented */
.seg { display: inline-flex; background: var(--slate-50); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-weight: 550; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 550; color: var(--text-2); font-size: 12px; padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: #fafbff; }
.tbl tr.row-flag td { background: #fff7f7; }
.tbl .t-right { text-align: right; }
.tbl .cell-main { font-weight: 550; }
.tbl .cell-sub { font-size: 12px; color: var(--text-3); }
.tbl tr.new-row td { animation: rowIn 1.6s ease; }
@keyframes rowIn { 0% { background: var(--accent-50); } 100% { background: transparent; } }
.empty { padding: 36px; text-align: center; color: var(--text-3); }

/* Drawer & modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; background: var(--surface); z-index: 90; box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.drawer-b { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.drawer-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--slate-50); }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.98); width: 480px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 95; opacity: 0; pointer-events: none; transition: all .2s; }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal-h { padding: 18px 20px 6px; display: flex; align-items: flex-start; gap: 10px; }
.modal-b { padding: 10px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.section-t { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.done .dot { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px #fff; }
.timeline li.current .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px #fff, 0 0 0 4px var(--accent-50); }
.timeline .t-title { font-weight: 550; font-size: 13px; }
.timeline .t-sub { font-size: 12px; color: var(--text-3); }
.timeline li.pending .t-title { color: var(--text-3); }

/* Toast */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 120; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 10px; align-items: center; animation: toastIn .25s ease; max-width: 360px; }
.toast .t-ico { width: 20px; height: 20px; border-radius: 50%; background: var(--green); display: grid; place-items: center; flex-shrink: 0; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* Phone frame */
.phone-stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 32px; align-items: start; }
.phone { width: 360px; height: 740px; border-radius: 46px; background: #0b0f19; padding: 12px; box-shadow: 0 30px 60px rgba(15,23,42,.25), inset 0 0 0 2px #2b3243; position: relative; flex-shrink: 0; }
.phone-screen { width: 100%; height: 100%; border-radius: 36px; background: #f4f5f8; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.phone-notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 110px; height: 28px; background: #0b0f19; border-radius: 0 0 16px 16px; z-index: 5; }
.phone-status { height: 40px; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 26px 4px; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.p-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.p-head { padding: 10px 18px 12px; display: flex; align-items: center; gap: 10px; }
.p-head h2 { font-size: 18px; }
.p-pad { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.p-card { background: #fff; border-radius: 14px; padding: 13px 14px; border: 1px solid #eceef2; }
.p-foot { padding: 12px 16px 20px; background: #fff; border-top: 1px solid #eceef2; display: flex; gap: 8px; flex-shrink: 0; }
.p-foot .btn { flex: 1; height: 44px; border-radius: 12px; font-size: 14px; }
.sig-pad { width: 100%; height: 150px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: #fff; touch-action: none; display: block; cursor: crosshair; }
.photo-ph { aspect-ratio: 4/3; border-radius: 12px; border: 1.5px dashed var(--border-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); cursor: pointer; font-size: 12.5px; text-align: center; overflow: hidden; }
.photo-ph.filled { border-style: solid; border-color: transparent; }
.photo-ph svg.shot { width: 100%; height: 100%; display: block; }
.explainer h2 { font-size: 22px; margin-bottom: 8px; }
.explainer ul { padding-left: 18px; color: var(--text-2); line-height: 1.7; }

/* Progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--slate-50); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

/* Responsive */
@media (max-width: 1180px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-main-side { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); gap: 2px; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { padding: 0 8px 0 2px; }
  .brand-text, .nav-label, .sidebar-foot { display: none !important; }
  .nav-item { width: auto; padding: 7px 10px; }
  .topbar { position: static; padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .g-3, .g-2 { grid-template-columns: minmax(0,1fr); }
  .phone-stage { grid-template-columns: minmax(0,1fr); justify-items: center; }
  .search .input { width: 100%; }
  .search { flex: 1; min-width: 160px; }
}
@media (max-width: 560px) {
  .g-5, .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi { padding: 12px 14px; }
  .kpi .k-value { font-size: 19px; }
  .phone { width: 100%; max-width: 360px; height: 700px; border-radius: 40px; padding: 10px; }
  .drawer { width: 100vw; }
  .kv { grid-template-columns: 110px 1fr; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .demo-banner { font-size: 11.5px; gap: 6px 10px; }
  .card-h, .card-b { padding-left: 14px; padding-right: 14px; }
}
@media print {
  .demo-banner, .sidebar, .topbar, .toasts { display: none !important; }
}
.align-start { align-items: start; }
