/* ===========================================================================
   RenewPulse — stylesheet
   Theme: blues (#1e40af, #3b82f6, #60a5fa) + purples (#7c3aed, #8b5cf6, #a78bfa)
   Font: Inter
   =========================================================================== */

:root {
    --blue-900: #1e3a8a;
    --blue-800: #1e40af;
    --blue-600: #3b82f6;
    --blue-400: #60a5fa;
    --purple-700: #7c3aed;
    --purple-600: #8b5cf6;
    --purple-400: #a78bfa;

    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --white: #ffffff;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --error: #dc2626;
    --error-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info-bg: #dbeafe;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
    --grad: linear-gradient(135deg, var(--blue-800), var(--purple-700));
    --grad-soft: linear-gradient(135deg, var(--blue-600), var(--purple-600));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- Landing */
.landing-body {
    background: var(--grad);
    min-height: 100vh;
}

.landing-split {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    min-height: 100vh;
}

.hero {
    display: flex;
    align-items: center;
    padding: 64px;
    color: var(--white);
}
.hero-inner { max-width: 560px; }

.hero-brand, .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 40px;
}
.hero-brand.center { justify-content: center; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    background: rgba(255,255,255,.18);
    border-radius: 9px;
    font-size: 18px;
}

.hero-title {
    font-size: 44px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: 20px;
}
.hero-sub {
    font-size: 17px;
    color: rgba(255,255,255,.85);
    margin-bottom: 32px;
}
.hero-features { list-style: none; display: grid; gap: 14px; margin-bottom: 32px; }
.hero-features li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: rgba(255,255,255,.92); }
.tick {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255,255,255,.22); font-size: 12px; flex-shrink: 0;
}
.hero-badge {
    display: inline-block;
    padding: 10px 16px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    font-size: 13px;
    color: rgba(255,255,255,.9);
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 40px;
}
.auth-standalone {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.auth-card {
    background: var(--card);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.auth-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); margin-bottom: 26px; font-size: 15px; }
