:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --brand: #06c755;
  --brand-dark: #04a947;
  --danger: #d92d20;
  --warn: #b54708;
  --shadow: 0 8px 28px rgba(20, 30, 45, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
.app { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { background: #101828; color: #fff; padding: 22px 16px; }
.brand { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.nav { display: grid; gap: 4px; }
.nav a {
  color: #d0d5dd;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a.active, .nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.main { padding: 24px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat { font-size: 32px; font-weight: 700; }
.muted { color: var(--muted); }
.flash { padding: 11px 13px; border-radius: 8px; margin-bottom: 16px; background: #ecfdf3; color: #027a48; border: 1px solid #abefc6; }
.flash.error { background: #fef3f2; color: #b42318; border-color: #fecdca; }
label { display: block; font-size: 13px; font-weight: 700; margin: 10px 0 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.pill { display: inline-flex; border-radius: 999px; padding: 4px 8px; background: #eef4ff; color: #3538cd; font-size: 12px; font-weight: 700; }
.pill.on { background: #dcfae6; color: #067647; }
.pill.off { background: #f2f4f7; color: #475467; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(420px, 100%); }
.reply-list { display: grid; gap: 10px; }
.reply-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.reply-item header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.preview { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; word-break: break-word; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; overflow: hidden; }
.media img, .media video { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #eef2f6; border-radius: 6px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 700; font-size: 13px; }
.tabs a.active { color: #fff; background: #101828; border-color: #101828; }
.flex-preview-wrap { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 14px; align-items: stretch; }
.flex-preview {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf4f0;
  padding: 14px;
  display: grid;
  place-items: center;
}
.flex-phone {
  width: min(320px, 100%);
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .12);
}
.flex-hero { width: 100%; aspect-ratio: 20 / 13; object-fit: cover; background: #eef4ff; display: block; }
.flex-body { padding: 16px; display: grid; gap: 8px; }
.flex-title { font-weight: 800; font-size: 20px; line-height: 1.25; }
.flex-text { color: #475467; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.flex-price { color: var(--brand); font-size: 24px; font-weight: 800; }
.flex-meta { color: #98a2b3; font-size: 12px; }
.flex-footer { padding: 0 16px 16px; display: grid; gap: 8px; }
.flex-button { border-radius: 8px; padding: 10px; text-align: center; font-weight: 800; background: var(--brand); color: #fff; }
.flex-button.secondary { background: #eef4ff; color: #3538cd; border: 1px solid #c7d7fe; }
.flex-promo .flex-body { background: #101828; color: #fff; }
.flex-promo .flex-text { color: #eaecf0; }
.flex-promo .flex-meta { color: #84e1bc; font-weight: 800; }
.flex-promo .flex-price { color: #fff; font-size: 18px; border-top: 1px solid #344054; padding-top: 12px; }
.flex-compact-inner { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 14px; }
.flex-compact-inner img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; background: #eef4ff; }
#flex-json-preview { min-height: 260px; font-family: Consolas, monospace; font-size: 12px; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.builder-main { display: grid; gap: 16px; }
.builder-side { display: grid; gap: 16px; }
.sticky { position: sticky; top: 16px; }
.builder-step {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 8px;
}
.template-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.template-cards label {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  background: #fff;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
}
.template-cards input { width: auto; }
.template-cards label:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(6,199,85,.14); }
.builder-save { min-height: 50px; font-size: 16px; }
.media-pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.media-pick {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  cursor: pointer;
}
.media-pick img, .media-pick video { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px; background: #eef2f6; }
.media-pick span { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .flex-preview-wrap { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; }
  .template-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky { position: static; }
}
