/* Mailverteiler – single stylesheet, no framework. */

:root {
    color-scheme: light dark;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #d9dde3;
    --border-strong: #b9c0cb;
    --text: #1d2430;
    --text-muted: #626d7d;
    --accent: #2f5bd7;
    --accent-hover: #2246ad;
    --accent-soft: #e8eefc;
    --ok: #1c7a46;
    --ok-soft: #e3f5ea;
    --warn: #8a5a00;
    --warn-soft: #fdf1da;
    --error: #b3261e;
    --error-soft: #fbe6e5;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

/* Dark colours apply when the system asks for them and the user has not forced light, */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14181f;
        --surface: #1c222b;
        --surface-2: #232a35;
        --border: #313a47;
        --border-strong: #46515f;
        --text: #e7ecf3;
        --text-muted: #9aa6b6;
        --accent: #6f95ef;
        --accent-hover: #87a7f4;
        --accent-soft: #223050;
        --ok: #5fd096;
        --ok-soft: #1a3428;
        --warn: #e5b85c;
        --warn-soft: #3a2f18;
        --error: #f08b85;
        --error-soft: #3a2220;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

/* ... and always when the user picked dark explicitly. */
:root[data-theme="dark"] {
    --bg: #14181f;
    --surface: #1c222b;
    --surface-2: #232a35;
    --border: #313a47;
    --border-strong: #46515f;
    --text: #e7ecf3;
    --text-muted: #9aa6b6;
    --accent: #6f95ef;
    --accent-hover: #87a7f4;
    --accent-soft: #223050;
    --ok: #5fd096;
    --ok-soft: #1a3428;
    --warn: #e5b85c;
    --warn-soft: #3a2f18;
    --error: #f08b85;
    --error-soft: #3a2220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

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

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

/* ---------- Layout ---------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 650;
    letter-spacing: -.01em;
    text-decoration: none;
    color: var(--text);
    margin-right: 8px;
    white-space: nowrap;
}

.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }

.nav a {
    padding: 7px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 16px 64px;
}

.container.narrow { max-width: 680px; }

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

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

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

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

.card > h2:first-child { margin-top: 0; }
.card-tight { padding: 0; overflow: hidden; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-body { padding: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Narrow screens: the navigation scrolls sideways instead of stacking. */
@media (max-width: 720px) {
    .topbar-inner { flex-wrap: nowrap; gap: 6px; min-height: 52px; }
    .nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { padding: 6px 10px; font-size: 14px; }
    .page-head h1 { font-size: 19px; }
}

@media (max-width: 480px) {
    .brand-text { display: none; }
    .container { padding: 14px 12px 48px; }
    .card { padding: 14px; }
}

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

label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=tel], input[type=url], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

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

input[disabled], textarea[disabled] { background: var(--surface-2); color: var(--text-muted); }

textarea { resize: vertical; min-height: 90px; }

.field { margin-bottom: 14px; }
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.checkbox input { width: auto; margin: 0; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1; min-width: 160px; }
.form-row > .shrink { flex: 0 0 auto; min-width: 0; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

.btn-danger { color: var(--error); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--error-soft); }

.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-link { border: 0; background: none; padding: 4px 6px; color: var(--accent); }
.btn-link:hover { background: var(--accent-soft); }

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

.btn-icon {
    padding: 6px 9px;
    font-size: 15px;
    line-height: 1;
}

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

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }

/* Sortable column headers */
a.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

a.sort-link:hover { color: var(--accent); }
a.sort-link.active { color: var(--text); }
.sort-arrow { font-size: 9px; line-height: 1; color: var(--accent); }
.table-scroll { overflow-x: auto; }

/* ---------- Badges, alerts ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-error { background: var(--error-soft); color: var(--error); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.alert {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 14px;
}

.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-error { background: var(--error-soft); color: var(--error); }
.alert strong { font-weight: 650; }

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

.progress {
    height: 10px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-bar { height: 100%; background: var(--accent); width: 0; transition: width .3s ease; }
.progress-bar.done { background: var(--ok); }

.stat { display: flex; gap: 22px; flex-wrap: wrap; }
.stat-item .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.stat-item .label { font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Attachments ---------- */

.file-list { list-style: none; margin: 10px 0 0; padding: 0; }

.file-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--surface-2);
    font-size: 14px;
}

.file-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--surface-2);
    font-size: 14px;
}

.dropzone.hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

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

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }

.check-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.check-list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.check-list li:last-child { border-bottom: 0; }
.check-list .state { flex: 0 0 18px; font-weight: 700; }
.check-list .state.ok { color: var(--ok); }
.check-list .state.warn { color: var(--warn); }
.check-list .state.error { color: var(--error); }
.check-list .name { flex: 0 0 210px; font-weight: 550; }
.check-list .detail { color: var(--text-muted); flex: 1; }

@media (max-width: 640px) {
    .check-list li { flex-wrap: wrap; }
    .check-list .name { flex-basis: auto; }
    .check-list .detail { flex-basis: 100%; }
}

.spinner {
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.tox-tinymce { border-radius: 8px !important; border-color: var(--border-strong) !important; }
