/* Launch OS dashboard.
   A focused SaaS surface, not an IDE: one accent colour, generous spacing,
   and Monaco confined to the editor pane so the rest never reads as a code
   window. */

:root {
  --bg:        #0a0c11;
  --surface:   #11141c;
  --surface-2: #171b25;
  --raised:    #1d2230;
  --line:      #242a38;
  --line-soft: #1b2029;

  --ink:       #e9ecf5;
  --ink-dim:   #9aa3bd;
  --ink-faint: #656d85;

  --accent:      #4b6bff;
  --accent-soft: rgba(75, 107, 255, .14);
  --accent-ink:  #aebbff;

  --good: #32d583;
  --warn: #fdb022;
  --bad:  #f97066;

  --radius:    12px;
  --radius-sm: 8px;
  --sidebar:   232px;
  --shadow:    0 18px 48px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ boot */

.boot {
  height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 24px;
}
.boot-mark { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.boot-mark span { color: var(--accent); }
.boot-bar {
  width: 160px; height: 3px; border-radius: 99px;
  background: var(--line); overflow: hidden;
}
.boot-bar i {
  display: block; height: 100%; width: 40%; border-radius: 99px;
  background: var(--accent);
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ----------------------------------------------------------------- login */

.login-wrap { height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.login h1 span { color: var(--accent); }
.login .lede { margin: 0 0 28px; color: var(--ink-dim); font-size: 14px; }

/* --------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
  overflow-y: auto;
}
.brand {
  font-size: 17px; font-weight: 700; letter-spacing: -.02em;
  padding: 4px 10px 22px;
}
.brand span { color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.who { padding: 8px 11px; }
.who .email { font-size: 12.5px; color: var(--ink-dim); word-break: break-all; }
.who .ws { font-size: 13px; font-weight: 600; margin-bottom: 2px; }

.main { overflow-y: auto; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }
.crumb { color: var(--ink-faint); font-size: 13px; }
.crumb a:hover { color: var(--ink); }

.page { padding: 26px 28px 56px; flex: 1; }
.page.flush { padding: 0; display: flex; flex-direction: column; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13.5px; font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--raised); border-color: #2e3547; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #5a78ff; border-color: #5a78ff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: rgba(249,112,102,.3); background: rgba(249,112,102,.08); }
.btn.danger:hover:not(:disabled) { background: rgba(249,112,102,.16); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- inputs */

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-dim); margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }
.field .hint code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
select { cursor: pointer; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2, .card h3 {
  margin: 0 0 4px; font-size: 15px; font-weight: 620; letter-spacing: -.01em;
}
.card .card-sub { color: var(--ink-dim); font-size: 13px; margin: 0 0 18px; }
.card + .card { margin-top: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint);
}
.stat .value {
  font-size: 26px; font-weight: 680; letter-spacing: -.025em;
  margin-top: 7px; font-variant-numeric: tabular-nums;
}
.stat .sub { font-size: 12.5px; color: var(--ink-dim); margin-top: 3px; }

/* --------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th {
  text-align: left; padding: 11px 16px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-dim);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.live, .badge.paid, .badge.active {
  background: rgba(50,213,131,.12); color: var(--good); border-color: rgba(50,213,131,.25);
}
.badge.draft, .badge.pending {
  background: rgba(253,176,34,.12); color: var(--warn); border-color: rgba(253,176,34,.25);
}
.badge.refunded, .badge.failed, .badge.error, .badge.partially_refunded {
  background: rgba(249,112,102,.12); color: var(--bad); border-color: rgba(249,112,102,.25);
}
.badge.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 99px;
  background: currentColor; display: block;
}

/* ---------------------------------------------------------------- misc */

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button {
  padding: 6px 12px; border: 0; background: transparent; border-radius: 6px;
  color: var(--ink-dim); font-size: 12.5px; font-weight: 550; cursor: pointer;
}
.segmented button.active { background: var(--raised); color: var(--ink); }

.empty { text-align: center; padding: 64px 24px; color: var(--ink-dim); }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty p { margin: 0 0 20px; font-size: 13.5px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }

/* --------------------------------------------------------------- charts */

.chart { width: 100%; height: 190px; display: block; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .area { fill: url(#revGradient); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-faint); margin-top: 8px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-step { display: grid; grid-template-columns: 148px 1fr 72px; align-items: center; gap: 14px; }
.funnel-step .name { font-size: 13px; color: var(--ink-dim); }
.funnel-bar { height: 28px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7a92ff); border-radius: 6px; }
.funnel-step .count { text-align: right; font-weight: 620; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- funnels */

/* Thin revenue bar under a funnel name, for scanning the comparison table. */
.bar-mini {
  height: 3px; border-radius: 99px; background: var(--line);
  margin-top: 7px; max-width: 200px; overflow: hidden;
}
.bar-mini i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.step-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.step-row:last-child { border-bottom: 0; padding-bottom: 4px; }

.step-num {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12.5px; font-weight: 680;
}

.step-main { min-width: 0; }
.step-head {
  display: flex; align-items: center; gap: 9px;
  flex-wrap: wrap; margin-bottom: 9px;
}
.step-head strong { font-size: 14.5px; }
.step-head .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.step-bar {
  height: 8px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden; margin-bottom: 9px;
}
.step-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #7a92ff);
  transition: width .3s ease;
}

.step-stats {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-dim);
}
.step-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.step-stats .muted { color: var(--ink-faint); }

.step-drop { font-size: 12px; color: var(--warn); margin-top: 7px; }

.step-actions { display: flex; gap: 6px; align-items: center; }
.step-actions .btn.sm { padding: 5px 9px; }

@media (max-width: 860px) {
  .step-row { grid-template-columns: 28px 1fr; }
  .step-actions { grid-column: 2; margin-top: 8px; }
}

/* --------------------------------------------------------------- editor */

.editor { display: flex; flex-direction: column; height: calc(100vh - 0px); }

.editor-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.editor-bar .title { font-weight: 620; font-size: 15px; letter-spacing: -.01em; }
.editor-bar .meta { font-size: 12.5px; color: var(--ink-faint); }
.editor-bar .spacer { flex: 1; }

.save-state { font-size: 12.5px; color: var(--ink-faint); display: flex; align-items: center; gap: 6px; }
.save-state.dirty { color: var(--warn); }
.save-state.saved { color: var(--good); }

.editor-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.editor-pane { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }

.tabs { display: flex; gap: 2px; padding: 8px 12px 0; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 15px; border: 0; background: transparent;
  color: var(--ink-faint); font-size: 13px; font-weight: 560;
  cursor: pointer; border-radius: 7px 7px 0 0;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink-dim); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); background: var(--bg); }
.tab .dot { display: inline-block; width: 5px; height: 5px; border-radius: 99px; background: var(--warn); margin-left: 6px; vertical-align: middle; }

#monaco { flex: 1; min-height: 0; }

.preview-pane { display: flex; flex-direction: column; min-width: 0; background: var(--surface-2); }
.preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.preview-bar .spacer { flex: 1; }
.preview-stage { flex: 1; display: grid; place-items: center; padding: 18px; overflow: auto; min-height: 0; }
.preview-frame {
  border: 0; background: #fff; border-radius: 10px;
  box-shadow: var(--shadow);
  width: 100%; height: 100%;
  transition: width .22s ease, height .22s ease;
}
.preview-frame.tablet { width: 768px; max-width: 100%; height: min(1024px, 100%); }
.preview-frame.mobile { width: 390px; max-width: 100%; height: min(844px, 100%); }

/* --------------------------------------------------------------- drawer */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(4,6,10,.62);
  backdrop-filter: blur(3px); z-index: 60;
  display: grid; place-items: center; padding: 24px;
}
.drawer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
  padding: 26px;
}
.drawer.wide { width: min(760px, 100%); }
.drawer h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.02em; }
.drawer .card-sub { color: var(--ink-dim); font-size: 13px; margin: 0 0 22px; }
.drawer-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* --------------------------------------------------------------- toasts */

.toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  background: var(--raised); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow); max-width: 380px; font-size: 13.5px;
  animation: toast-in .2s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.bad  { border-left-color: var(--bad); }
.toast .t-title { font-weight: 620; margin-bottom: 2px; }
.toast .t-body { color: var(--ink-dim); font-size: 12.5px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .editor-body { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid var(--line); min-height: 44vh; }
  .preview-pane { min-height: 44vh; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; overflow-x: auto;
    padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 12px 0 4px; }
  .nav-item span { display: none; }
  .sidebar-foot { display: none; }
  .page { padding: 18px 16px 40px; }
  .topbar { padding: 16px; }
  .row { grid-template-columns: 1fr; }
}
