/* =========================================================
   CP-Demo.com - dark green on white, Inter, responsive
   ========================================================= */
:root {
    --green-900: #0b2e22;
    --green-800: #14422f;
    --green-700: #1b4332;
    --green-600: #2d6a4f;
    --green-500: #40916c;
    --green-400: #52b788;
    --green-100: #e6f0eb;
    --green-50:  #f1f7f4;

    --ink:       #0f1f1a;
    --ink-soft:  #2c3a35;
    --muted:     #6a7a73;
    --line:      #d8e2dc;
    --line-2:    #eef2f0;
    --bg:        #ffffff;

    --danger:    #b3261e;
    --danger-bg: #fdecea;
    --ok:        #1b6b3a;
    --ok-bg:     #e5f4ec;

    --radius:    10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(11, 46, 34, 0.06),
                 0 1px 3px rgba(11, 46, 34, 0.04);
    --shadow-md: 0 4px 14px rgba(11, 46, 34, 0.08);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
            'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--green-600); text-decoration: underline; }

.container {
    width: 100%;
    max-width: 1060px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------------- Header ---------------- */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--green-800);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--green-700); }
.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--green-700), var(--green-500));
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
}
.top-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-pill {
    color: var(--muted);
    font-size: 14px;
}

/* ---------------- Main ---------------- */
.main {
    padding: 36px 24px 64px;
}

.hero {
    margin: 8px 0 28px;
    text-align: center;
}
.hero-title {
    font-size: 40px;
    line-height: 1.1;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    color: var(--green-800);
    font-weight: 700;
}
.hero-sub {
    color: var(--muted);
    font-size: 17px;
    margin: 0;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 0 24px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 28px;
    margin: 0 0 4px;
    color: var(--green-800);
    letter-spacing: -0.01em;
    font-weight: 700;
}
.page-sub {
    margin: 0;
    color: var(--muted);
}

/* ---------------- Card ---------------- */
.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}
.card-narrow {
    max-width: 440px;
    margin: 8px auto 0;
}
.card-title {
    margin: 0 0 4px;
    font-size: 20px;
    color: var(--green-800);
}
.card-sub {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14px;
}

/* ---------------- Form ---------------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.field-row > .field { flex: 1 1 200px; min-width: 0; }
.field-grow { flex: 2 1 240px; }
.field-narrow { flex: 0 1 140px; }
.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}
.field-hint {
    color: var(--muted);
    font-size: 12px;
}
.input {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    transition: border-color 120ms, box-shadow 120ms;
}
.input:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.25);
}
.textarea {
    resize: vertical;
    min-height: 160px;
    font-family: var(--font);
}
.muted { color: var(--muted); font-weight: 400; }
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.inline-form { display: inline; margin: 0; padding: 0; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 120ms, color 120ms, border-color 120ms,
                box-shadow 120ms, transform 60ms;
    text-decoration: none;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--green-700);
    color: #fff;
}
.btn-primary:hover {
    background: var(--green-600);
    color: #fff;
    text-decoration: none;
}
.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--green-800);
    border-color: var(--line);
}
.btn-ghost:hover {
    background: var(--green-50);
    text-decoration: none;
}

.btn-block { width: 100%; }

/* ---------------- Flash ---------------- */
.flash {
    margin: 0 0 20px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.flash-success {
    background: var(--ok-bg);
    color: var(--ok);
    border-color: rgba(27, 107, 58, 0.25);
}
.flash-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(179, 38, 30, 0.25);
}

/* ---------------- Action tiles ---------------- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 8px;
}
.action-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 28px;
    min-height: 200px;
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg,
                var(--green-700) 0%,
                var(--green-600) 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    transition: transform 120ms, box-shadow 120ms;
}
.action-tile:hover {
    transform: translateY(-2px);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(11, 46, 34, 0.18);
}
.action-tile-eyebrow {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
}
.action-tile-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.action-tile-sub {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    line-height: 1.5;
    margin-top: auto;
}

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}
.table th, .table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-2);
}
.table thead th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--green-50);
}
.table tbody tr:hover { background: var(--green-50); }
.col-num    { width: 56px; color: var(--muted); }
.col-action { width: 72px; text-align: center; }

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    color: var(--green-700);
    border: 1px solid var(--line);
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
}
.icon-link:hover {
    background: var(--green-100);
    color: var(--green-800);
    text-decoration: none;
}
.icon-link-danger { color: var(--danger); }
.icon-link-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 24px 0;
    margin: 0;
}

/* ---------------- Footer ---------------- */
.site-footer {
    border-top: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    padding: 20px 0;
    text-align: center;
    font-size: 13px;
}

