* { box-sizing: border-box; }

:root {
    --red: #b3122e;
    --red-bright: #d42a45;
    --ink: #1d2233;
    --muted: #6b7288;
    --line: #e6e8ef;
    --bg: #f5f6fa;
}

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--red); }
h1 { font-size: 26px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.danger { color: var(--red) !important; }

/* ---------- Top bar ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 28px;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 17px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--red-bright), #8f0e24);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
}

.topbar nav { display: flex; gap: 4px; flex: 1; }

.topbar nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.topbar nav a:hover { background: var(--bg); color: var(--ink); }
.topbar nav a.active { background: #fdeaed; color: var(--red); }

.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.who form { margin: 0; }

.container { max-width: 1180px; margin: 0 auto; padding: 28px; }

/* ---------- Panels, stats ---------- */

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 20px;
}

.panel.flush { padding: 0; overflow: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head.pad { padding: 18px 22px 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats.compact { grid-template-columns: repeat(2, 1fr); margin: 16px 0 8px; }

.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
    color: inherit;
    text-decoration: none;
}

a.stat:hover { border-color: var(--red-bright); }
.stat span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat strong { display: block; margin-top: 6px; font-size: 28px; font-weight: 800; }
.stat strong.small { font-size: 18px; margin-top: 12px; }

/* ---------- Charts ---------- */

.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.chart.hours { gap: 3px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-group span { font-size: 11px; color: var(--muted); margin-top: 6px; height: 14px; white-space: nowrap; }
.bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar { width: 100%; max-width: 18px; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar.visits { background: var(--red-bright); }
.bar.new { background: #1d2233; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.key-visits { background: var(--red-bright); margin-left: 0; }
.key-new { background: #1d2233; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 22px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td form { margin: 0; display: inline; }
.panel:not(.flush) th, .panel:not(.flush) td { padding-left: 0; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef0f5;
    color: var(--muted);
}

.badge-sent, .badge-delivered, .badge-subscribed, .badge-live { background: #e3f6ea; color: #17803d; }
.badge-sending, .badge-pending, .badge-scheduled { background: #e8efff; color: #2d55c7; }
.badge-failed, .badge-paused, .badge-opted-out { background: #fdeaed; color: var(--red); }

/* ---------- Forms ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--red-bright), #9e0f28);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg); }

.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--red); cursor: pointer; }
.who .link { color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="search"],
input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #d8dbe5;
    border-radius: 10px;
    background: #fff;
    font: inherit;
    color: var(--ink);
}

textarea { height: auto; padding: 12px; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--red-bright);
    box-shadow: 0 0 0 3px rgba(212, 42, 69, .12);
}

.form label, .public-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.form label input, .form label textarea, .public-card label input { margin-top: 6px; }
.form label.radio { font-weight: 400; margin-bottom: 8px; }
.form label.inline { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.form label.inline input { width: auto; margin: 0; }

fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px 16px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 700; font-size: 14px; }
fieldset .btn { margin-top: 12px; }

.counter { margin: -6px 0 6px; font-size: 13px; color: var(--muted); }
.reach { margin: 12px 0 0; font-size: 14px; }
.actions { display: flex; gap: 10px; margin: 16px 0; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { max-width: 280px; }
.toolbar select { width: auto; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; background: #e3f6ea; color: #17803d; font-weight: 600; }
.flash.error { background: #fdeaed; color: var(--red); }

.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 16px 0; color: var(--muted); }

.details { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0 0 16px; }
.details dt { color: var(--muted); font-weight: 600; }
.details dd { margin: 0; }

.sms-preview {
    max-width: 340px;
    padding: 12px 14px;
    border-radius: 16px 16px 16px 4px;
    background: #eef0f5;
    line-height: 1.45;
    white-space: normal;
    word-wrap: break-word;
}

input[type="file"] { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; }
.media-preview { display: block; width: 100%; max-height: 320px; border-radius: 12px; background: #000; object-fit: contain; margin-bottom: 10px; }
.media-thumb { display: block; width: 96px; height: 54px; border-radius: 6px; background: #000; object-fit: cover; }

.progress { height: 10px; border-radius: 99px; background: #eef0f5; overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--red-bright), #9e0f28); }

/* ---------- Public pages (login, opt-out) ---------- */

body.public {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 20% 0%, #d42a45 0%, #b3122e 40%, #6e0a1c 100%);
}

.public-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 30px 60px rgba(40, 0, 10, .45);
}

.public-card .brand { margin-bottom: 22px; }
.public-card h1 { font-size: 22px; margin-bottom: 10px; }
.public-card p { color: var(--muted); line-height: 1.5; }
.public-card .btn { width: 100%; height: 48px; margin-top: 6px; }
.public-card form input[type="tel"] { margin-bottom: 12px; }
.hp { position: absolute; left: -9999px; }

.portal-media { position: relative; margin: 0 0 18px; border-radius: 14px; overflow: hidden; background: #000; }
.portal-media video, .portal-media img { display: block; width: 100%; max-height: 55vh; object-fit: contain; }
.portal-media .sound {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.public-card label.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; color: var(--muted); }
.public-card label.check input { width: auto; margin: 3px 0 0; }

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
    .grid-2 { grid-template-columns: 1fr; }
    .topbar { gap: 12px; padding: 0 14px; overflow-x: auto; }
    .topbar .brand { font-size: 0; gap: 0; }
    .container { padding: 18px 14px; }
}
