:root {
    --wine: #8d1735;
    --wine-dark: #651026;
    --red: #c52a38;
    --ink: #17171a;
    --muted: #72727c;
    --line: #e7e7eb;
    --surface: #ffffff;
    --background: #f5f5f7;
    --success: #16835d;
    --warning: #b36a00;
    --danger: #b42336;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(18, 18, 24, .07);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--wine); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
code { background: #f0f0f3; border-radius: 5px; padding: 2px 5px; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 248px; background: #161619; color: white; padding: 22px 16px; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 10; }
.brand { color: white; display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 16px; padding: 0 8px 25px; }
.brand small { color: #aaaab2; font-weight: 500; }
.brand-mark { width: 42px; height: 42px; display: inline-grid; place-items: center; flex: 0 0 42px; border-radius: 12px; color: white; background: linear-gradient(140deg, var(--red), var(--wine-dark)); font-weight: 850; letter-spacing: -.5px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { color: #bdbdc4; padding: 11px 13px; border-radius: 10px; display: flex; align-items: center; gap: 11px; }
.sidebar nav a:hover, .sidebar nav a.active { background: #29292e; color: white; }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #303036; padding: 16px 8px 0; display: grid; }
.sidebar-footer span { font-weight: 650; }
.sidebar-footer a { color: #a8a8b1; font-size: 13px; }
.main-area { margin-left: 248px; width: calc(100% - 248px); }
.topbar { height: 92px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 34px; }
.topbar h1 { font-size: 23px; margin-bottom: 2px; }
.topbar p { color: var(--muted); margin: 0; font-size: 13px; text-transform: capitalize; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 24px; margin-right: 14px; }
.content { padding: 28px 34px 50px; max-width: 1500px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { padding: 21px; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; font-size: 28px; margin-top: 8px; }
.stat-card .trend { color: var(--success); font-size: 12px; }
.card { padding: 23px; margin-bottom: 22px; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.card-header h2 { font-size: 17px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 18px; }
.toolbar form { display: contents; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font: inherit; font-weight: 650; background: white; color: var(--ink); }
.button-primary { background: var(--wine); color: white; }
.button-primary:hover { background: var(--wine-dark); }
.button-secondary { border-color: var(--line); }
.button-danger { color: var(--danger); border-color: #f2ccd2; background: #fff7f8; }
.button-small { padding: 6px 10px; min-height: 32px; font-size: 12px; }
.button-block { width: 100%; }
label { display: grid; gap: 6px; color: #3b3b42; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #d9d9df; border-radius: 9px; padding: 10px 11px; background: white; color: var(--ink); font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(141, 23, 53, .11); }
textarea { min-height: 130px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid .full { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.checkbox input { width: auto; }
.table-wrap { overflow-x: auto; margin: 0 -23px -23px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { color: var(--muted); background: #fafafa; font-size: 12px; letter-spacing: .02em; text-transform: uppercase; text-align: left; }
th, td { padding: 13px 18px; border-top: 1px solid var(--line); }
td.actions { display: flex; gap: 6px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; background: #eeeef1; font-size: 12px; font-weight: 650; }
.badge-success { color: #0d6849; background: #e4f6ee; }
.badge-danger { color: #9e2133; background: #fbe7ea; }
.badge-warning { color: #895100; background: #fff0d6; }
.alert { border-radius: 10px; padding: 12px 15px; margin-bottom: 18px; }
.alert-success { color: #0c6848; background: #e5f7ef; border: 1px solid #bce8d5; }
.alert-error { color: #962034; background: #fcebed; border: 1px solid #f1c6cd; }
.alert-warning { color: #805000; background: #fff2dc; border: 1px solid #f0dab0; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 35px; color: var(--muted); }
.pagination { display: flex; gap: 7px; margin-top: 18px; }
.pagination a { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.pagination a.active { background: var(--wine); color: white; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric { padding: 14px; border: 1px solid var(--line); border-radius: 11px; }
.metric strong { display: block; font-size: 21px; }
.bar { height: 9px; border-radius: 10px; background: #ececf0; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--wine); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at top, #f7e9ed, #f4f4f6 50%); }
.auth-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 34px; }
.auth-card .brand-mark { margin-bottom: 20px; }
.auth-card form { display: grid; gap: 16px; }
.preview-frame { width: 100%; min-height: 440px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.email-preview-stage { display: flex; justify-content: center; padding: 14px; border-radius: 12px; background: #ececf0; overflow: auto; }
.email-preview-stage .preview-frame { transition: width .2s ease; }
.preview-controls, .template-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-controls .active { color: white; background: var(--wine); border-color: var(--wine); }
.preview-dialog { width: min(1000px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 22px; box-shadow: 0 24px 70px rgba(18, 18, 24, .25); }
.preview-dialog::backdrop { background: rgba(18, 18, 24, .62); }
.preview-dialog .preview-frame { height: min(720px, calc(100vh - 150px)); }
.code-block { background: #18181b; color: #efeff1; border-radius: 10px; padding: 15px; overflow: auto; white-space: pre-wrap; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; width: 100%; }
    .menu-toggle { display: block; }
    .topbar { padding: 0 18px; }
    .content { padding: 20px 16px 40px; }
    .stats-grid, .form-grid, .metric-row { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
}
