/* Herald company console — Brevo-like SaaS layout:
   light sidebar, cool grey canvas, white cards, green primary. */

:root {
  --canvas: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7eaef;
  --sidebar: #ffffff;
  --text: #1b2733;
  --text-dim: #5a6a7a;
  --text-faint: #8a99a8;
  --border: #e3e8ee;
  --border-soft: #eef1f5;
  --accent: #0b996e;
  --accent-hover: #0a8862;
  --accent-soft: #e6f6f0;
  --accent-text: #ffffff;
  --ok: #0b7a57;
  --ok-bg: #e6f6f0;
  --warn: #8a5a00;
  --warn-bg: #fff6e5;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --info: #1a6fb5;
  --info-bg: #e8f2fb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(27,39,51,.05);
  --shadow-lift: 0 2px 8px rgba(27,39,51,.07);
  --sidebar-w: 244px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #12161b;
    --surface: #1a1f26;
    --surface-2: #22282f;
    --surface-3: #2c333b;
    --sidebar: #171b21;
    --text: #e7ebef;
    --text-dim: #98a5b3;
    --text-faint: #75818e;
    --border: #2a3138;
    --border-soft: #232a31;
    --accent: #21b98a;
    --accent-hover: #2ac795;
    --accent-soft: #122c24;
    --accent-text: #04160f;
    --ok: #58cfa2;
    --ok-bg: #12291f;
    --warn: #dfae5f;
    --warn-bg: #2b2413;
    --danger: #ef8478;
    --danger-bg: #2c1714;
    --info: #6bb0e8;
    --info-bg: #13232f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lift: 0 2px 10px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 14px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.shell { display: flex; min-height: 100vh; }

/* ---- sidebar ---------------------------------------------------------- */
.side {
  width: var(--sidebar-w); flex: none; background: var(--sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 12px 14px; position: sticky; top: 0; height: 100vh;
}
.side__brand {
  display: flex; align-items: center; gap: 9px; padding: 0 8px 20px;
  font-size: 16px; font-weight: 700; letter-spacing: -.02em;
}
.side__logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  color: var(--accent-text); display: grid; place-items: center; font-size: 14px; flex: none;
}
.side__brand small { display: block; font-size: 10.5px; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .09em; margin-top: 1px; }
.side__group { font-size: 10.5px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .09em; padding: 14px 10px 6px; }
.side__nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.side__nav button {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  border: 0; background: none; color: var(--text-dim); cursor: pointer;
  padding: 9px 10px; border-radius: 7px; font: inherit; font-weight: 550;
}
.side__nav button .ico { font-size: 15px; width: 18px; text-align: center; flex: none; opacity: .85; }
.side__nav button:hover { background: var(--surface-2); color: var(--text); }
.side__nav button[aria-current="page"] {
  background: var(--accent-soft); color: var(--ok); font-weight: 650;
}
.side__foot {
  border-top: 1px solid var(--border-soft); padding: 12px 10px 0; margin-top: 10px;
  font-size: 11.5px; color: var(--text-faint);
}
.side__foot strong { display: block; color: var(--text-dim); font-size: 12.5px; font-weight: 600; }
.side__foot code { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; word-break: break-all; }

/* ---- main ------------------------------------------------------------- */
.main { flex: 1; min-width: 0; padding: 26px 32px 64px; max-width: 1020px; }
.page { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page__main { flex: 1; min-width: 0; }
h1 { font-size: 22px; letter-spacing: -.025em; margin: 0 0 3px; font-weight: 700; }
.lead { color: var(--text-dim); margin: 0; font-size: 14px; }
h2 { font-size: 15px; margin: 0 0 3px; font-weight: 650; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); margin: 26px 0 10px; font-weight: 700; }
p { margin: 0 0 10px; }
.dim { color: var(--text-dim); } .small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; padding: 12px;
    border-right: 0; border-bottom: 1px solid var(--border); }
  .side__nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .side__nav button { white-space: nowrap; }
  .side__group, .side__foot { display: none; }
  .main { padding: 18px 16px 48px; }
}

/* ---- cards & metrics -------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card--pad0 { padding: 0; overflow: hidden; }
.card__head { padding: 15px 18px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px; }
.card__head h2 { flex: 1; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 14px; }

.metric { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.metric__label { font-size: 11.5px; font-weight: 650; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .06em; }
.metric__value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.metric__hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---- controls --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-text); font: inherit;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--wide { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }

label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 14px 0 6px; font-weight: 600; }
label:first-child { margin-top: 0; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; border-radius: 6px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 220px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.6; }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .two { grid-template-columns: 1fr; } }

/* ---- badges, notes ---------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 4px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--mute { background: var(--surface-2); color: var(--text-dim); }

.note { border-radius: 6px; padding: 12px 14px; font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent; border-left-width: 3px; }
.note--ok { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); }
.note--warn { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.note--danger { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.note--info { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }
.note strong { display: block; margin-bottom: 2px; }
.note code, .mono-inline { font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; }

/* ---- tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); font-weight: 700; padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td strong { font-weight: 620; }

/* ---- cap meter -------------------------------------------------------- */
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 7px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter--full span { background: var(--danger); }
.meter--near span { background: var(--warn); }

/* ---- composer --------------------------------------------------------- */
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px;
  border-radius: 7px; width: fit-content; margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 5px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.preview {
  border: 1px solid var(--border); border-radius: 6px; padding: 18px 20px;
  background: var(--surface); min-height: 220px; font-size: 15px; line-height: 1.65;
}
.preview h2 { font-size: 19px; margin: 20px 0 8px; font-weight: 680; }
.preview h3 { font-size: 16px; margin: 18px 0 6px; text-transform: none; letter-spacing: 0; color: var(--text); }
.preview p { margin: 0 0 12px; }
.preview ul, .preview ol { margin: 0 0 12px; padding-left: 22px; }
.preview a { color: var(--accent); }
.preview blockquote { margin: 0 0 12px; padding-left: 13px; border-left: 3px solid var(--surface-3); color: var(--text-dim); }
.preview img { max-width: 100%; border-radius: 6px; display: block; margin-bottom: 12px; }
.preview pre { background: var(--surface-2); padding: 12px; border-radius: 6px; overflow-x: auto; }
.preview code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.md-blocked { display: inline-block; font-size: 12px; color: var(--warn);
  background: var(--warn-bg); border-radius: 4px; padding: 2px 6px; }

.attachlist { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.attachrow { display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px; font-size: 13px; }
.attachrow__main { flex: 1; min-width: 0; }
.attachrow__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachrow__meta { font-size: 11.5px; color: var(--text-faint); }
.dropzone { border: 1.5px dashed var(--border); border-radius: 7px; padding: 20px;
  text-align: center; color: var(--text-dim); font-size: 13px; cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); color: var(--ok); background: var(--accent-soft); }

.empty { text-align: center; color: var(--text-faint); padding: 44px 20px; font-size: 13.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 13px; }
.kv dt { color: var(--text-faint); } .kv dd { margin: 0; font-weight: 550; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: 480px;
  padding: 13px 16px; border-radius: 7px; font-size: 13.5px; font-weight: 550;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-lift);
  opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .18s, transform .18s; }
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); color: #fff; }
.toast--ok { background: var(--accent); color: #fff; }
.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); } }
