:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #6b726e;
  --line: #e4e1d8;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --side: #17312a;
  --side-ink: #cfe0d8;
  --warn: #a85a00;
  --warn-soft: #fff1dc;
  --danger: #b3261e;
  --danger-soft: #fbe7e5;
  --info-soft: #e7eef8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14.5px; line-height: 1.55; color: var(--ink); background: var(--bg);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h2 { font-size: 18px; }
h3 { font-size: 15.5px; }
code { background: #efece4; padding: 1px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; display: block; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex: 0 0 236px; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; padding: 4px 8px 14px; }
.brand.big { color: var(--ink); justify-content: center; font-size: 22px; padding-bottom: 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: #3fb08f; color: #0d241e;
  display: grid; place-items: center; font-weight: 800;
}
.proj { padding: 10px 8px 14px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.proj label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.proj select { width: 100%; margin-top: 4px; background: #23443b; color: #fff; border: 0; }
.proj-name { color: #fff; font-weight: 600; margin-top: 2px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--side-ink); text-decoration: none; font-weight: 500;
}
.side nav a svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: #2a5246; color: #fff; }
.side-foot { font-size: 12.5px; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); opacity: .8; }
.side-foot a { color: var(--side-ink); }
.main { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.top h1 { font-size: 22px; margin: 0; }
.menu-btn { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }
.content { padding: 12px 28px 48px; max-width: 1240px; }

/* Cards & layout */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }
.stat small { color: var(--accent); font-weight: 600; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13.5px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid #d4d0c5; border-radius: 8px;
  background: #fff; color: var(--ink); width: 100%; min-width: 0;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd1c1; border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
select[multiple] { min-height: 110px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #cfcabd; background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f7f5f0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #185a4a; }
.btn.danger { color: var(--danger); border-color: #e7b9b5; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn.ai { background: #f3eefe; border-color: #d9cdf6; color: #4b2f99; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #faf9f6; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: #fbfaf7; }
table.t td.num, table.t th.num { text-align: right; }
.t a.strong { font-weight: 600; text-decoration: none; color: var(--ink); }
.t a.strong:hover { color: var(--accent); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eeece6; color: #4b4f4c; white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: #2d5a99; }
.badge.purple { background: #f0eafd; color: #5a3aa8; }
.chip { display: inline-block; padding: 1px 8px; margin: 1px 2px 1px 0; border-radius: 6px; background: #f0eee8; font-size: 12px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--accent-soft); border-color: #bcdccf; }
.alert-error { background: var(--danger-soft); border-color: #efc4c0; color: #7d1a14; }
.alert-info { background: var(--info-soft); border-color: #c8d7ee; }
.alert-warn { background: var(--warn-soft); border-color: #f1d3a4; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters > * { width: auto; }
.filters input[type=search] { min-width: 220px; }
.bulk { display: none; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: #fbf8ee; border-bottom: 1px solid var(--line); }
.bulk.show { display: flex; }
.bulk select { width: auto; }

/* Pager */
.pager { display: flex; gap: 4px; padding: 14px; justify-content: center; }
.pager a, .pager span { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; }
.pager span { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Editor */
.editor-wrap { border: 1px solid #d4d0c5; border-radius: 8px; background: #fff; }
.editor-wrap .ql-toolbar { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 8px 8px 0 0; }
.editor-wrap .ql-container { border: 0 !important; font: inherit; font-size: 15px; }
.editor-wrap .ql-editor { min-height: 260px; }
.editor-wrap .ql-editor a[href$="#sc-btn"] { display: inline-block; background: var(--accent); color: #fff; padding: 6px 16px; border-radius: 6px; text-decoration: none; }
.editor-tools { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border-top: 1px solid var(--line); background: #faf9f6; border-radius: 0 0 8px 8px; }
textarea.html-src { font-family: ui-monospace, Menlo, monospace; font-size: 13px; min-height: 260px; border: 0; border-radius: 0; }

/* AI panel */
.ai-box { background: #f8f5ff; border: 1px solid #e2d8fa; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.ai-box h3 { color: #4b2f99; }
.subject-picks { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.subject-picks button { text-align: left; font: inherit; background: #fff; border: 1px solid #e2d8fa; border-radius: 6px; padding: 7px 10px; cursor: pointer; }
.subject-picks button:hover { border-color: #8c6be0; }

/* Sequence steps */
.step { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 14px; }
.step-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #faf9f6; border-radius: var(--radius) var(--radius) 0 0; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.step-body { padding: 16px; }
.step-head input[type=number] { width: 70px; }
.step-head input[type=time] { width: 120px; }
.lang-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.lang-tabs button { font: inherit; font-weight: 600; padding: 5px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.lang-tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.timeline { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.timeline .dot { padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12.5px; }

/* Embed code */
pre.code { background: #1d2320; color: #d8e6df; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; max-height: 320px; }
.preview-frame { width: 100%; border: 1px dashed #cfcabd; border-radius: 8px; background: #fff; min-height: 420px; }

/* Bare pages */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.bare-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: var(--shadow); }
.bare-box.wide-box { max-width: 640px; }
.bare-box h3 { margin: 10px 0 0; }
ol.steps li { margin-bottom: 6px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .side.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: block; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .cols, .grid2, .grid3 { grid-template-columns: 1fr; }
  .filters input[type=search] { min-width: 0; width: 100%; }
}