/* ---------------- Top nav bar (logged-in) ---------------- */
.nav-bar {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 0;
    margin: 0 auto;
    border-top: 1px solid var(--line-2);
}
.nav-link {
    display: inline-block;
    padding: 12px 14px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    transition: color 120ms, border-color 120ms, background 120ms;
}
.nav-link:hover {
    color: var(--green-800);
    background: var(--green-50);
    text-decoration: none;
}
.nav-link.is-active {
    color: var(--green-800);
    border-bottom-color: var(--green-700);
    font-weight: 600;
}
.page-head-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------------- Toggle / Checkbox row ---------------- */
.toggle {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    color: var(--ink-soft);
    user-select: none;
    cursor: pointer;
    padding: 4px 0;
}
.toggle input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--green-600);
}

/* ---------------- KPI grid ---------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.kpi-value {
    font-size: 28px;
    color: var(--green-800);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-warn .kpi-value { color: var(--danger); }

/* ---------------- Chart grid ---------------- */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.chart-grid .card { padding: 18px 20px; }

/* ---------------- Filter bar ---------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}
.filter-bar .input { min-width: 240px; }
.filter-bar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.filter-bar-grid .filter-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-bar-grid .field-grow-2 { grid-column: span 2; }

/* ---------------- Tables: sort/compact ---------------- */
.sort-link {
    color: inherit;
    text-decoration: none;
    user-select: none;
}
.sort-link:hover { color: var(--green-700); text-decoration: underline; }

.table-clickable thead th { cursor: pointer; }
.table-compact th, .table-compact td {
    padding: 8px 10px;
    font-size: 13px;
}
.table-compact td.mono, .table-compact td.ellipsis {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.json-blob {
    max-width: 480px;
    max-height: 220px;
    overflow: auto;
    background: #f6faf7;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    white-space: pre-wrap;
}
.card-flush { padding: 0; }
.card-flush .table-wrap { padding: 0; }

.row-warn   { background: rgba(217, 168, 73, 0.08); }
.row-danger { background: rgba(179, 38, 30, 0.07); }

/* ---------------- Event badges ---------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: var(--green-100);
    color: var(--green-800);
    text-transform: capitalize;
}
.badge-send       { background: #d8eddf; color: #14422f; }
.badge-delivery   { background: #c9e8d6; color: #14422f; }
.badge-bounce     { background: #fdecea; color: #b3261e; }
.badge-complaint  { background: #fcd9bd; color: #8a3d00; }
.badge-rendering  { background: #eef2f0; color: #2c3a35; }
.badge-deliverydelay { background: #fdf5e6; color: #8a3d00; }
.badge-reject     { background: #fdecea; color: #b3261e; }

/* ---------------- Pagination ---------------- */
.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}
.pagination-info {
    margin-right: auto;
    color: var(--muted);
    font-size: 13px;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.col-date { white-space: nowrap; }

/* ---------------- Recipient rows (insight email form) ---------------- */
.recipient-row {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--green-50);
}
.weekday-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.weekday-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.weekday-chip input[type="checkbox"] {
    width: 14px; height: 14px;
    accent-color: var(--green-600);
}
.weekday-chip:has(input:checked) {
    background: var(--green-700);
    color: #fff;
    border-color: var(--green-700);
}
.freq-pane { margin-top: 8px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
    .hero-title { font-size: 32px; }
    .page-title { font-size: 24px; }
    .action-grid { grid-template-columns: 1fr; }
    .action-tile { min-height: 160px; padding: 22px; }
    .card { padding: 20px; }
    .header-inner { height: 56px; }
    .user-pill { display: none; }
}
@media (max-width: 480px) {
    .container { padding: 0 16px; }
    .main { padding: 24px 16px 48px; }
    .field-row { gap: 12px; }
}
