:root {
  --bg: #f5f6f8; --panel: #ffffff; --line: #e4e7ec; --text: #1f2430; --muted: #6b7280;
  --brand: #2563eb; --brand-dark: #1d4ed8; --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
  --sidebar: #111827; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 15px; margin: 0 0 12px; } h1 + .muted { margin-top: 2px; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.sidebar { width: 220px; background: var(--sidebar); color: #cbd5e1; padding: 20px 14px; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; padding: 4px 8px 20px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(37,99,235,.25); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #cbd5e1; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; }
.sidebar-foot .btn-ghost { color: #cbd5e1; }

.main { flex: 1; padding: 24px 28px 48px; min-width: 0; }
.main-public { max-width: 560px; margin: 60px auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-narrow { max-width: 420px; margin: 0 auto; }
.center { text-align: center; } .num { text-align: right; } .pad { padding: 12px 16px; } .mt { margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .error-text { color: var(--danger); }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: inherit; box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat-n { font-size: 26px; font-weight: 700; } .stat-l { color: var(--muted); font-size: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table .check { width: 32px; }
.table.small td { font-size: 12px; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.actions-inline { white-space: nowrap; } .actions-inline form { display: inline-block; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef0f3; color: #374151; }
.badge-subscribed, .badge-sent { background: #dcfce7; color: #166534; }
.badge-unsubscribed, .badge-cancelled { background: #f3f4f6; color: #4b5563; }
.badge-bounced, .badge-failed { background: #fee2e2; color: #991b1b; }
.badge-draft { background: #e0e7ff; color: #3730a3; }
.badge-sending, .badge-queued { background: #fef3c7; color: #92400e; }
.chip { display: inline-block; background: #eef0f3; border-radius: 999px; padding: 1px 8px; font-size: 11px; margin: 1px 2px 1px 0; }
.chip-blue { background: #dbeafe; color: #1e40af; font-weight: 600; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; margin-right: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--brand); }
input[type=file] { font: inherit; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.row-form input, .row-form select { width: auto; flex: 1; min-width: 140px; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; } .filters input[type=search] { flex: 1; min-width: 200px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; } .btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; } .btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .6; cursor: default; }

.flashes { margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.bulk-bar { display: flex; gap: 8px; align-items: center; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.bulk-bar select, .bulk-bar input { width: auto; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }

.progress-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); transition: width .4s; }

/* ---------------- composer ---------------- */
.composer-page .main { padding-bottom: 24px; }
.composer-head .title-input { font-size: 20px; font-weight: 700; border: 1px solid transparent; padding: 4px 6px; margin-left: -6px; width: min(520px, 90vw); background: transparent; }
.composer-head .title-input:hover, .composer-head .title-input:focus { border-color: #d0d5dd; background: #fff; }
.test-box { display: flex; gap: 6px; } .test-box input { width: 220px; }
.save-state { min-width: 90px; text-align: right; }
.composer { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.composer-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.composer-main { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: calc(100vh - 140px); }
.toolbar { display: flex; flex-wrap: wrap; gap: 3px; padding: 8px; border-bottom: 1px solid var(--line); align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; border-radius: var(--radius) var(--radius) 0 0; }
.toolbar button { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; min-width: 30px; }
.toolbar button:hover { background: #f3f4f6; border-color: #e5e7eb; }
.toolbar button.toggle.active { background: #e0e7ff; color: #3730a3; }
.toolbar select { width: auto; padding: 4px 6px; font-size: 13px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toolbar .grow { flex: 1; }
.editor-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); flex: 1; min-height: 0; }
.editor-split.no-preview { grid-template-columns: minmax(0, 1fr); }
.editor-split.no-preview .preview-pane { display: none; }
.editor-pane { padding: 20px; background: #f3f4f6; overflow: auto; border-right: 1px solid var(--line); }
.editor-paper { background: #fff; max-width: 600px; margin: 0 auto; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); min-height: 400px; }
.editor { padding: 32px; min-height: 400px; outline: none; font-size: 16px; line-height: 1.6; color: #1f2937; }
.editor:empty::before { content: "Scrie mesajul aici…"; color: #9ca3af; }
.editor p { margin: 0 0 16px; } .editor h1 { font-size: 26px; margin: 0 0 16px; } .editor h2 { font-size: 21px; margin: 24px 0 12px; } .editor h3 { font-size: 18px; margin: 20px 0 10px; }
.editor img { max-width: 100%; height: auto; } .editor a { color: #2563eb; }
.editor blockquote { margin: 0 0 16px; padding: 8px 16px; border-left: 4px solid #d1d5db; color: #4b5563; }
.editor hr { border: 0; border-top: 1px solid #e5e7eb; margin: 24px 0; }
.editor .hf-btn { display: inline-block; background: #2563eb; color: #fff; text-decoration: none; padding: 12px 22px; border-radius: 6px; font-weight: 600; }
.source { width: 100%; min-height: 460px; border: 0; padding: 20px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; border-radius: 8px; }
.preview-pane { display: flex; flex-direction: column; background: #f3f4f6; min-height: 0; }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fff; gap: 12px; }
.preview-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-modes button { font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid #d0d5dd; background: #fff; cursor: pointer; }
.preview-modes button:first-child { border-radius: 6px 0 0 6px; } .preview-modes button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.preview-modes button.active { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.preview-warn { background: #fff7ed; color: #9a3412; padding: 6px 14px; border-bottom: 1px solid #fed7aa; }
#preview { flex: 1; width: 100%; border: 0; min-height: 500px; background: #f3f4f6; transition: width .2s; align-self: center; }
#preview.mobile { width: 375px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 20; max-width: 420px; }
.toast.error { background: var(--danger); }
@media (max-width: 1100px) { .composer { grid-template-columns: 1fr; } .composer-side { position: static; max-height: none; } .editor-split { grid-template-columns: 1fr; } .preview-pane { border-top: 1px solid var(--line); } }
@media (max-width: 720px) { body { flex-direction: column; } .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px; } .sidebar nav { flex-direction: row; flex-wrap: wrap; } .brand { padding: 0 8px; } .sidebar-foot { margin-left: auto; } .main { padding: 16px; } }

/* ---------------- template-uri ---------------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; margin: 0; }
.tpl-thumb { display: block; height: 220px; overflow: hidden; background: #f3f4f6; border-bottom: 1px solid var(--line); position: relative; }
.tpl-thumb iframe { width: 640px; height: 880px; border: 0; transform: scale(0.5); transform-origin: 0 0; pointer-events: none; }
.tpl-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.tpl-body h2 { margin: 0; }
.tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }

/* ---------------- programare ---------------- */
.badge-scheduled { background: #ede9fe; color: #5b21b6; }
.scheduled-box { border-color: #c4b5fd; background: #faf5ff; }
.schedule-wrap { position: relative; }
.popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.14); padding: 14px; width: 320px; display: flex; flex-direction: column; gap: 10px; }
.popover input[type=datetime-local] { font: inherit; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 8px; width: 100%; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------------- automatizări ---------------- */
.badge-active, .badge-completed { background: #dcfce7; color: #166534; }
.badge-paused, .badge-exited { background: #f3f4f6; color: #4b5563; }
.badge-running { background: #dbeafe; color: #1e40af; }
.auto-grid { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .auto-grid { grid-template-columns: 1fr; } }

/* ---------------- flux automatizare (stil vertical, ca ActiveCampaign) ---------------- */
.flow { display: flex; flex-direction: column; align-items: center; padding: 8px 4px 16px; }
.flow-node, .flow-step, #flow-top { width: 100%; max-width: 460px; }
.flow-conn { width: 2px; height: 20px; background: #d5dbe3; margin: 0 auto; }
.flow-pill { display: inline-flex; align-items: center; gap: 8px; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 600; }
.flow-end .flow-pill { background: #f3f4f6; color: #4b5563; }
.flow-trigger { background: #eaf3ff; border: 1px solid #cadffb; border-radius: 12px; padding: 12px 14px; }
.flow-trigger .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #5b7bab; font-weight: 700; }
.flow-trigger .txt { font-weight: 600; margin-top: 2px; }
.flow-wait { display: flex; align-items: center; gap: 8px; justify-content: center; color: #6b7280; font-size: 13px; flex-wrap: wrap; }
.flow-wait input[type=number] { width: 62px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.flow-wait select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.flow-card { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.flow-card.sel { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.flow-ic { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: 0 0 auto; }
.flow-email .flow-ic { background: #e0edff; color: #1d4ed8; }
.flow-tag .flow-ic { background: #fef3c7; color: #92400e; }
.flow-list .flow-ic { background: #dcfce7; color: #166534; }
.flow-unlist .flow-ic { background: #fee2e2; color: #991b1b; }
.flow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.flow-title { font-weight: 600; font-size: 13px; }
.flow-main select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.flow-sub { color: #6b7280; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-acts { display: flex; gap: 2px; flex: 0 0 auto; }
.flow-add { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------------- formulare ---------------- */
#embed-iframe, #embed-html { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f9fafb; cursor: copy; }
.step-body textarea { font: inherit; }

.badge-delivered { background: #dcfce7; color: #166534; } .badge-opened, .badge-clicked { background: #dbeafe; color: #1e40af; }

/* ---------------- SMS ---------------- */
.badge-sms { background: #ecfccb; color: #3f6212; }
.sms-main { padding: 20px; display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 24px; }
.sms-editor { display: flex; flex-direction: column; gap: 8px; }
.sms-label { font-weight: 600; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.sms-label code { background: #eef0f3; border-radius: 4px; padding: 1px 5px; cursor: pointer; font-size: 12px; }
.sms-body { width: 100%; box-sizing: border-box; min-height: 220px; font: 15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; padding: 14px; border: 1px solid #d0d5dd; border-radius: 10px; resize: vertical; }
.sms-meta { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.phone-frame { background: #111827; border-radius: 28px; padding: 14px 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.phone-screen { background: #f3f4f6; border-radius: 18px; min-height: 380px; padding: 16px 12px; }
.bubble { background: #e5e7eb; color: #111827; border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; max-width: 85%; }
@media (max-width: 900px) { .sms-main { grid-template-columns: 1fr; } .sms-phone { display: none; } }

/* ---------------- WhatsApp ---------------- */
.badge-whatsapp { background: #dcf8c6; color: #075e54; }
.wa-tpl-row { display: flex; gap: 8px; align-items: center; }
.wa-template { flex: 1; box-sizing: border-box; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 10px; font: 14px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; }
.wa-lang { padding: 10px 8px; border: 1px solid #d0d5dd; border-radius: 10px; }
.wa-vars { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.wa-vars code { background: #eef0f3; border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.phone-wa .phone-screen { background: #e5ddd5; }
.bubble-wa { background: #dcf8c6; color: #111b21; border-radius: 8px 8px 8px 2px; margin-left: auto; box-shadow: 0 1px 1px rgba(0,0,0,.1); }

/* ---------------- confirmare în pagină (uiconfirm, merge și în iframe) ---------------- */
.uiconfirm-ov { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.uiconfirm-box { background: #fff; border-radius: 12px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.uiconfirm-box p { margin: 0 0 16px; font-size: 15px; line-height: 1.5; color: #1f2937; }
.uiconfirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
