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

:root {
    --ink: #122d2a;
    --muted: #6f7f7d;
    --paper: #f3f5ef;
    --surface: #ffffff;
    --line: #e2e8e2;
    --green: #0f5d50;
    --green-2: #187766;
    --mint: #dcefe7;
    --amber: #e7a940;
    --amber-soft: #fff3d9;
    --danger: #b64a47;
    --danger-soft: #fdeceb;
    --shadow: 0 18px 50px rgba(23, 54, 48, .08);
    --radius: 20px;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); font-family: "Cairo", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { color: var(--green-2); font-size: 14px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.full, .full-width { width: 100%; grid-column: 1 / -1; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border: 1px solid transparent; border-radius: 12px; font-weight: 700; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--green); box-shadow: 0 10px 24px rgba(15, 93, 80, .18); }
.button-primary:hover { background: var(--green-2); }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }
.button-secondary:hover { border-color: var(--green-2); }
.button-light { background: white; color: var(--green); }
.button-danger { background: var(--danger-soft); color: var(--danger); border-color: #f3cbc8; }
.button-small { min-height: 40px; padding: 0 16px; font-size: 14px; }
.link-button { padding: 0; border: 0; color: var(--green-2); background: transparent; font-weight: 700; }

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup strong { font-size: 21px; }
.brand-lockup small { display: block; color: var(--muted); font-size: 13px; margin-top: -3px; }
.brand-mark { display: inline-grid; place-items: center; width: 43px; height: 43px; border-radius: 14px 14px 6px 14px; color: white; background: var(--green); font-size: 22px; font-weight: 800; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }

/* Login and installer */
.login-body, .setup-body { min-height: 100vh; background: var(--paper); }
.login-shell, .setup-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, .92fr) minmax(430px, 1.08fr); }
.login-copy, .setup-intro { position: relative; display: flex; flex-direction: column; justify-content: center; padding: clamp(46px, 7vw, 110px); overflow: hidden; color: white; background: var(--green); }
.login-copy::before, .setup-intro::before { content: ""; position: absolute; width: 500px; height: 500px; left: -220px; bottom: -220px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 80px rgba(255,255,255,.025), 0 0 0 160px rgba(255,255,255,.02); }
.login-copy .brand-lockup, .setup-intro .eyebrow { position: absolute; top: 45px; right: clamp(46px, 7vw, 110px); }
.login-copy .brand-mark { color: var(--green); background: white; }
.login-copy .eyebrow, .setup-intro .eyebrow { color: #a8d2c8; }
.login-copy > .eyebrow { position: static; }
.login-copy h1, .setup-intro h1 { position: relative; max-width: 650px; margin: 16px 0 18px; font-size: clamp(42px, 5vw, 74px); line-height: 1.08; letter-spacing: -.04em; }
.login-copy p, .setup-intro p { position: relative; max-width: 560px; color: #d7e6e2; font-size: 18px; line-height: 1.9; }
.privacy-note { position: absolute; right: clamp(46px, 7vw, 110px); bottom: 45px; color: #b8d3cd; font-size: 13px; }
.login-card, .setup-card { align-self: center; justify-self: center; width: min(460px, calc(100% - 48px)); padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.setup-card { width: min(650px, calc(100% - 48px)); }
.login-card h2, .setup-card h2 { margin: 24px 0 4px; font-size: 28px; }
.login-card > p { margin: 0 0 28px; color: var(--muted); }
.setup-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.setup-points span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: #d7e6e2; font-size: 14px; }

.form-stack, .form-grid { display: grid; gap: 18px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 8px; color: #314945; font-size: 15px; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; }
input, select { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #d9e1dc; border-radius: 11px; outline: 0; color: var(--ink); background: #fbfcfa; transition: .18s ease; }
input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(24,119,102,.1); background: white; }
.alert { margin: 16px 0; padding: 13px 16px; border-radius: 11px; font-size: 14px; }
.alert-error { color: #883a37; background: var(--danger-soft); border: 1px solid #f2cfcd; }
.alert-success { color: #1f6a59; background: var(--mint); border: 1px solid #c4e2d7; }

/* Main app */
.app-body { min-height: 100vh; background: var(--paper); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 20px; background: #f9faf7; border-left: 1px solid var(--line); z-index: 20; }
.sidebar .brand-lockup { padding: 0 10px 28px; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; min-height: 49px; padding: 0 14px; border-radius: 12px; color: #5e706d; font-size: 16px; font-weight: 600; transition: .18s ease; }
.sidebar nav a span { display: grid; place-items: center; width: 24px; height: 24px; font-size: 19px; }
.sidebar nav a:hover { color: var(--ink); background: #edf1ec; }
.sidebar nav a.active { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(15,93,80,.16); }
.sidebar-footer { margin-top: auto; display: grid; gap: 18px; padding: 18px 10px 0; border-top: 1px solid var(--line); }
.connection-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 700; }
.connection-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.connection-pill.ready i { background: #32a77d; box-shadow: 0 0 0 4px #dff3eb; }
.main-content { min-width: 0; padding: 0 clamp(22px, 4vw, 58px) 70px; }
.topbar { min-height: 116px; display: flex; align-items: center; gap: 20px; }
.topbar > div { margin-left: auto; }
.topbar h1 { margin: 3px 0 0; font-size: 25px; line-height: 1; }
.topbar .muted { font-size: 14px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 24px; }

.hero-panel { position: relative; min-height: 266px; display: grid; grid-template-columns: 1fr 230px; align-items: center; gap: 50px; padding: 42px 48px; overflow: hidden; color: white; border-radius: 26px; background: var(--green); box-shadow: var(--shadow); }
.hero-panel::before { content: ""; position: absolute; width: 290px; height: 290px; left: -80px; top: -85px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 50px rgba(255,255,255,.035), 0 0 0 100px rgba(255,255,255,.025); }
.hero-panel > * { position: relative; }
.hero-panel .eyebrow { color: #acd3ca; }
.hero-panel h2 { margin: 10px 0 8px; font-size: clamp(30px, 4vw, 48px); line-height: 1.2; letter-spacing: -.03em; }
.hero-panel p { max-width: 660px; margin: 0 0 22px; color: #d5e6e1; line-height: 1.8; }
.hero-meter { display: flex; flex-direction: column; justify-content: center; min-height: 170px; padding: 28px; border: 1px solid rgba(255,255,255,.16); border-radius: 22px; background: rgba(255,255,255,.08); backdrop-filter: blur(8px); }
.hero-meter span, .hero-meter small { color: #c7ded8; font-size: 14px; }
.hero-meter strong { margin: 8px 0 2px; font-size: 52px; line-height: 1; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
.stat-card { min-height: 126px; display: flex; flex-direction: column; justify-content: center; padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.stat-card span { color: var(--muted); font-size: 14px; font-weight: 700; }
.stat-card strong { margin: 5px 0; font-size: 30px; line-height: 1.1; }
.stat-card small { color: #8a9996; font-size: 13px; }
.stat-card small.positive { color: var(--green-2); }
.stats-grid.compact { margin-top: 0; }
.stats-grid.compact .stat-card { min-height: 105px; }

.content-grid, .settings-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 7px 24px rgba(23,54,48,.035); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 26px 16px; }
.panel-heading h3 { margin: 4px 0 0; font-size: 20px; }
.panel-heading > a { color: var(--green-2); font-size: 14px; font-weight: 700; }
.campaign-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 15px 26px; border-top: 1px solid #edf0ec; transition: .18s ease; }
.campaign-row:hover { background: #fafbf9; }
.campaign-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--green); background: var(--mint); font-size: 19px; }
.campaign-main { min-width: 0; }
.campaign-main strong, .campaign-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campaign-main small { margin-top: 2px; color: var(--muted); font-size: 13px; }
.progress { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e8ede9; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--green-2); }
.progress.large { height: 9px; }
.status { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 10px; border-radius: 999px; color: #506561; background: #edf1ee; font-size: 13px; font-weight: 800; white-space: nowrap; }
.status-running, .status-delivered, .status-read, .status-completed { color: #176550; background: #def2e9; }
.status-paused, .status-pending, .status-sending { color: #91621d; background: var(--amber-soft); }
.status-failed, .status-cancelled { color: #9a3e3a; background: var(--danger-soft); }
.status-sent { color: #316686; background: #e5f1f8; }
.checklist { display: grid; gap: 22px; margin: 8px 26px 25px; padding: 0; list-style: none; }
.checklist li { display: flex; gap: 13px; align-items: center; }
.checklist i { display: grid; place-items: center; flex: 0 0 31px; height: 31px; border: 1px solid #d8dfda; border-radius: 50%; color: #879591; font-style: normal; font-size: 12px; font-weight: 800; }
.checklist li.done i { color: white; border-color: var(--green-2); background: var(--green-2); }
.checklist strong, .checklist small { display: block; }
.checklist strong { font-size: 15px; }
.checklist small { color: var(--muted); font-size: 13px; }
.readiness-panel .button { margin: 0 26px 26px; width: calc(100% - 52px); }
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 30px; color: var(--amber); }
.empty-state h4 { margin: 10px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; font-size: 15px; }

/* Wizard */
.wizard-shell { max-width: 1060px; margin: 0 auto; }
.wizard-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.wizard-head h2 { margin: 6px 0; font-size: 32px; }
.wizard-head p { margin: 0; color: var(--muted); }
.step-indicator { display: flex; align-items: center; direction: ltr; }
.step-indicator span { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #d7dfda; border-radius: 50%; color: #8d9a97; background: white; font-size: 12px; font-weight: 800; }
.step-indicator span.active { color: white; border-color: var(--green); background: var(--green); }
.step-indicator i { width: 32px; height: 1px; background: #d7dfda; }
.upload-zone { min-height: 300px; display: grid; place-items: center; padding: 28px; border: 1.5px dashed #aabbb6; border-radius: 24px; background: rgba(255,255,255,.6); transition: .2s ease; }
.upload-zone.dragging { border-color: var(--green); background: var(--mint); }
.upload-zone label { display: flex; align-items: center; flex-direction: column; text-align: center; cursor: pointer; }
.upload-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 18px; border-radius: 20px; color: var(--green); background: var(--mint); font-size: 30px; }
.upload-zone strong { font-size: 19px; }
.upload-zone small { margin-top: 7px; color: var(--muted); font-weight: 400; }
.mapping-section { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: white; }
.import-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 24px; border-bottom: 1px solid var(--line); background: #f8faf7; }
.import-summary > div { display: grid; grid-template-columns: 38px auto; column-gap: 12px; }
.import-summary strong, .import-summary small { grid-column: 2; }
.import-summary small { color: var(--muted); font-size: 14px; }
.success-dot { grid-row: 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: white; background: var(--green-2); }
.campaign-form { padding: 26px; }
.preview-table-wrap { max-height: 270px; margin-top: 24px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-actions p { margin: 0; color: var(--muted); font-size: 14px; }

/* Tables and detail */
.table-panel { overflow: hidden; }
.responsive-table { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: right; font-size: 15px; }
.data-table th { padding: 13px 18px; color: #758682; background: #f7f9f6; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.data-table td { padding: 15px 18px; border-bottom: 1px solid #edf0ec; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.count-badge { padding: 6px 10px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 14px; font-weight: 800; }
.campaign-overview { display: grid; gap: 18px; }
.campaign-title-card, .progress-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 26px 30px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.campaign-title-card h2 { margin: 10px 0 3px; }
.campaign-title-card p { margin: 0; color: var(--muted); }
.campaign-title-card code { padding: 3px 6px; border-radius: 5px; background: #f0f3ef; }
.detail-actions { display: flex; align-items: center; gap: 10px; }
.progress-card { display: grid; grid-template-columns: 170px 1fr; }
.progress-card > div:first-child { display: flex; justify-content: space-between; }
.error-cell { max-width: 340px; color: var(--danger); font-size: 13px; }

/* Settings */
.settings-form { padding-bottom: 26px; }
.settings-form > .form-grid { padding: 8px 26px; }
.settings-form .form-actions { margin: 24px 26px 0; }
.integration-card { padding: 26px; }
.integration-card h3 { margin: 5px 0 24px; }
.integration-card label { margin-top: 18px; }
.integration-card code { display: block; padding: 12px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 10px; color: #2c6057; background: #f6f9f6; direction: ltr; text-align: left; font-size: 13px; font-weight: 500; }
.integration-card p { margin: 20px 0 0; padding: 13px; color: #75551f; border-radius: 10px; background: var(--amber-soft); font-size: 14px; line-height: 1.8; }

.toast { position: fixed; left: 28px; bottom: 28px; max-width: 430px; padding: 14px 18px; opacity: 0; pointer-events: none; transform: translateY(10px); color: white; border-radius: 12px; background: var(--ink); box-shadow: var(--shadow); transition: .22s ease; z-index: 100; font-size: 15px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid, .settings-grid { grid-template-columns: 1fr; }
    .hero-panel { grid-template-columns: 1fr 190px; }
}

@media (max-width: 760px) {
    .login-shell, .setup-shell { display: block; }
    .login-copy, .setup-intro { min-height: 40vh; padding: 80px 28px 50px; }
    .login-copy .brand-lockup, .setup-intro .eyebrow { top: 24px; right: 28px; }
    .login-copy h1, .setup-intro h1 { font-size: 40px; }
    .privacy-note { display: none; }
    .login-card, .setup-card { width: calc(100% - 28px); margin: -20px auto 30px; padding: 28px; position: relative; }
    .form-grid { grid-template-columns: 1fr; }
    .app-shell { display: block; }
    .sidebar { position: fixed; right: 0; width: 260px; transform: translateX(105%); transition: .25s ease; box-shadow: -20px 0 50px rgba(0,0,0,.12); }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 0 16px 45px; }
    .menu-button { display: block; }
    .topbar { min-height: 90px; }
    .topbar .button { display: none; }
    .hero-panel { min-height: auto; grid-template-columns: 1fr; padding: 30px 24px; }
    .hero-meter { min-height: 120px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { min-height: 108px; padding: 16px; }
    .stat-card strong { font-size: 25px; }
    .wizard-head { display: block; }
    .step-indicator { margin-top: 18px; }
    .form-actions, .campaign-title-card, .detail-actions { align-items: stretch; flex-direction: column; }
    .progress-card { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .campaign-row { grid-template-columns: 38px minmax(0,1fr); padding: 14px 16px; }
    .campaign-row .status { grid-column: 2; justify-self: start; }
    .panel-heading { padding-inline: 18px; }
}
