/* Outreach Mailer — one stylesheet, no framework.
   The whole UI is a dozen screens for one or two operators; a CSS framework would be more
   bytes than the app. Colours are defined once as custom properties and the palette is
   deliberately quiet: this is a tool for reading lists and checking numbers before an
   irreversible action, not a marketing page. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --ink: #1b1f24;
    --ink-soft: #5a6472;
    --ink-faint: #8b95a3;
    --line: #dfe3e8;
    --line-strong: #c3cad3;

    --accent: #1f6f5c;
    --accent-dark: #17594a;
    --accent-wash: #e8f2ef;

    --good: #1f6f5c;
    --good-wash: #e8f2ef;
    --warn: #8a6116;
    --warn-wash: #fdf3e0;
    --bad: #a32b2b;
    --bad-wash: #fbeceb;

    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

a { color: var(--accent); }

/* ---- Chrome: left sidebar + content ------------------------------------------------- */

.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.content { padding: 24px; max-width: 1180px; min-width: 0; }

/* One column on narrow screens: the sidebar stacks above the content rather than becoming a
   drawer. This is a desk tool for one or two operators; a hamburger would be ceremony. */
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .content { padding: 16px; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    padding: 0 6px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 14px;
}

.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.is-active { background: var(--accent-wash); color: var(--accent-dark); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }

.footer { padding: 20px 0 8px; color: var(--ink-faint); font-size: 13px; }

/* ---- Sidebar calendar --------------------------------------------------------------- */

.side-cal { border-top: 1px solid var(--line); padding-top: 12px; }

.side-cal-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0 4px; }
.side-cal-head a { color: var(--ink); text-decoration: none; }
.side-cal-head a:hover { color: var(--accent); }

.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }

.mini-dow {
    text-align: center;
    font-size: 10px;
    color: var(--ink-faint);
    padding-bottom: 3px;
    font-weight: 600;
}

.mini-day {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    font-size: 11.5px;
    border-radius: 5px;
    color: var(--ink);
    text-decoration: none;
}

.mini-day:hover { background: var(--bg); }
.mini-day.is-out { color: var(--ink-faint); opacity: .5; }
.mini-day.is-today { background: var(--accent); color: #fff; font-weight: 700; }

/* A dot under a day that carries campaign work. Kept to a dot rather than a fill so "today"
   stays legible when it is also a milestone. */
.mini-day.has-event::after,
.mini-day.has-stop::after {
    content: "";
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

.mini-day.has-stop::after { background: var(--bad); }
.mini-day.is-today.has-event::after, .mini-day.is-today.has-stop::after { background: #fff; }

/* ---- Sidebar hard stop -------------------------------------------------------------- */

.side-stop {
    background: var(--bad-wash);
    border: 1px solid #f0cfcd;
    border-radius: var(--radius);
    padding: 9px 10px;
}

.side-stop-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bad);
}

.side-stop-title { font-size: 12.5px; font-weight: 600; margin-top: 2px; line-height: 1.35; }
.side-stop-when { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }

/* ---- Sidebar tickler ---------------------------------------------------------------- */

.side-tickler { border-top: 1px solid var(--line); padding-top: 12px; }

.side-tickler-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    padding: 0 4px;
}

.tickler-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.tickler-item {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    padding: 5px 4px;
    border-radius: 5px;
    font-size: 12.5px;
    line-height: 1.35;
}

.tickler-item:hover { background: var(--bg); }

