:root {
    --bg: #f0f2f5;
    --text: #1a1a2e;
    --muted: #5f6b7a;
    --nav-bg: #1e2530;
    --brand-green: #22c55e;
    --card-border: #d5dbe3;
    --card-bg: #f8f9fb;
    --link: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #eab308;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --transition: 150ms ease;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Topbar ── */

.topbar {
    background: var(--nav-bg);
    color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.topbar-inner {
    width: min(100%, 1400px);
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-size: 15px;
    font-weight: 600;
    color: #f2f5f8;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.brand i {
    color: var(--brand-green);
    font-size: 18px;
}

.topnav {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topnav a {
    color: #c5cdd7;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}

.topnav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    text-decoration: none;
}

.topnav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

/* ── Page containers ── */

.page {
    width: min(100%, 820px);
    margin: 28px auto 20px;
    padding: 0 20px;
}

.page-wide {
    width: min(100%, 1400px);
    margin: 28px auto 20px;
    padding: 0 20px;
}

/* ── Cards ── */

.card {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.legal-card {
    background: var(--card-bg);
    text-align: center;
    margin-bottom: 20px;
}

.legal-card h2 {
    margin: 0;
    font-size: 32px;
}

.legal-title {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    font-weight: 700;
}

.legal-subtitle {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--muted);
}

.heading {
    font-size: 36px;
    line-height: 1.15;
    margin: 16px 0 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.subheading {
    font-size: 17px;
    margin: 0;
    font-weight: 700;
}

.meta-links {
    margin: 10px 0 8px;
    display: inline-flex;
    gap: 20px;
    font-size: 14px;
    font-weight: 600;
}

.meta-note {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}

/* ── Forms ── */

.form-panel {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--link);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
    min-height: 84px;
}

.input-group {
    display: flex;
    width: 100%;
}

.input-group .prefix {
    border: 1px solid #d1d5db;
    border-right: 0;
    border-radius: 6px 0 0 6px;
    background: #f3f4f6;
    font-size: 14px;
    color: var(--muted);
    padding: 10px 12px;
    font-weight: 500;
}

.input-group input {
    border-radius: 0 6px 6px 0;
}

.help {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

/* ── Consent boxes ── */

.consent-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    user-select: none;
}

.consent-box:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
    box-shadow: var(--shadow-sm);
}

.consent-box.checked {
    border-color: #93c5fd;
    background: #eff6ff;
}

.unsubscribe-panel .consent-box.checked {
    border-color: #fca5a5;
    background: #fef2f2;
}

.consent-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
}

.consent-title.service {
    color: #1d4ed8;
}

.consent-title.marketing {
    color: #15803d;
}

.consent-title.email-service {
    color: #0f766e;
}

.consent-title.email-marketing {
    color: #c2410c;
}

.consent-title.voice {
    color: #7c3aed;
}

.icon-slash {
    position: relative;
    display: inline-block;
}

.icon-slash::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        currentColor calc(50% - 1px),
        currentColor calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}

.consent-box p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #475569;
}

.consent-box input[type="checkbox"] {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 6px;
    cursor: pointer;
    accent-color: var(--link);
    flex-shrink: 0;
}

.consent-box label {
    display: inline;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.55;
    color: #475569;
}

.agreement {
    margin-top: 14px;
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
}

/* ── Notices ── */

