:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --border: #2d3a4f;
    --text: #e7ecf3;
    --muted: #8b9cb3;
    --primary: #25d366;
    --primary-dark: #1da851;
    --danger: #ff6b6b;
    --warn: #f0ad4e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.brand { font-weight: 700; color: var(--text); }

.topbar nav a { margin-left: 1rem; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.auth-card { max-width: 420px; margin: 3rem auto; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.form label {
    display: block;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.form input, .form select, .form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.btn {
    display: inline-block;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border: none;
    font: inherit;
    cursor: pointer;
}

.btn-primary { background: var(--primary); color: #052e16; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-link { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: rgba(255,107,107,0.15); color: #ffb4b4; }
.alert-success { background: rgba(37,211,102,0.15); color: #9ef0b8; }
.alert-warn { background: rgba(240,173,78,0.15); color: #ffd89a; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

.badge {
    font-size: 0.75rem;
    background: var(--border);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.25rem;
}

.status { font-size: 0.85rem; padding: 0.2rem 0.5rem; border-radius: 999px; }
.status-pending { background: rgba(240,173,78,0.2); color: #ffd89a; }
.status-processing { background: rgba(100,149,237,0.2); color: #a8c7ff; }
.status-sent { background: rgba(37,211,102,0.2); color: #9ef0b8; }
.status-failed { background: rgba(255,107,107,0.2); color: #ffb4b4; }
.status-cancelled { background: rgba(139,156,179,0.2); color: var(--muted); }

.messages-fieldset {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.recurrence-fieldset {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.checkbox-inline input {
    width: auto;
    margin: 0;
}

.recurrence-panel {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.weekday-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 0.5rem 0 1rem;
}

.weekday-grid label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text);
    margin: 0;
}

.weekday-grid input {
    width: auto;
    margin: 0;
}

.field-label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.recurrence-preview {
    margin-top: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.replace-all-option {
    display: flex;
    margin: 1rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.badge-recurrence {
    background: rgba(37, 211, 102, 0.15);
    color: #9ef0b8;
    font-size: 0.75rem;
}

.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; }

.form-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.actions-cell {
    white-space: nowrap;
}

.btn-link-action {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    margin-right: 0.75rem;
}

.btn-link-action:hover {
    color: #9ef0b8;
}

.btn-delete-series-inline,
.btn-delete-single {
    color: #ffb4b4;
}

.btn-delete-series-inline:hover,
.btn-delete-single:hover {
    color: #ff6b6b;
}


.message-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.message-block .inline { display: inline-block; width: auto; margin-right: 1rem; }

.api-key {
    display: block;
    word-break: break-all;
    background: var(--bg);
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0.75rem 0;
}

.footer { padding: 2rem 0; text-align: center; }