.tickler-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: var(--ink-faint); }
.track-foundation { background: #6b7f99; }
.track-campaign { background: var(--accent); }
.track-relationship { background: #8a6116; }
.track-gate { background: var(--bad); }

.tickler-body { display: flex; flex-direction: column; min-width: 0; }
.tickler-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tickler-when { font-size: 11px; color: var(--ink-faint); }

.tickler-item.is-overdue .tickler-when { color: var(--bad); font-weight: 600; }
.tickler-item.is-stop .tickler-title { font-weight: 650; }

/* ---- Full calendar page -------------------------------------------------------------- */

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.cal-dow { background: var(--bg); padding: 7px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); text-align: center; }

.cal-cell { background: var(--surface); min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.is-out { background: #fafbfc; }
.cal-cell.is-today { background: var(--accent-wash); }

.cal-daynum { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.cal-cell.is-today .cal-daynum { color: var(--accent-dark); }
.cal-cell.is-out .cal-daynum { color: var(--ink-faint); opacity: .6; }

.cal-chip {
    font-size: 11px;
    line-height: 1.3;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--accent-wash);
    color: var(--accent-dark);
    border-left: 3px solid var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    display: block;
}

.cal-chip.is-stop { background: var(--bad-wash); color: var(--bad); border-left-color: var(--bad); font-weight: 600; }
.cal-chip.is-done { opacity: .5; text-decoration: line-through; }

@media (max-width: 700px) {
    .cal-cell { min-height: 62px; }
    .cal-chip { display: none; }
}

/* ---- Type -------------------------------------------------------------------------- */

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.subtitle { color: var(--ink-soft); margin: 0; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---- Cards & grids ----------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-narrow { width: 100%; max-width: 420px; margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---- Stats ------------------------------------------------------------------------- */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.stat-good .stat-value { color: var(--good); }
.stat-bad .stat-value { color: var(--bad); }
.stat-warn .stat-value { color: var(--warn); }

/* ---- Tables ------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-faint);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 28px; text-align: center; color: var(--ink-faint); }

/* ---- Badges ------------------------------------------------------------------------ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-good { background: var(--good-wash); color: var(--good); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-bad { background: var(--bad-wash); color: var(--bad); }
.badge-quiet { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }

.tag {
    display: inline-block;
    padding: 1px 7px;
    margin: 1px 2px 1px 0;
    border-radius: 4px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink-soft);
}

/* ---- Banners ----------------------------------------------------------------------- */

.banner {
    padding: 11px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}

.banner-good { background: var(--good-wash); color: var(--accent-dark); border-color: #c5e0d8; }
.banner-bad { background: var(--bad-wash); color: var(--bad); border-color: #f0cfcd; }
.banner-warn { background: var(--warn-wash); color: var(--warn); border-color: #ecd9ae; }

.banner ul { margin: 6px 0 0; padding-left: 20px; }

/* ---- Forms ------------------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field .hint { color: var(--ink-faint); font-size: 12.5px; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---- Collapsible panels --------------------------------------------------------------
   Built on <details>/<summary> rather than JavaScript, so they open with the keyboard, are
   announced correctly by screen readers, and still work if a script fails to load. JS only
   remembers which ones you left open. */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    cursor: pointer;
    user-select: none;

    /* Both are needed to drop the default disclosure triangle across browsers. */
    list-style: none;
}

.panel-head::-webkit-details-marker { display: none; }
.panel-head:hover { background: var(--bg); }
.panel-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.panel-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.panel-meta { margin-left: auto; color: var(--ink-faint); font-size: 13px; text-align: right; }

.panel-chev {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    color: var(--ink-faint);
    transition: transform .15s ease;
}

.panel[open] .panel-chev { transform: rotate(90deg); }
.panel[open] .panel-head { border-bottom: 1px solid var(--line); }

.panel-body { padding: 16px 18px 18px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.panel-tools {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 12px;
}

/* Show/hide control for password and secret inputs. The button sits inside the field's right
   edge, so the input keeps its full width and the control never reflows the form. */
.pw-field { position: relative; display: block; }
.pw-field > input { padding-right: 40px; }

.pw-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
}

.pw-toggle:hover { background: var(--bg); color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.pw-toggle svg { width: 17px; height: 17px; display: block; }

/* Two icons live in the button; CSS swaps which one shows, so no DOM churn on click. */
.pw-toggle .icon-hide { display: none; }
.pw-toggle.is-shown .icon-show { display: none; }
.pw-toggle.is-shown .icon-hide { display: block; }
.pw-toggle.is-shown { color: var(--accent); }
.pw-toggle:disabled { opacity: .4; cursor: wait; }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.check input { margin-top: 3px; }
.check label { font-weight: 400; margin: 0; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 160px; }
.inline-form { display: inline; }

.field-error, .validation-summary-errors { color: var(--bad); font-size: 13px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

/* ---- Buttons ----------------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 550;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-quiet:hover { background: var(--bg); color: var(--ink); }

.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Progress ---------------------------------------------------------------------- */

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .4s ease; }

/* ---- Email preview ----------------------------------------------------------------- */

.preview-frame {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 24px;
    max-width: 640px;
}

.preview-meta {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 13px;
}

.preview-meta dt { color: var(--ink-faint); font-size: 12px; }
.preview-meta dd { margin: 0 0 8px; }

pre.plain {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 13px;
    margin: 0;
}

/* ---- Pagination -------------------------------------------------------------------- */

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; font-size: 14px; }

/* ---- Misc -------------------------------------------------------------------------- */

.qr { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: #fff; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; }
.codes code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* Fixed-height audience picker. One tag per sending day means this list only grows —
   without a cap it pushes Save and the rest of the sidebar below the fold. */
.scroll-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--surface);
}
.scroll-list .check:last-child { margin-bottom: 0; }
.tag-filter { margin-bottom: 8px; }
