/* MailForge — Brevo-style: dark navy sidebar, green primary, light content. */
:root {
    --green: #0b996e; --green-dark: #08805c; --green-soft: #e3f7ee; --lime: #c4f2c9;
    --side: #0b1f2f; --side-ink: #b7c7d3; --side-active: #163a52;
    --ink: #1a2b3c; --text: #354a5e; --muted: #7a8a9a; --link: #0b7a5a;
    --bg: #f4f6f8; --panel: #fff; --line: #e1e7ec; --line-soft: #edf1f4;
    --ok: #0b996e; --ok-bg: #e3f7ee; --warn: #a3720a; --warn-bg: #fbf0d3;
    --bad: #c62828; --bad-bg: #fde8e8; --info: #1f5fbf; --info-bg: #e6eefb;
    --radius: 10px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 16px rgba(16,32,48,.04);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.5 "Inter", -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { background: #eef2f5; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .inline { display: inline; }
.hidden { display: none !important; }

/* --------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex-shrink: 0; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 60; }
.side-brand { padding: 18px 18px 10px; display: flex; align-items: center; justify-content: space-between; }
.side-brand a { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.side-brand a:hover { text-decoration: none; }
.side-brand img { max-height: 34px; max-width: 170px; }
.logo-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--green); display: inline-block;
            box-shadow: inset 0 0 0 5px var(--side), inset 0 0 0 8px var(--lime); }
.side-close { display: none; background: none; border: 0; color: var(--side-ink); font-size: 18px; cursor: pointer; }
.side-nav { padding: 6px 12px 12px; flex: 1; }
.side-group { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: #6d8497; margin: 16px 10px 5px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink);
              font-weight: 500; font-size: 13.5px; }
.side-nav a svg { width: 17px; height: 17px; opacity: .8; flex-shrink: 0; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--side-active); color: #fff; }
.side-nav a.active svg { color: var(--lime); opacity: 1; }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 10px 12px; display: flex; align-items: center; gap: 6px; }
.side-foot a { display: flex; align-items: center; gap: 9px; color: var(--side-ink); padding: 7px 10px; border-radius: 8px; font-size: 13px; min-width: 0; }
.side-foot a:first-child { flex: 1; } .side-foot a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side-foot svg { width: 17px; height: 17px; flex-shrink: 0; }
.side-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center; gap: 14px;
          padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.burger { display: none; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 4px; }
.burger svg { width: 22px; height: 22px; }
.topsearch { flex: 1; max-width: 480px; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line);
             border-radius: 8px; padding: 0 12px; height: 36px; color: var(--muted); }
.topsearch svg { width: 16px; height: 16px; }
.topsearch input { border: 0; background: none; flex: 1; font: inherit; outline: none; color: var(--ink); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; font-weight: 500; }
h1 { font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 600; color: var(--ink); }
h3 { font-size: 14px; font-weight: 600; color: var(--ink); }
.headright { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --------------------------------------------------------------- cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile-l { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.tile-v { font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 4px; letter-spacing: -.02em; }
.tile-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-i { font-size: 36px; margin-bottom: 8px; } .empty h3 { color: var(--ink); margin-bottom: 4px; } .empty p { margin-bottom: 14px; }

/* --------------------------------------------------------------- forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=tel],
input[type=datetime-local], input[type=time], input[type=search], select, textarea {
    width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink);
    background: #fff; outline: none; transition: border-color .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,153,110,.14); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; accent-color: var(--green); vertical-align: -2px; }
.field { margin-bottom: 14px; }
.field .hint, .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; color: var(--text); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar input[type=search] { min-width: 240px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
       background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
       text-decoration: none !important; transition: background .12s, border-color .12s; }
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: #f6f8fa; border-color: #cfd8e0; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn.dark { background: var(--side); border-color: var(--side); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f2c4c4; } .btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: none; } .btn.ghost:hover { background: #eef2f5; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
     padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line-soft); }
.pager .muted { flex: 1; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef2f5; color: var(--text); text-transform: capitalize; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }
.flash { padding: 11px 14px; border-radius: 8px; background: var(--ok-bg); color: #0a5c43; margin-bottom: 16px; border: 1px solid #bfe9d5; }
.flash.bad { background: var(--bad-bg); color: #8a1f1f; border-color: #f2c4c4; }
.flash.warn { background: var(--warn-bg); color: #6b4a06; border-color: #f0dfa8; }
.flash.info { background: var(--info-bg); color: #163f7a; border-color: #c6d6f3; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); display: inline-flex;
          align-items: center; justify-content: center; font-weight: 700; font-size: 12px; margin-right: 8px; vertical-align: middle; }
.bar { height: 6px; background: #eef2f5; border-radius: 3px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--green); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13.5px; } .kv dt { color: var(--muted); font-weight: 500; } .kv dd { color: var(--ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; } .tabs a.on { color: var(--green-dark); border-color: var(--green); }
.steps { display: flex; gap: 0; margin-bottom: 22px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.steps a { flex: 1; padding: 12px 16px; display: flex; gap: 10px; align-items: center; color: var(--muted); font-weight: 600; border-right: 1px solid var(--line); }
.steps a:last-child { border-right: 0; } .steps a:hover { text-decoration: none; background: #fafbfc; }
.steps a .n { width: 24px; height: 24px; border-radius: 50%; background: #eef2f5; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.steps a.on { color: var(--ink); background: var(--green-soft); } .steps a.on .n { background: var(--green); color: #fff; }
.steps a.done .n { background: var(--green); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 6px; background: #eef2f5; font-size: 12.5px; margin: 2px 4px 2px 0; }
.chip b { font-weight: 600; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); background: #fafbfc; }
.dropzone.over { border-color: var(--green); background: var(--green-soft); }
.modal-bg { position: fixed; inset: 0; background: rgba(10,25,40,.45); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.on { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .card-h { position: sticky; top: 0; background: #fff; }
.progress { height: 10px; background: #eef2f5; border-radius: 5px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--green); transition: width .3s; }
.sparkline { height: 140px; width: 100%; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.two { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.codebox { background: #0b1f2f; color: #d9e6ef; padding: 14px 16px; border-radius: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; overflow-x: auto; white-space: pre; line-height: 1.55; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c3ccd4; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
details summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.actions-cell { white-space: nowrap; } .actions-cell form { display: inline; }
.preview-frame { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 400px; }
.rule-row { display: grid; grid-template-columns: 1.3fr 1fr 1.4fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.tag { font-size: 11px; background: var(--green-soft); color: var(--green-dark); padding: 2px 7px; border-radius: 4px; font-weight: 600; }

/* ----------------------------------------------------------------- auth */
.auth-body { background: linear-gradient(135deg, #0b1f2f 0 50%, #f4f6f8 50% 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 420px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 20px; margin: 18px 0 16px; }
.auth-card .brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; color: var(--ink); }
.auth-card .brand .logo-dot { box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 8px var(--lime); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.auth-foot { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
    .grid.c3, .grid.c4, .grid.c6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .two { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .18s; height: 100vh; }
    body.nav-open .side { transform: none; }
    body.nav-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
    .side-close { display: block; }
    .burger { display: block; }
    .content { padding: 16px 16px 60px; }
    .grid.c2, .grid.c3, .grid.c4, .grid.c6 { grid-template-columns: 1fr; }
    .topsearch { display: none; }
    .rule-row { grid-template-columns: 1fr; }
    .steps { flex-direction: column; } .steps a { border-right: 0; border-bottom: 1px solid var(--line); }
    .kv { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------- workflow builder */
.fl-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.fl-canvas { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; min-height: 400px; display: flex; flex-direction: column; align-items: center; }
.fl-step { display: flex; align-items: center; gap: 12px; width: 320px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.fl-step:hover { border-color: #9db7c8; } .fl-step.sel { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,153,110,.15); }
.fl-step.trigger { background: var(--side); color: #fff; border-color: var(--side); } .fl-step.trigger .fl-sum { color: #b7c7d3; }
.fl-ic { font-size: 20px; width: 28px; text-align: center; } .fl-body { flex: 1; min-width: 0; } .fl-body b { display: block; font-size: 13.5px; }
.fl-sum { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; } .fl-del:hover { color: var(--bad); }
.fl-plus { display: flex; flex-direction: column; align-items: center; position: relative; padding: 4px 0; }
.fl-plus::before, .fl-plus::after { content: ""; width: 2px; height: 12px; background: #c6d3dc; display: block; }
.fl-plus button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #c6d3dc; background: #fff; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.fl-plus button:hover { background: var(--green); border-color: var(--green); color: #fff; }
.fl-menu { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 20; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 6px; width: 320px; }
.fl-menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
.fl-menu button:hover { background: var(--green-soft); }
.fl-branches { display: flex; gap: 20px; align-items: flex-start; justify-content: center; margin: 4px 0; }
.fl-branch { display: flex; flex-direction: column; align-items: center; border-left: 1px dashed #c6d3dc; border-right: 1px dashed #c6d3dc; padding: 0 10px; border-radius: 8px; min-width: 200px; }
.fl-branch .fl-step { width: 260px; }
.fl-bl { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 10px; border-radius: 999px; margin-top: 8px; }
.fl-bl.yes { background: var(--ok-bg); color: var(--ok); } .fl-bl.no { background: var(--bad-bg); color: var(--bad); }
.fl-end { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; margin-top: 4px; }
.fl-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: sticky; top: 72px; }
.fl-panel h3 { margin-bottom: 10px; } .fl-panel .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 900px) { .fl-wrap { grid-template-columns: 1fr; } .fl-panel { position: static; } }
