:root {
    --bg: #f6f7f9;
    --card: #fff;
    --text: #1e2330;
    --muted: #6b7280;
    --line: #e3e6ea;
    --accent: #1a73e8;
    --danger: #c62828;
    --ok: #2e7d32;
    --warn: #b26a00;
}

* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
a { color: var(--accent); }
h1 { font-size: 1.7rem; margin: 0 0 16px; }
h2 { font-size: 1.2rem; margin: 28px 0 10px; }
small, .muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; min-height: 56px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.admin-nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.admin-nav a { color: var(--text); text-decoration: none; }
.admin-nav a:hover { color: var(--accent); }
.site-footer { border-top: 1px solid var(--line); padding: 16px 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 0 0 20px; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.notice { background: #e8f0fe; border: 1px solid #c6dafc; border-radius: 8px; padding: 10px 14px; }
.error { color: var(--danger); }
.danger { color: var(--danger); }

label { display: block; margin: 0 0 14px; font-weight: 600; }
label.check { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=file], select, textarea {
    display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; border: 1px solid #c9ced6; border-radius: 6px; background: #fff;
}
label.check input { display: inline; width: auto; margin: 0 6px 0 0; }
textarea { font: 13px/1.45 ui-monospace, Consolas, Menlo, monospace; resize: vertical; }
input:disabled, textarea:disabled { background: #f1f2f4; color: var(--muted); }

.btn { display: inline-block; padding: 9px 16px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(0.95); }
.btn:disabled { background: #9db7e0; cursor: not-allowed; }
.btn.secondary { background: #eef0f3; color: var(--text); }
.btn.danger { background: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link.danger { color: var(--danger); }
form.inline { display: inline; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row input { flex: 1 1 220px; margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.toolbar input, .toolbar select { margin: 0; width: auto; }
.toolbar input[type=search] { flex: 1 1 200px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f1f3f6; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions form + form::before { content: " · "; color: var(--muted); }
td.detail { font-size: 0.85rem; color: var(--muted); word-break: break-word; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #e5e7eb; color: #374151; vertical-align: middle; }
.badge.subscribed, .badge.sent, .badge.delivery { background: #dcfce7; color: #166534; }
.badge.pending, .badge.draft { background: #fef3c7; color: #92400e; }
.badge.queued, .badge.sending { background: #dbeafe; color: #1e40af; }
.badge.unsubscribed, .badge.cancelled { background: #e5e7eb; color: #374151; }
.badge.bounced, .badge.complained, .badge.cleaned, .badge.bounce, .badge.complaint, .badge.reject { background: #fee2e2; color: #991b1b; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 8px; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.stat strong { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: 0.9rem; }

.editor-card .fields { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 0 16px; align-items: end; }
.editor-card .fields .check { grid-column: 1 / -1; }
.editor-toolbar { margin: 8px 0 10px; }
.editor-tabs .tab { background: none; border: 1px solid var(--line); padding: 6px 14px; cursor: pointer; font: inherit; color: var(--muted); border-radius: 6px 6px 0 0; margin-right: 4px; }
.editor-tabs .tab.active { color: var(--text, #111); border-bottom-color: #fff; background: #fff; font-weight: 600; }
#gjs { border: 1px solid var(--line); border-radius: 0 6px 6px 6px; overflow: hidden; }
#html-pane textarea { width: 100%; min-height: 70vh; }
.small { font-size: 13px; }
.btn.google { background: #fff; color: #1f1f1f; border: 1px solid #747775; display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.btn.google:hover { background: #f3f4f6; }
.preview summary { cursor: pointer; list-style: none; }
.preview iframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 6px; margin-top: 10px; background: #fff; }
@media (max-width: 900px) { .editor-card .fields { grid-template-columns: 1fr; } }

.checklist { list-style: none; padding: 0; margin: 10px 0 16px; }
.checklist li { padding-left: 24px; position: relative; margin: 4px 0; }
.checklist li::before { position: absolute; left: 0; font-weight: 700; }
.checklist li.ok::before { content: "✓"; color: var(--ok); }
.checklist li.bad::before { content: "✗"; color: var(--danger); }
.checklist li.warn::before { content: "!"; color: var(--warn); }

.archive { list-style: none; padding: 0; }
.archive li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; gap: 16px; }
.archive time { color: var(--muted); min-width: 110px; }
.pager { margin-top: 14px; display: flex; gap: 8px; }
details summary { cursor: pointer; font-weight: 600; }
details form { margin-top: 12px; }
