@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --ink: #172235;
  --muted: #677286;
  --line: #e5e9f0;
  --surface: #ffffff;
  --background: #f6f7fb;
  --navy: #17243c;
  --navy-2: #213252;
  --coral: #ef725f;
  --coral-dark: #d95b49;
  --blue: #4d82d8;
  --gold: #e6ab3b;
  --green: #46a37d;
  --radius: 18px;
  --shadow: 0 16px 45px rgba(28, 40, 67, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: 'DM Sans', system-ui, sans-serif; font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: Manrope, sans-serif; letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; }
h2 { font-size: 1.24rem; }
p { line-height: 1.55; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 27px 18px 20px; color: #dce5f5; background: var(--navy); display: flex; flex-direction: column; z-index: 30; }
.brand-lockup { display: flex; align-items: center; gap: 11px; color: #fff; font-family: Manrope, sans-serif; font-weight: 800; font-size: 1.08rem; }
.sidebar > .brand-lockup { margin: 0 10px 38px; }
.brand-symbol { width: 39px; height: 39px; display: inline-grid; place-items: center; flex: 0 0 39px; border-radius: 13px; color: white; background: var(--coral); font: 800 1.28rem Manrope, sans-serif; box-shadow: 0 8px 22px rgba(239, 114, 95, .28); }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { width: 100%; min-height: 44px; padding: 0 13px; border: 0; border-radius: 11px; display: flex; gap: 12px; align-items: center; color: #aebbd0; background: transparent; text-align: left; font-weight: 600; }
.nav-link span { width: 21px; text-align: center; color: #8496b3; font-size: 1.15rem; }
.nav-link b { margin-left: auto; min-width: 23px; padding: 2px 6px; border-radius: 99px; color: #d8e4f7; background: rgba(255,255,255,.08); font-size: .72rem; text-align: center; }
.nav-link:hover, .nav-link.active { color: white; background: var(--navy-2); }
.nav-link.active span { color: var(--coral); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 4px; }
.nav-button { cursor: pointer; font-family: inherit; font-size: inherit; }
.main-panel { min-width: 0; }
.topbar { min-height: 66px; padding: 0 4vw; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: flex-end; gap: 20px; color: var(--muted); font-size: .82rem; position: sticky; top: 0; z-index: 20; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #51b58c; box-shadow: 0 0 0 4px rgba(81,181,140,.13); }
.user-chip { padding: 8px 12px; border-radius: 9px; color: var(--ink); background: #f0f3f7; font-weight: 600; }
.menu-button { display: none; margin-right: auto; border: 0; background: transparent; font-size: 1.3rem; }
.page-wrap { width: min(1450px, 100%); margin: 0 auto; padding: 46px 4vw 70px; }
.page-heading { margin-bottom: 30px; display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; }
.page-heading p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 9px; color: var(--coral-dark); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.muted { color: var(--muted); }

.button { min-height: 43px; padding: 0 17px; border: 1px solid transparent; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.button-primary { color: white; background: var(--coral); box-shadow: 0 8px 20px rgba(239,114,95,.18); }
.button-primary:hover { background: var(--coral-dark); }
.button-ghost { color: #3b4860; background: white; border-color: var(--line); }
.button-ghost:hover { border-color: #bfc8d7; }
.button-wide { width: 100%; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 18px rgba(28,40,67,.035); }
.card-header { padding: 23px 25px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: .87rem; }
.card-header a { color: var(--coral-dark); font-weight: 700; }
.stats-grid { margin-bottom: 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 17px; }
.stat-card { min-height: 148px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: white; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; width: 90px; height: 90px; right: -24px; bottom: -40px; border-radius: 50%; background: currentColor; opacity: .08; }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { margin: 9px 0 3px; display: block; font: 800 2.35rem Manrope, sans-serif; letter-spacing: -.05em; }
.stat-card.coral { color: var(--coral); } .stat-card.blue { color: var(--blue); } .stat-card.gold { color: var(--gold); } .stat-card.green { color: var(--green); }
.stat-card span, .stat-card small { color: var(--muted); }
.stats-grid.compact .stat-card { min-height: 110px; }
.stats-grid.compact .stat-card strong { font-size: 1.8rem; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; color: #7c8799; background: #fafbfc; text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 16px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); }
td a:hover strong { color: var(--coral-dark); }
.table-card { overflow: hidden; }
.badge { padding: 5px 9px; border-radius: 99px; display: inline-block; color: #526176; background: #eef1f5; white-space: nowrap; font-size: .74rem; font-weight: 700; }
.badge-active, .badge-sent, .badge-completed { color: #24775c; background: #e2f4ed; }
.badge-queued, .badge-sending { color: #9a6707; background: #fff2d7; }
.badge-paused, .badge-skipped { color: #536175; background: #e9edf3; }
.badge-failed, .badge-bounced, .badge-unsubscribed { color: #a24545; background: #fbe7e7; }
.tag { padding: 5px 9px; border-radius: 7px; color: #526176; background: #f0f2f6; font-size: .76rem; }
.row-actions { display: flex; gap: 12px; white-space: nowrap; }
.row-actions a, .row-actions button { border: 0; padding: 0; color: var(--blue); background: none; font-size: .8rem; }
.row-actions button { color: #a95555; }
.error-cell { max-width: 310px; color: #8a5660; font-size: .78rem; }
.empty-state { min-height: 230px; padding: 35px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state > div { margin-bottom: 12px; font-size: 2rem; color: #a5afbd; }
.empty-state p { margin: 7px 0 0; }

.toolbar { margin-bottom: 18px; display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.search { max-width: 520px; flex: 1; display: flex; }
.search input { border-radius: 11px 0 0 11px; }
.search button { padding: 0 16px; border: 1px solid var(--line); border-left: 0; border-radius: 0 11px 11px 0; color: #536175; background: white; font-weight: 700; }
.toolbar-actions { display: flex; gap: 9px; }
label { display: grid; gap: 7px; color: #344158; font-size: .84rem; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; border: 1px solid #dce1e9; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #7c9bd0; box-shadow: 0 0 0 3px rgba(77,130,216,.11); }
textarea { resize: vertical; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.span-2 { grid-column: span 2; }

dialog { width: min(620px, calc(100% - 32px)); border: 0; padding: 0; border-radius: 18px; background: transparent; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(17, 28, 47, .54); backdrop-filter: blur(3px); }
dialog[open]:not(:modal) { position: fixed; inset: 0; z-index: 50; }
.dialog-card { padding: 26px; border-radius: 18px; background: white; }
.dialog-head { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: #657187; background: #f1f3f6; font-size: 1.4rem; }
.dialog-actions { margin-top: 25px; display: flex; justify-content: flex-end; gap: 9px; }
.upload-zone { padding: 30px; border: 1.5px dashed #c9d1df; border-radius: 14px; text-align: center; background: #fafbfd; }
.upload-zone p { color: var(--muted); }
.upload-zone input { margin-top: 8px; }

.composer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.composer-main { padding: 28px; display: grid; gap: 19px; }
.composer-side { padding: 26px; position: sticky; top: 90px; }
.section-title { margin-top: 4px; padding-top: 8px; display: flex; gap: 13px; align-items: flex-start; }
.section-title:not(:first-of-type) { margin-top: 16px; padding-top: 27px; border-top: 1px solid var(--line); }
.section-title > span { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 29px; border-radius: 50%; color: white; background: var(--coral); font-weight: 800; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
.merge-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.merge-toolbar span { color: var(--muted); font-size: .79rem; }
.merge-toolbar button { padding: 5px 8px; border: 1px solid #d9dfE8; border-radius: 7px; color: #4c6283; background: #f7f9fc; font: 600 .74rem monospace; }
.field-note { margin: -11px 0 0; color: var(--muted); font-size: .76rem; }
.check-list { padding: 0; margin: 19px 0; display: grid; gap: 12px; list-style: none; }
.check-list li { padding-left: 24px; color: #566277; line-height: 1.4; position: relative; }
.check-list li::before { content: '✓'; position: absolute; left: 0; color: var(--green); font-weight: 800; }
.notice { margin: 22px 0; padding: 15px; border-radius: 12px; color: #755f32; background: #fff7e7; }
.notice p { margin: 5px 0 0; font-size: .83rem; }

.campaign-hero { margin-bottom: 19px; padding: 22px 25px; border-radius: var(--radius); color: white; background: linear-gradient(130deg, var(--navy), #2c456f); display: flex; justify-content: space-between; gap: 20px; }
.campaign-hero > div > a { display: block; margin-bottom: 15px; color: #bfcbe0; font-size: .8rem; }
.campaign-hero p { margin: 5px 0 0; color: #c7d2e5; }
.campaign-actions { display: flex; align-items: center; gap: 9px; }

.inbox-layout { display: grid; grid-template-columns: minmax(310px, .85fr) minmax(420px, 1.4fr); gap: 18px; align-items: start; }
.message-list { max-height: calc(100vh - 210px); overflow-y: auto; }
.message-item { padding: 15px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; color: #5e6a7c; }
.message-item:hover, .message-item.selected { background: #f7f9fc; }
.message-item.unread { color: var(--ink); background: #fffaf8; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #536987; background: #e8edf5; font-weight: 800; }
.message-item strong, .message-item b, .message-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-item strong { font-size: .78rem; }
.message-item b { margin: 3px 0; font-size: .83rem; }
.message-item small { color: var(--muted); }
.message-item time { color: #8993a4; font-size: .68rem; white-space: nowrap; }
.message-reader { min-height: 520px; }
.reader-head { padding: 27px; border-bottom: 1px solid var(--line); }
.reader-head p { margin: 5px 0; color: var(--muted); font-size: .82rem; }
.reader-head time { display: block; margin-top: 11px; color: #8791a0; font-size: .75rem; }
.reader-body { padding: 30px; line-height: 1.72; white-space: normal; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-grid .card { padding: 25px; }
.settings-grid h2 { margin-bottom: 18px; }
dl { margin: 0; }
dl div { padding: 11px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-weight: 700; }
.variable-list { display: flex; flex-wrap: wrap; gap: 8px; }
.variable-list code { padding: 7px 9px; border-radius: 7px; color: #4c6283; background: #f0f4fa; }

.alert { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 11px; }
.alert-success { color: #226d55; border-color: #b9e4d3; background: #e9f7f1; }
.alert-error { color: #943f48; border-color: #efc1c5; background: #fcedee; }
.login-page { min-height: 100vh; background: var(--navy); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.login-copy { padding: 9vw; color: white; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 20% 80%, rgba(77,130,216,.23), transparent 33%), radial-gradient(circle at 70% 20%, rgba(239,114,95,.19), transparent 28%); }
.login-copy .brand-lockup { position: absolute; top: 42px; left: 5vw; }
.login-copy h1 { max-width: 700px; font-size: clamp(2.5rem, 5vw, 5rem); }
.login-copy > p:last-child { max-width: 590px; color: #b7c3d7; font-size: 1.08rem; }
.login-card { width: min(470px, calc(100% - 42px)); margin: auto; padding: 38px; border-radius: 24px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.login-card > div:first-child { margin-bottom: 24px; }
.stack { display: grid; gap: 17px; }
.public-page { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.public-card { width: min(560px, calc(100% - 36px)); padding: 50px; border-radius: 24px; background: white; text-align: center; box-shadow: var(--shadow); }
.public-card .brand-symbol { margin: 0 auto 22px; }
.public-card p { color: var(--muted); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .composer-layout { grid-template-columns: 1fr; }
  .composer-side { position: static; }
  .inbox-layout { grid-template-columns: 1fr; }
  .message-list { max-height: 440px; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: 250px; position: fixed; left: -270px; transition: left .22s ease; box-shadow: 18px 0 50px rgba(11,22,39,.25); }
  .sidebar.open { left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 18px; }
  .topbar > div { display: none; }
  .page-wrap { padding: 30px 18px 60px; }
  .page-heading, .toolbar { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .stats-grid, .settings-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .login-shell { display: block; padding: 28px 0 50px; }
  .login-copy { min-height: 44vh; padding: 70px 28px 35px; }
  .login-copy .brand-lockup { top: 24px; left: 28px; }
  .login-copy h1 { font-size: 2.7rem; }
  .login-card { padding: 27px; }
  .campaign-hero { flex-direction: column; }
}