.notice {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.notice.success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.notice.error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* ── Buttons ── */

.btn-row {
    display: flex;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

.btn.full {
    width: 100%;
}

.btn-sm {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 5px;
}

.btn-xs {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #1a1a2e;
}

.btn-primary {
    background: var(--link);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: #d1d5db;
    color: var(--text);
}

.btn:hover {
    text-decoration: none;
    filter: brightness(0.95);
    box-shadow: var(--shadow-sm);
}

.btn-icon {
    padding: 6px 8px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
    background: #f3f4f6;
    color: var(--text);
    text-decoration: none;
}

.home-actions .btn {
    flex: 1;
    font-size: 16px;
    padding: 14px 20px;
}

/* ── Page titles ── */

.page-title {
    margin: 12px 0 16px;
    font-size: 36px;
    line-height: 1.15;
    font-weight: 700;
}

.small-muted {
    color: var(--muted);
    font-size: 13px;
}

/* ── Tabs ── */

.tabs {
    display: flex;
    border: 1px solid var(--card-border);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    margin-bottom: 0;
}

.tabs a {
    flex: 1;
    text-align: center;
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    background: #f8f9fb;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), background var(--transition);
}

.tabs a.active {
    color: var(--link);
    background: #fff;
    border-bottom-color: var(--link);
}

.tabs a:hover {
    text-decoration: none;
    color: var(--text);
}

.unsubscribe-panel {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* ── Info strip ── */

.info-strip {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
    color: #475569;
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ── Tables ── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid #f0f0f0;
    padding: 10px 12px;
    font-size: 14px;
    vertical-align: middle;
    text-align: left;
}

th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

th a {
    color: var(--muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

th a:hover {
    color: var(--text);
    text-decoration: none;
}

th a .sort-icon {
    font-size: 10px;
    opacity: 0.4;
}

th a.sorted .sort-icon {
    opacity: 1;
    color: var(--link);
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges ── */

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 3px;
    margin-bottom: 2px;
}

.badge.on {
    background: #dcfce7;
    color: #166534;
}

.badge.off {
    background: #f3f4f6;
    color: #6b7280;
}

.badge.badge-warn {
    background: #fef3c7;
    color: #92400e;
}

/* ── Footer ── */

.footer {
    margin-top: auto;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 20px 16px 28px;
}

.footer .quick-links {
    margin-bottom: 8px;
}

.footer .quick-links a {
    color: var(--muted);
    font-size: 13px;
}

.footer .admin-links {
    display: inline-flex;
    gap: 8px;
    margin-top: 4px;
}

.footer .admin-links .btn {
    font-size: 12px;
    padding: 6px 10px;
}

.inline-links {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--muted);
}

/* ── Policy content ── */

.policy-content h2 {
    font-size: 18px;
    margin: 20px 0 8px;
    font-weight: 700;
}

.policy-content p,
.policy-content li {
    font-size: 14px;
    line-height: 1.65;
    color: #475569;
}

.highlight {
    border-left: 3px solid var(--link);
    background: #f8fafc;
    padding: 14px 16px;
    margin: 16px 0;
    border-radius: 0 6px 6px 0;
}

/* ── Admin layout ── */

.admin-layout {
    display: grid;
    gap: 20px;
}

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

/* ── Admin toolbar ── */

.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-toolbar .search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.admin-toolbar .search-box input {
    padding-left: 36px;
    font-size: 14px;
}

.admin-toolbar .search-box .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
    pointer-events: none;
}

.admin-toolbar select {
    width: auto;
    min-width: 160px;
    font-size: 14px;
    padding: 10px 12px;
}

.admin-toolbar .toolbar-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.subscriber-count {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

/* ── Admin sections ── */

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-section-header .subheading {
    margin: 0;
}

/* ── Actions column ── */

.actions {
    display: inline-flex;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
}

/* ── Settings page ── */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* ── Subscriber form (create/edit) ── */

.subscriber-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.campaign-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.campaign-overview-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.campaign-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.campaign-stat {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.campaign-stat-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.campaign-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}

.campaign-section-jump {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.consent-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.consent-row .consent-box {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.inline-actions {
    display: inline-flex;
    gap: 8px;
}

.campaign-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 10px;
    background: #f8fafc;
}

.campaign-user-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid #dbe1ea;
    border-radius: 6px;
    background: #fff;
    padding: 10px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.campaign-user-option:hover {
    border-color: #93c5fd;
    box-shadow: var(--shadow-sm);
}

.campaign-user-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0 0 4px;
}

.campaign-user-option.ineligible {
    opacity: 0.55;
    border-style: dashed;
    background: #f8fafc;
}

.campaign-user-option.no-consent {
    border-color: #fbbf24;
    border-style: dashed;
    background: #fffbeb;
}

.campaign-user-option.no-consent:hover {
    border-color: #f59e0b;
}

.campaign-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.campaign-user-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    line-height: 1.3;
}

.campaign-guide-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.setup-steps,
.setup-list {
    margin: 8px 0 0 18px;
    padding: 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
}

.setup-list {
    list-style: disc;
}

.setup-steps li,
.setup-list li {
    margin: 4px 0;
}

.code-sample {
    margin: 0;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #1e293b;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.consent-info-strip {
    background: #fffbeb;
    border-color: #fde68a;
    color: #78350f;
}

.consent-info-strip i {
    color: #d97706;
    margin-right: 4px;
}

.campaign-empty {
    padding: 22px 16px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
}

.campaign-row-selected td {
    background: #eff6ff;
}

/* ── Pagination ── */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 0;
    margin-top: 14px;
    border-top: 1px solid #e5e7eb;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--muted);
}

.pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pagination-page {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

/* ── Inline edit row ── */

.edit-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 20px 24px;
}

.edit-banner .subheading {
    color: #1e40af;
}

/* ── Empty state ── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.empty-state i {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
    opacity: 0.4;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ── Responsive ── */

@media (max-width: 880px) {
    .heading,
    .page-title {
        font-size: 28px;
    }

    .legal-title {
        font-size: 26px;
    }

    .btn:not(.btn-sm):not(.btn-xs):not(.btn-icon) {
        font-size: 14px;
    }

    .admin-grid,
    .subscriber-form-grid,
    .settings-grid,
    .campaign-form-grid {
        grid-template-columns: 1fr;
    }

    .campaign-guide-grid {
        grid-template-columns: 1fr;
    }

    .consent-row {
        flex-direction: column;
    }

    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-toolbar .toolbar-actions {
        margin-left: 0;
        justify-content: flex-end;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 700px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 16px;
    }

    .topnav {
        width: 100%;
        justify-content: flex-start;
        gap: 4px;
        flex-wrap: wrap;
    }

    .btn-row {
        flex-direction: column;
    }

    .page,
    .page-wide {
        padding: 0 12px;
    }

    .card,
    .form-panel {
        padding: 16px;
    }

    .actions {
        flex-direction: column;
    }
}

/* ── Confirm Modal ── */

.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
}

.confirm-overlay.open {
    display: flex;
}

.confirm-dialog {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md), 0 8px 24px rgba(0, 0, 0, 0.12);
    max-width: 400px;
    width: calc(100% - 32px);
    padding: 24px;
    animation: confirmFadeIn 150ms ease;
}

@keyframes confirmFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.confirm-dialog .confirm-icon {
    font-size: 28px;
    color: var(--danger);
    margin-bottom: 8px;
}

.confirm-dialog .confirm-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 6px;
}

.confirm-dialog .confirm-message {
    font-size: 14px;
    color: var(--muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.confirm-dialog .confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