.auth-links { margin-top: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-links .dot { margin: 0 8px; color: var(--line); }

/* ---------------------------------------------------------------- Forms */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.textarea-code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; line-height: 1.6; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L2 4h8z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
.form-section-title { font-weight: 600; font-size: 14px; color: var(--ink-soft); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .05s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: var(--white); box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.btn-secondary { background: var(--blue-600); color: var(--white); }
.btn-secondary:hover { background: var(--blue-800); }
.btn-ghost { background: transparent; color: var(--purple-700); border: 1px solid var(--purple-400); }
.btn-ghost:hover { background: rgba(139,92,246,.08); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Alerts */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.alert-success { background: var(--success-bg); color: #166534; }
.alert-error { background: var(--error-bg); color: #991b1b; }
.alert-warning { background: var(--warning-bg); color: #92400e; }
.alert-info { background: var(--info-bg); color: #1e40af; }

/* ---------------------------------------------------------------- App shell */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--ink);
    background: linear-gradient(180deg, #14213d, #1e1b4b);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { color: var(--white); padding: 0 8px; margin-bottom: 34px; }
.sidebar-nav { display: grid; gap: 4px; flex: 1; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: var(--white); text-decoration: none; }
.nav-link.is-active { background: var(--grad-soft); color: var(--white); box-shadow: var(--shadow); }
.nav-icon { font-size: 16px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 6px 8px; margin-bottom: 8px; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--grad-soft); color: var(--white);
    font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-name { color: var(--white); font-size: 14px; font-weight: 600; }
.user-company { font-size: 12px; color: #94a3b8; }
.logout-link { display: block; padding: 9px 14px; color: #94a3b8; font-size: 13px; }
.logout-link:hover { color: var(--white); text-decoration: none; }

.main-content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 20px 32px;
    position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 22px; font-weight: 700; }
.content-inner { padding: 28px 32px; max-width: 1200px; width: 100%; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 15px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.grad-blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.grad-blue-2 { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.grad-purple { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.grad-purple-2 { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--muted); }
.card-link { font-size: 13px; font-weight: 600; }
.card .form { padding: 22px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
    text-align: left;
    padding: 12px 22px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}
.table tbody td { padding: 14px 22px; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.empty-cell { text-align: center; color: var(--muted); padding: 40px 22px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }

/* Pills / statuses / tags */
.pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-red { background: var(--error-bg); color: #991b1b; }
.pill-amber { background: var(--warning-bg); color: #92400e; }
.pill-blue { background: var(--info-bg); color: #1e40af; }
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-sent { background: var(--success-bg); color: #166534; }
.status-failed { background: var(--error-bg); color: #991b1b; }
.status-skipped { background: #f1f5f9; color: var(--muted); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; background: var(--purple-400); color: var(--white); border-radius: 5px; font-size: 10px; font-weight: 700; vertical-align: middle; }
.tag-blue   { background: var(--blue-600); }
.tag-purple { background: var(--purple-600); }
.tag-green  { background: #16a34a; }
.error-hint { color: var(--error); cursor: help; margin-left: 4px; }

/* Tabs */
.tab-bar { display: flex; gap: 4px; background: var(--white); padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none; background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600;
    color: var(--muted); cursor: pointer;
    transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { background: var(--grad-soft); color: var(--white); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Switch */
.switch-field { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch-field input { display: none; }
.switch { position: relative; width: 44px; height: 25px; background: var(--line); border-radius: 999px; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; background: var(--white); border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow); }
.switch-field input:checked + .switch { background: var(--purple-600); }
.switch-field input:checked + .switch::after { transform: translateX(19px); }

/* Checkbox interval grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; }
.check-card { cursor: pointer; }
.check-card input { display: none; }
.check-card-body {
    display: grid; place-items: center; gap: 2px;
    padding: 18px 10px;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color .15s, background .15s;
}
.check-card input:checked + .check-card-body { border-color: var(--purple-600); background: rgba(139,92,246,.06); }
.check-card-num { font-size: 24px; font-weight: 800; color: var(--ink); }
.check-card-label { font-size: 12px; color: var(--muted); }

/* Template editor */
.editor-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.side-stack { display: grid; gap: 24px; }
.merge-card .muted, .muted { color: var(--muted); font-size: 13px; }
.merge-card .muted { padding: 0 22px; margin-bottom: 8px; }
.merge-list { list-style: none; padding: 0 22px 22px; display: grid; gap: 10px; }
.merge-list li { display: flex; align-items: center; gap: 10px; }
.merge-tag {
    font-family: ui-monospace, Menlo, monospace; font-size: 12px;
    background: rgba(59,130,246,.1); color: var(--blue-800);
    border: 1px solid rgba(59,130,246,.25);
    padding: 4px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.merge-tag:hover { background: rgba(59,130,246,.18); }
.merge-desc { font-size: 12.5px; color: var(--muted); }
.preview-pane { padding: 22px; min-height: 200px; font-size: 14px; }
.preview-pane .preview-subject { font-weight: 700; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.inline-result { margin-top: 12px; font-size: 13px; }
.inline-result.ok { color: var(--success); }
.inline-result.err { color: var(--error); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px; }
.page-btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.page-btn:hover { border-color: var(--blue-600); color: var(--blue-600); text-decoration: none; }
.page-info { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .editor-grid { grid-template-columns: 1fr; }
    .landing-split { grid-template-columns: 1fr; }
    .hero { padding: 48px 32px; }
}
@media (max-width: 720px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar-brand { margin-bottom: 0; margin-right: auto; }
    .sidebar-nav { flex: 0 0 100%; grid-auto-flow: column; overflow-x: auto; margin-top: 12px; }
    .sidebar-footer { flex: 0 0 100%; display: flex; align-items: center; justify-content: space-between; border-top: none; }
    .stat-grid { grid-template-columns: 1fr; }
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
    .content-inner { padding: 20px; }
    .hero-title { font-size: 32px; }
}
