/* Outreach admin – simple, accessible styles (WCAG 2.2 AA contrast). */

:root {
    --text: #1b1b1f;
    --text-muted: #4a4f57;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #c9ced6;
    --primary: #0b57d0;
    --primary-dark: #0842a0;
    --focus: #0b57d0;
    --ok-bg: #e3f3e7; --ok-text: #0d5223;
    --warn-bg: #fdf3d8; --warn-text: #6b4100;
    --err-bg: #fbe5e3; --err-text: #9b1111;
    --info-bg: #e5eefc; --info-text: #0a3f94;
    --muted-bg: #eceef1; --muted-text: #3c4043;
    --radius: 6px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 100%;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--surface);
    padding: .5rem 1rem;
    z-index: 10;
    border: 2px solid var(--primary);
}
.skip-link:focus { top: .5rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.container-narrow { max-width: 640px; padding-top: 3rem; }
main:focus { outline: none; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding-top: .5rem; padding-bottom: .5rem; }
.brand { margin: 0; font-weight: 700; font-size: 1.15rem; }
.brand a { color: var(--text); text-decoration: none; }
.nav { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; }
.nav a { display: block; padding: .4rem .7rem; border-radius: var(--radius); text-decoration: none; color: var(--text); }
.nav a:hover { background: var(--muted-bg); }
.nav a[aria-current="page"] { background: var(--info-bg); color: var(--info-text); font-weight: 600; }
.logout { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.user { color: var(--text-muted); font-size: .9rem; }

h1 { font-size: 1.6rem; margin: 1rem 0; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.card > h2:first-child { margin-top: 0; }

/* Forms */
.field { margin-bottom: 1rem; }
label, legend { display: block; font-weight: 600; margin-bottom: .25rem; }
fieldset { border: 0; padding: 0; margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="time"], input[type="date"], input[type="search"], select, textarea {
    width: 100%;
    max-width: 36rem;
    padding: .5rem .6rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #767b84;
    border-radius: var(--radius);
}
textarea { max-width: 100%; }
.input-short { max-width: 10rem; }
.input-mono, pre, code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9rem; }
[aria-invalid="true"] { border-color: var(--err-text); border-width: 2px; }
.help { margin: .25rem 0 0; color: var(--text-muted); font-size: .9rem; }
.field-error { margin: .25rem 0 0; color: var(--err-text); font-weight: 600; }
.field-error::before { content: "⚠ "; }

.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox label { font-weight: 400; margin: 0; }
.checkbox input { width: 1.15rem; height: 1.15rem; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }

.button {
    display: inline-block;
    padding: .55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    border: 1px solid #767b84;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--muted-bg); color: var(--text); }
.button-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); color: #fff; }
.button-link { border: 0; background: none; color: var(--primary); text-decoration: underline; padding: .25rem; font-weight: 400; }
.button-link:hover { background: none; color: var(--primary-dark); }

.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.button-row form { margin: 0; }
.subheading { margin-top: 1.5rem; font-size: 1.05rem; }
.inline-form .field { margin-bottom: .5rem; }

.button-danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.button-danger:hover { background: #8c1d18; color: #fff; }
.card-danger { border-color: #b3261e; }
.table-scroll { overflow-x: auto; }
progress { width: 100%; max-width: 36rem; height: 1.25rem; display: block; margin-bottom: .5rem; }
input[type="file"] { font: inherit; }

/* Campaign sub-navigation */
.subnav { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0 0 1rem; border-bottom: 2px solid var(--border); }
.subnav a { display: block; padding: .5rem .9rem; text-decoration: none; color: var(--text); border-radius: var(--radius) var(--radius) 0 0; }
.subnav a[aria-current="page"] { background: var(--surface); border: 2px solid var(--border); border-bottom-color: var(--surface); margin-bottom: -2px; font-weight: 600; }

/* Template editor tabs */
.editor-label { font-weight: 600; margin: 0 0 .25rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: .5rem; }
.tabs [role="tab"] { font: inherit; padding: .45rem .9rem; border: 1px solid transparent; border-bottom: 0; background: none; color: var(--text); cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.tabs [role="tab"][aria-selected="true"] { border-color: var(--border); background: var(--surface); font-weight: 600; box-shadow: inset 0 -3px 0 var(--primary); }
.editor-code { min-height: 18rem; }
.insert-field { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin-top: .5rem; }
.insert-field label { margin: 0; align-self: center; }
.insert-field select { max-width: 16rem; }
.text-preview { min-height: 6rem; background: var(--surface); border: 1px solid var(--border); font-size: .95rem; }

/* Email preview: mimics the email (system font, normal size) */
.email-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: #fff; color: #222;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 14px; line-height: 1.5; overflow-x: auto; }
.email-preview a { color: #1a0dab; }

form.inline { display: inline-block; margin-left: .5rem; }
td.actions form.inline { margin: 0 .25rem .25rem 0; }
td.actions textarea { min-width: 12rem; }
.field-error-inline { color: var(--err-text); }
.button-small { padding: .2rem .6rem; font-size: .9rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.filters .field { min-width: 10rem; }
.field-actions { display: flex; gap: .5rem; }

/* Notices and badges */
.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: 1rem 0; border-left: 5px solid; }
.notice p { margin: .25rem 0; }
.notice ul { margin: .25rem 0; }
.notice-success { background: var(--ok-bg); color: var(--ok-text); }
.notice-info { background: var(--info-bg); color: var(--info-text); }
.notice-warning { background: var(--warn-bg); color: var(--warn-text); }
.notice-error { background: var(--err-bg); color: var(--err-text); }
.notice a { color: inherit; font-weight: 600; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warning { background: var(--warn-bg); color: var(--warn-text); }
.badge-error { background: var(--err-bg); color: var(--err-text); }
.badge-muted { background: var(--muted-bg); color: var(--muted-text); }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); margin-bottom: 1rem; }
caption { text-align: left; font-weight: 700; font-size: 1.1rem; padding: .25rem 0 .5rem; }
th, td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
thead th { background: var(--muted-bg); }
tbody th { font-weight: 600; }
.nowrap { white-space: nowrap; }
.table-logs td:last-child { word-break: break-word; }
.table-inbound td { overflow-wrap: anywhere; }
.table-inbound .badge { white-space: nowrap; overflow-wrap: normal; }
.table-inbound .row-unseen td:first-child { border-left: 4px solid var(--primary); }
.table-inbound form.inline { display: block; margin-top: .35rem; }
.totp-secret code { font-size: 1.25rem; letter-spacing: .08em; padding: .25rem .5rem; background: var(--muted-bg); border-radius: var(--radius); }
.classify-form {display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .35rem; }
.classify-form label { font-size: .875rem; }
.classify-form select { width: auto; }
.rate { color: var(--text-muted); font-size: .9em; white-space: nowrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.stat-tiles > div { background: var(--muted-bg); border-radius: var(--radius); padding: .75rem; }
.stat-tiles dt { font-size: .875rem; color: var(--text-muted); }
.stat-tiles dd { margin: 0; font-size: 1.6rem; font-weight: 700; }
.stat-tiles dd.rate { font-size: .9rem; font-weight: 400; }
details summary { cursor: pointer; color: var(--primary); }
pre { white-space: pre-wrap; word-break: break-word; background: var(--muted-bg); padding: .5rem; border-radius: var(--radius); }

.status-list { display: grid; gap: .5rem; margin: 0; }
.status-list div { display: flex; gap: 1rem; }
.status-list dt { font-weight: 600; min-width: 10rem; }
.status-list dd { margin: 0; }

.pagination { list-style: none; display: flex; gap: 1rem; padding: 0; align-items: center; }

@media (max-width: 640px) {
    .logout { margin-left: 0; }
    table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
