:root {
    --navy: #101828;
    --navy-2: #1d2939;
    --ink: #101828;
    --muted: #667085;
    --line: #eaecf0;
    --paper: #f8f9fc;
    --card: #ffffff;
    --accent: #a512b8;
    --accent-2: #7a0d8c;
    --teal: #0e9f90;
    --gold: #dc6803;
    --ok: #067647;
    --ok-bg: #ecfdf3;
    --warn: #b54708;
    --warn-bg: #fffaeb;
    --err: #b42318;
    --err-bg: #fef3f2;
    --info: #175cd3;
    --info-bg: #eff8ff;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.04);
    --sidebar: 272px;
    --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
#hpc { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    background: rgba(248, 249, 252, 0.72);
    backdrop-filter: blur(6px);
    color: var(--muted);
}
.page-loader[hidden] { display: none; }
.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid #ead7f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #0b1220 0%, #151b2b 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    padding: 8px 8px 20px;
    text-decoration: none;
}
.brand img { width: 78px; background: #fff; border-radius: 10px; padding: 5px; }
.brand strong, .brand small { display: block; }
.brand small { color: #98a2b3; font-size: 11px; }

.side-nav { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.nav-link, .nav-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: #d0d5dd;
    background: transparent;
    border: 0;
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}
.nav-link svg, .nav-toggle svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.nav-link.is-active, .nav-link:hover, .nav-toggle:hover { background: rgba(165, 18, 184, 0.22); color: #fff; text-decoration: none; }
.caret { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.nav-group.is-open > .nav-toggle .caret { transform: rotate(225deg); }
.nav-sub { display: none; padding: 4px 0 8px 18px; }
.nav-group.is-open .nav-sub { display: grid; gap: 2px; }
.nav-sub a { color: #98a2b3; padding: 7px 12px; border-radius: 10px; text-decoration: none; font-size: 12px; }
.nav-sub a.is-active, .nav-sub a:hover { color: #fff; background: rgba(255,255,255,.06); }

.side-foot { margin-top: auto; padding: 16px 8px 8px; border-top: 1px solid rgba(255,255,255,.08); }
.version { color: #98a2b3; font-size: 11px; letter-spacing: .04em; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.topbar h1 { margin: 2px 0 0; font-size: 18px; }
.icon-btn, .profile-btn {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    cursor: pointer;
}
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.menu-btn { display: none; }

.top-search { position: relative; }
.top-search svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; fill: var(--muted); }
.top-search input {
    width: 240px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px 10px 34px;
    background: #fff;
}

.profile-menu { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), #5b21b6);
    color: #fff; font-size: 11px; font-weight: 700;
}
.profile-copy { text-align: left; }
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 13px; }
.profile-copy small { color: var(--muted); text-transform: capitalize; font-size: 11px; }
.profile-drop {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 240px; background: #fff; border: 1px solid var(--line);
    border-radius: 14px; box-shadow: var(--shadow); padding: 8px; z-index: 30;
}
.profile-drop-head { display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.profile-drop-head small { color: var(--muted); word-break: break-all; }
.profile-drop a, .profile-drop button {
    display: block; width: 100%; text-align: left; border: 0; background: transparent;
    padding: 8px 10px; border-radius: 10px; color: var(--ink); cursor: pointer; text-decoration: none;
    font-size: 13px;
}
.profile-drop a:hover, .profile-drop button:hover { background: var(--paper); }

.app-content { padding: 24px 28px 12px; display: flex; flex-direction: column; gap: 18px; }
.app-footer { margin-top: auto; padding: 16px 28px 24px; color: var(--muted); display: flex; justify-content: space-between; font-size: 11px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 14px; }
.card-sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.kpi-grid, .grid-2 { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plan-features-title { margin: 16px 0 8px; font-size: 13px; }
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.kpi { position: relative; overflow: hidden; }
.kpi strong { font-size: 22px; display: block; margin: 8px 0 4px; }
.kpi p, .kpi small { margin: 0; color: var(--muted); }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%; opacity: .12; }
.kpi-violet::after { background: var(--accent); }
.kpi-navy::after { background: #3538cd; }
.kpi-teal::after { background: var(--teal); }
.kpi-gold::after { background: var(--gold); }

.chart-wrap { height: 240px; }
.chart-wrap-donut { height: 260px; }
.chart { width: 100%; height: 100%; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fbfafe; }
.empty { color: var(--muted); text-align: center; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 7px; font-size: 11px; text-transform: capitalize; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-muted, .badge-info { background: var(--info-bg); color: var(--info); }

.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.details dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }

.toolbar, .page-actions, .search, .form-actions { display: flex; gap: 10px; align-items: center; }
.filter-card { padding: 16px; }
.filter-form {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) repeat(6, minmax(110px, 1fr)) auto;
    gap: 10px;
    align-items: end;
}
.filter-form label { display: block; margin: 0 0 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.filter-form select, .filter-form input[type="search"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
}
.filter-actions { display: flex; gap: 8px; align-items: center; }
.search { width: 100%; }
.search input, .stack-form input, .stack-form select, input[type="email"], input[type="password"], input[type="search"], input[type="text"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
}
.status-form { display: flex; gap: 8px; align-items: center; }
.status-form select {
    min-width: 120px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
}
.photo-cell, .passport-wrap { display: flex; align-items: flex-end; gap: 8px; }
.passport-photo {
    width: 98px;
    height: 126px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f2f4f7;
    display: block;
}
.passport-photo-sm { width: 42px; height: 54px; border-radius: 5px; }
.passport-empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
    padding: 4px;
    font-weight: 600;
}
.details-photo { grid-column: 1 / -1; }
.icon-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}
.icon-download svg { width: 16px; height: 16px; fill: currentColor; }
.icon-download:hover { text-decoration: none; color: var(--accent-2); }
.stack-form label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 12px; }
.form-card { max-width: 680px; }
.form-actions { margin-top: 18px; }
.btn-primary, .btn-secondary, .link-btn {
    border: 0; border-radius: 12px; padding: 11px 14px; cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-inline { width: auto; }
.btn-secondary { background: #f2e9f7; color: var(--ink); text-decoration: none; }
.link-btn { background: transparent; color: #fff; }

.alert { border-radius: 12px; padding: 12px 14px; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.pager {
    display: flex;
    justify-content: flex-end;
    padding-top: 14px;
}
.pager-nav { width: 100%; display: flex; justify-content: flex-end; }
.pagination {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
}
.pagination a:hover { background: var(--paper); text-decoration: none; }
.pagination .is-active span, .pagination .active a {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.filter-form-compact { grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(120px, 1fr)) auto; }
.link-action {
    border: 0;
    background: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.drawer[hidden] { display: none; }
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.45); }
.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(420px, 92vw);
    background: #fff;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; }
.drawer-body { padding: 16px 18px; overflow: auto; }
.drawer-body .details { grid-template-columns: 1fr; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top left, rgba(165,18,184,.16), transparent 36%), var(--paper);
}
.auth-shell {
    width: min(920px, 94vw);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.auth-brand {
    background: linear-gradient(180deg, #101828, #1d1028);
    color: #fff;
    padding: 40px 36px;
}
.auth-brand img { width: 180px; background: #fff; border-radius: 12px; padding: 8px; }
.auth-brand h1 { margin: 28px 0 12px; font-size: 22px; }
.auth-brand p, .auth-brand li { color: #d0d5dd; font-size: 13px; }
.auth-card { padding: 40px 36px; }
.auth-card h2 { margin: 6px 0 8px; font-size: 20px; }
.auth-card label { font-size: 12px; font-weight: 600; display: block; margin: 12px 0 6px; }
.muted { color: var(--muted); }
.auth-card .btn-primary { width: 100%; margin-top: 18px; }

.wa-template-list { display: flex; flex-direction: column; gap: 12px; }
.wa-template-row {
    display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
    padding: 14px 0; border-bottom: 1px solid var(--line);
}
.wa-template-row:last-child { border-bottom: 0; }
.wa-template-copy { min-width: 0; }
.wa-template-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.wa-template-meta h3 { margin: 0; font-size: 14px; }
.wa-template-body { margin: 0 0 8px; color: var(--ink); white-space: pre-wrap; }
.wa-vars { margin: 0; color: var(--muted); font-size: 12px; }
.wa-vars code { background: #f2e9f7; padding: 2px 6px; border-radius: 6px; margin-right: 4px; }
.wa-compose { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.wa-phone-label { margin: 0 0 12px; font-weight: 700; }
.wa-phone {
    width: 280px; margin: 0 auto; background: #0b141a; border-radius: 28px; padding: 10px 10px 16px;
    box-shadow: inset 0 0 0 2px #1f2c34;
}
.wa-phone-notch { width: 92px; height: 8px; background: #1f2c34; border-radius: 8px; margin: 4px auto 10px; }
.wa-phone-bar {
    display: flex; gap: 10px; align-items: center; background: #008069; color: #fff;
    border-radius: 10px 10px 0 0; padding: 10px 12px;
}
.wa-phone-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: #25d366; display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.wa-phone-bar small { display: block; opacity: .8; font-size: 10px; }
.wa-phone-chat { min-height: 340px; background: #0b141a url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><circle cx="4" cy="4" r="1" fill="%231a2a32"/></svg>'); padding: 14px 10px; border-radius: 0 0 10px 10px; }
.wa-bubble {
    max-width: 92%; background: #005c4b; color: #e9edef; border-radius: 8px 8px 2px 8px; padding: 8px 10px 18px;
    position: relative; margin-left: auto; font-size: 12px; line-height: 1.45; white-space: pre-wrap;
}
.wa-bubble-header { margin: 0 0 6px; font-weight: 700; }
.wa-bubble-body, .wa-bubble-footer { margin: 0 0 6px; }
.wa-bubble-footer { opacity: .75; font-size: 11px; }
.wa-bubble-time { position: absolute; right: 8px; bottom: 4px; font-size: 10px; opacity: .7; }
.wa-chip { background: rgba(255,255,255,.08); border-radius: 8px; padding: 6px 8px; margin-top: 6px; text-align: center; color: #53bdeb; }
.wa-fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 16px; margin: 0 0 16px; }
.wa-fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 700; }
.wa-textarea, .stack-form textarea, input[type="url"], input[type="file"] {
    width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; font: inherit;
}
.wa-progress { margin-top: 18px; }
.wa-progress-head, .wa-progress-counts { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 8px; }
.wa-progress-track { height: 10px; background: #f2e9f7; border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.wa-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.wa-log { list-style: none; margin: 10px 0 0; padding: 0; max-height: 180px; overflow: auto; }
.wa-log li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.wa-log-success { color: var(--ok); }
.wa-log-failed { color: var(--err); }
.wa-log-skipped { color: var(--warn); }
.kpi-text { font-size: 14px !important; word-break: break-word; }
.wa-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.wa-steps li {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
    background: #f8f9fc; color: var(--muted); font-size: 12px; font-weight: 600;
}
.wa-steps li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d0d5dd; }
.wa-steps li.is-active { background: #eff8ff; color: var(--info); }
.wa-steps li.is-active::before { background: var(--info); }
.wa-steps li.is-done { background: var(--ok-bg); color: var(--ok); }
.wa-steps li.is-done::before { background: var(--ok); }
.wa-steps li.is-error { background: var(--err-bg); color: var(--err); }
.wa-steps li.is-error::before { background: var(--err); }
.wa-log-info { color: var(--info); }
.filter-form input[type="date"] {
    width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff;
}
.wa-thread { display: flex; flex-direction: column; gap: 10px; min-height: 360px; background: #0b141a; border-radius: 14px; padding: 16px; }
.wa-msg { display: flex; }
.wa-msg-inbound { justify-content: flex-start; }
.wa-msg-outbound { justify-content: flex-end; }
.wa-msg-bubble {
    max-width: min(78%, 520px); padding: 8px 10px; border-radius: 10px; color: #e9edef; font-size: 13px; line-height: 1.45;
    white-space: pre-wrap;
}
.wa-msg-inbound .wa-msg-bubble { background: #202c33; border-bottom-left-radius: 3px; }
.wa-msg-outbound .wa-msg-bubble { background: #005c4b; border-bottom-right-radius: 3px; }
.wa-msg-bubble p { margin: 0 0 8px; }
.wa-msg-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 11px; opacity: .85; }
.wa-count {
    display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 12px;
    background: #f2e9f7; color: var(--ink); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.wa-action-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.wa-countdown {
    font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 700; color: var(--warn);
    background: var(--warn-bg); border-radius: 999px; padding: 3px 8px;
}

/* ── Coupon form inputs ── */
.form-input {
    width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
    font: inherit; font-size: 13px; background: #fff; color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(165,18,184,.1); }
.text-muted { color: var(--muted); font-size: 11px; }
.coupon-toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 1000;
    padding: 11px 22px; border-radius: 10px; font-size: 13px; font-weight: 600;
    box-shadow: 0 4px 18px rgba(0,0,0,.15); white-space: nowrap;
}
.coupon-toast[hidden] { display: none; }
.coupon-toast-ok  { background: #ecfdf3; color: var(--ok); border: 1px solid #a3e6c3; }
.coupon-toast-err { background: var(--err-bg); color: var(--err); border: 1px solid #f9b9b7; }

/* ── Badge: neutral / inactive ── */
.badge-neutral { background: #f2f4f7; color: var(--muted); }

/* ── Code tag inline ── */
.code-tag { font-family: monospace; background: #f3f4f6; border-radius: 4px;
            padding: 1px 6px; font-size: 13px; color: var(--ink); }

/* ── Form helpers ── */
.req { color: var(--err); }
.form-hint { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group[hidden], .btn-spinner[hidden] { display: none; }
.page-actions-split { justify-content: space-between; flex-wrap: wrap; }
.page-actions-split h2 { margin: 0; font-size: 16px; }
.filter-form-coupon { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--accent); }
.btn-primary-inline { display: inline-flex; align-items: center; gap: 6px; }
.modal-body .form-input, .form-grid-2 .form-input { padding: 10px 12px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

/* ── Button spinner ── */
.btn-spinner {
    display: inline-block; width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite; vertical-align: middle; margin-right: 5px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal overlay ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 16px; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: #fff; border-radius: 20px; width: 100%; max-width: 680px;
    box-shadow: 0 24px 64px rgba(0,0,0,.18); position: relative;
    animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--line);
}
.modal-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.modal-close {
    border: 0; background: transparent; cursor: pointer;
    font-size: 18px; color: var(--muted); line-height: 1;
    padding: 4px 8px; border-radius: 6px; transition: background .15s;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 12px 24px 20px;
    border-top: 1px solid var(--line);
}

/* ── Reseller coupon cards ── */
.rc-cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 680px) { .rc-cards-grid { grid-template-columns: 1fr; } }

.rc-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.rc-card-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.rc-card-icon { width: 36px; height: 36px; color: var(--accent); flex-shrink: 0; }
.rc-card-icon svg { width: 36px; height: 36px; }
.rc-card-title { font-size: 15px; font-weight: 700; margin: 0; flex: 1; }
.rc-card-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rc-card-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.rc-card-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; margin: 0; }

/* Each individual coupon inside a card */
.rc-coupon-item {
    border-radius: 12px; border: 1.5px solid var(--line);
    overflow: hidden;
}
.rc-coupon-item-active { border-color: #a3e6c3; background: #f6fef9; }
.rc-coupon-item-inactive { border-color: #e4e7ec; background: #f9fafb; }
.rc-coupon-item-expired { border-color: #fedf89; background: #fffcf0; }

.rc-coupon-item-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-bottom: 1px solid inherit;
}
.rc-coupon-item-active .rc-coupon-item-head  { border-bottom-color: #a3e6c3; }
.rc-coupon-item-inactive .rc-coupon-item-head { border-bottom-color: #e4e7ec; }
.rc-coupon-item-expired .rc-coupon-item-head  { border-bottom-color: #fedf89; }

.rc-code { font-size: 15px; font-weight: 700; font-family: monospace; letter-spacing: .06em; }
.rc-coupon-item-active .rc-code  { color: var(--ok); }
.rc-coupon-item-inactive .rc-code { color: var(--muted); }
.rc-coupon-item-expired .rc-code  { color: var(--warn); }

.rc-coupon-details { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; padding: 12px 14px; }
.rc-detail-row { display: flex; flex-direction: column; gap: 2px; }
.rc-detail-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.rc-detail-value { font-size: 13px; font-weight: 600; color: var(--ink); }
.rc-detail-date { font-size: 11px; font-weight: 500; }

/* Skeleton */
.rc-card-skeleton { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.rc-sk-line { height: 14px; background: linear-gradient(90deg, #f2f4f7 25%, #e4e7ec 50%, #f2f4f7 75%); border-radius: 6px; animation: rcShimmer 1.4s infinite; }
.rc-sk-title { height: 18px; width: 60%; }
.rc-sk-short { width: 40%; }
@keyframes rcShimmer { 0%{background-position:-400px 0} 100%{background-position:400px 0} }
.rc-order-skeleton { display: flex; flex-direction: column; gap: 8px; }
.rc-sk-row { height: 40px; background: linear-gradient(90deg,#f2f4f7 25%,#e4e7ec 50%,#f2f4f7 75%); border-radius: 8px; animation: rcShimmer 1.4s infinite; background-size: 800px 100%; }

/* ── Support chat page (scoped to .wa-chat-wrapper; gallery thread keeps its own look) ── */
.wa-chat-wrapper { display: flex; flex-direction: column; gap: 0; }

.wa-chat-header {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 20px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.wa-back-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.wa-chat-contact-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.wa-chat-avatar-lg {
    width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff;
    font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wa-chat-contact-name { font-size: 15px; font-weight: 700; }
.wa-chat-phone { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.wa-chat-header-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.wa-chat-wrapper .wa-chat-body {
    background: #eef0f4; overflow-y: auto; height: 60vh; min-height: 320px;
    padding: 14px 18px; display: flex; flex-direction: column;
    border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.wa-chat-wrapper #waMessagesContainer { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.wa-load-more-bar { text-align: center; padding: 4px 0 12px; }

.wa-chat-wrapper .wa-date-sep { text-align: center; margin: 10px 0 4px; user-select: none; }
.wa-chat-wrapper .wa-date-sep span {
    background: #fff; color: var(--muted); font-size: 11px; border: 1px solid var(--line);
    border-radius: 999px; padding: 2px 10px;
}

/* Compact white bubbles: size follows the content, never stretches */
.wa-chat-wrapper .wa-msg { display: flex; margin: 0; }
.wa-chat-wrapper .wa-msg-inbound  { justify-content: flex-start; }
.wa-chat-wrapper .wa-msg-outbound { justify-content: flex-end; }
.wa-chat-wrapper .wa-msg-bubble {
    position: relative; display: inline-block; width: fit-content; max-width: min(68%, 520px);
    padding: 6px 10px 4px; border-radius: 10px; background: #fff; color: #111b21;
    font-size: 13px; line-height: 1.4; white-space: normal; word-break: break-word;
    border: 1px solid #e3e6ec; box-shadow: 0 1px 1px rgba(16, 24, 40, .05);
}
.wa-chat-wrapper .wa-msg-inbound  .wa-msg-bubble { border-top-left-radius: 2px; }
.wa-chat-wrapper .wa-msg-outbound .wa-msg-bubble { border-top-right-radius: 2px; border-right: 3px solid #25a56a; }
.wa-chat-wrapper .wa-msg-selected .wa-msg-bubble { outline: 2px solid var(--accent); outline-offset: 1px; }
.wa-chat-wrapper .wa-msg-text { margin: 0; white-space: pre-wrap; }

.wa-chat-wrapper .wa-msg-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 6px;
    margin-top: 1px; font-size: 10.5px; color: #667781; min-height: 16px;
}
.wa-chat-wrapper .wa-msg-time { white-space: nowrap; }
.wa-chat-wrapper .wa-tick { font-size: 12px; color: #8696a0; }
.wa-chat-wrapper .wa-tick-read { color: #2f9fe0; }
.wa-chat-wrapper .wa-tick-failed { color: var(--err); font-weight: 700; }

/* Reply button: appears on hover (always visible on touch devices) */
.wa-reply-btn {
    margin-right: auto; padding: 0 4px; border: 0; background: transparent; color: var(--accent);
    font-size: 11px; font-weight: 600; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.wa-chat-wrapper .wa-msg:hover .wa-reply-btn,
.wa-reply-btn:focus-visible { opacity: 1; }
.wa-reply-btn:hover { text-decoration: underline; }
@media (hover: none) { .wa-reply-btn { opacity: 1; } }

/* Quoted message inside a bubble */
.wa-quote {
    display: flex; flex-direction: column; gap: 1px; margin: 0 0 4px; padding: 4px 8px;
    border-left: 3px solid #25a56a; border-radius: 4px; background: #f2f4f7; font-size: 12px;
}
.wa-quote-in { border-left-color: var(--accent); }
.wa-quote b { font-size: 11px; color: #3b4a54; }
.wa-quote span { color: #54656f; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Media */
.wa-chat-img   { max-width: 240px; max-height: 200px; border-radius: 6px; display: block; margin: 0 0 4px; }
.wa-chat-video { max-width: 240px; border-radius: 6px; display: block; margin: 0 0 4px; }
.wa-chat-audio { max-width: 240px; display: block; margin: 0 0 4px; }
.wa-chat-file  { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13px; margin-bottom: 4px; }
.wa-chat-caption { margin: 0 0 2px; font-size: 12.5px; color: #3b4a54; }
.wa-chat-empty { text-align: center; color: var(--muted); margin: 40px 0; font-size: 13px; }

/* Composer (sticky bottom) */
.wa-chat-composer {
    position: sticky; bottom: 0; z-index: 5; background: #fff;
    border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
}
.wa-reply-bar {
    display: flex; align-items: center; gap: 10px; padding: 8px 16px;
    background: #f7f8fa; border-bottom: 1px solid var(--line); border-left: 4px solid var(--accent);
}
.wa-reply-bar[hidden] { display: none; }
.wa-reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; }
.wa-reply-bar-body b { color: var(--accent); font-size: 11px; }
.wa-reply-bar-body span { color: #54656f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-reply-cancel { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 6px; }
.wa-reply-cancel:hover { color: var(--ink); }

.wa-chat-input-wrap { display: flex; align-items: flex-end; gap: 12px; padding: 12px 16px; background: #fff; }
.wa-chat-textarea {
    flex: 1; min-height: 56px; max-height: 140px; padding: 12px 14px; resize: none;
    border: 1px solid #d0d5dd; border-radius: 12px; background: #fff; color: var(--ink);
    font: inherit; font-size: 14px; line-height: 1.45; outline: none;
}
.wa-chat-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(165, 18, 184, .12); }
.wa-chat-send-btn {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.wa-chat-send-btn:hover { background: var(--accent-2); }
.wa-chat-send-btn:disabled { opacity: .5; cursor: default; }

.wa-chat-closed {
    display: flex; align-items: center; gap: 14px; padding: 14px 20px; background: #fff; color: var(--muted);
    border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); font-size: 13px;
}
.wa-chat-closed p { margin: 0; }

.wa-chat-error-toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 999;
    background: var(--err); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px;
    white-space: nowrap; box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.wa-chat-error-toast[hidden] { display: none; }

/* ══ PA Calling page ═══════════════════════════════════════════════════════ */

/* Hero banner */
.cl-hero {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 50%, #a519c0 100%);
    border-radius: 16px; padding: 28px 32px; margin-bottom: 28px; position: relative; overflow: hidden;
}
.cl-hero::before {
    content: ''; position: absolute; top: -40px; right: -40px;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgba(255,255,255,.06); pointer-events: none;
}
.cl-hero::after {
    content: ''; position: absolute; bottom: -60px; right: 80px;
    width: 160px; height: 160px; border-radius: 50%;
    background: rgba(255,255,255,.04); pointer-events: none;
}
.cl-hero-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: rgba(255,255,255,.15); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: #fff;
}
.cl-hero-icon svg { width: 28px; height: 28px; }
.cl-hero-text { flex: 1; min-width: 0; }
.cl-hero-title { font-size: 22px; font-weight: 800; color: #fff; margin: 0 0 4px; letter-spacing: -.3px; }
.cl-hero-sub   { font-size: 13px; color: rgba(255,255,255,.75); margin: 0; }
.cl-hero-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fef3c7; color: #92400e;
    border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 600;
    white-space: nowrap; flex-shrink: 0;
}

/* Centered card wrapper */
.cl-wrap { display: flex; justify-content: center; }
.cl-card {
    width: 100%; max-width: 520px;
    background: #fff; border-radius: 20px;
    border: 1px solid var(--line);
    box-shadow: 0 4px 24px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
    padding: 32px;
}

/* Card header */
.cl-card-head   { margin-bottom: 28px; }
.cl-card-title  { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.cl-card-sub    { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* Fields */
.cl-fields { display: flex; flex-direction: column; gap: 22px; margin-bottom: 22px; }
.cl-field   { display: flex; flex-direction: column; gap: 8px; }
.cl-field-label { display: flex; align-items: center; gap: 10px; }
.cl-step {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    background: var(--accent); color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.cl-label      { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; cursor: pointer; }
.cl-label-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }

/* Phone input */
.cl-phone-wrap {
    display: flex; align-items: stretch;
    border: 1.5px solid var(--line); border-radius: 12px;
    overflow: hidden; background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.cl-phone-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
.cl-phone-flag {
    display: flex; align-items: center; gap: 7px;
    padding: 0 14px; background: #f8f7fb;
    border-right: 1.5px solid var(--line);
    flex-shrink: 0; user-select: none;
}
.cl-phone-flag svg { border-radius: 2px; }
.cl-phone-cc   { font-size: 14px; font-weight: 700; color: var(--text); }
.cl-phone-input {
    flex: 1; border: none; outline: none; background: transparent;
    padding: 13px 16px; font-size: 16px; font-weight: 500;
    color: var(--text); letter-spacing: .5px;
    font-family: inherit;
}
.cl-phone-input::placeholder { color: #bbb; font-weight: 400; letter-spacing: 0; font-size: 14px; }

/* Error */
.cl-error {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 11px 14px; border-radius: 10px; margin-bottom: 16px;
    background: #fff1f2; border: 1px solid #fca5a5; color: #b91c1c; font-size: 13px;
}
.cl-error svg { flex-shrink: 0; margin-top: 1px; }

/* CTA button */
.cl-cta-btn {
    width: 100%; padding: 15px 20px; border-radius: 12px; border: none; cursor: pointer;
    background: linear-gradient(135deg, #7c3aed, #a519c0);
    color: #fff; font-size: 16px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: opacity .15s, transform .1s, box-shadow .15s;
    box-shadow: 0 4px 14px rgba(124,58,237,.35);
    font-family: inherit; letter-spacing: .2px;
}
.cl-cta-btn:hover:not(:disabled) { opacity: .93; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,.4); }
.cl-cta-btn:active:not(:disabled) { transform: translateY(0); }
.cl-cta-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Info box */
.cl-info-box {
    margin-top: 24px; border-radius: 12px;
    background: #f8f7fb; border: 1px solid #e9e6f5;
    padding: 16px 18px;
}
.cl-info-head {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 700; color: #5b21b6; margin-bottom: 12px;
}
.cl-info-head svg { color: #7c3aed; flex-shrink: 0; }
.cl-info-steps {
    margin: 0; padding-left: 20px;
    display: flex; flex-direction: column; gap: 7px;
}
.cl-info-steps li { font-size: 13px; color: var(--text); line-height: 1.5; }

/* Success panel */
.cl-success-panel { text-align: center; padding: 8px 0; }
.cl-success-ring {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px; color: #059669;
    box-shadow: 0 4px 18px rgba(5,150,105,.2);
}
.cl-success-title { font-size: 22px; font-weight: 800; margin: 0 0 8px; color: var(--text); }
.cl-success-sub   { font-size: 14px; color: var(--text-muted); margin: 0 0 28px; line-height: 1.6; }

/* Step progress items */
.cl-success-steps { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-bottom: 6px; }
.cl-ss-item { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text); }
.cl-ss-dot  {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.cl-ss-done    { background: #d1fae5; color: #059669; }
.cl-ss-active  { background: #dbeafe; color: #2563eb; animation: clPulse 1.4s ease-in-out infinite; }
.cl-ss-pending { background: #f3f4f6; color: #9ca3af; }
@keyframes clPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.3); }
    50%       { box-shadow: 0 0 0 6px rgba(37,99,235,.0); }
}

/* Again button */
.cl-again-btn {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 20px;
    padding: 11px 22px; border-radius: 10px; border: 1.5px solid var(--line);
    background: #fff; color: var(--text); font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s;
}
.cl-again-btn:hover { border-color: var(--accent); background: #faf8ff; }

/* Responsive */
@media (max-width: 580px) {
    .cl-hero { padding: 20px; gap: 12px; }
    .cl-hero-title { font-size: 18px; }
    .cl-hero-badge { display: none; }
    .cl-card { padding: 22px 18px; border-radius: 14px; }
}

/* ── WhatsApp support export button & modal ────────────────────── */
.filter-actions-sep { flex: 1; }
.wa-export-err {
    margin-top: 12px; padding: 10px 14px; border-radius: 8px;
    background: #fff1f2; border: 1px solid #fca5a5;
    color: #b91c1c; font-size: 13px; line-height: 1.5;
}

/* ── Reseller coupon filter row ────────────────────────────────── */
.rc-filter-row {
    display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
    padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.rc-filter-field { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 4px; }
.rc-filter-label { font-size: 11px; font-weight: 600; color: var(--text-muted, var(--muted)); text-transform: uppercase; letter-spacing: .4px; margin: 0; }
.rc-filter-actions { display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }

/* ── Assign-to picker ──────────────────────────────────────────── */
.assign-picker-wrap { position: relative; display: flex; align-items: center; gap: 4px; }
.assign-picker-input { flex: 1; }
.assign-picker-clear {
    flex-shrink: 0; background: none; border: 1px solid var(--line); border-radius: 6px;
    cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 2px 7px;
    line-height: 1.6; transition: background .15s;
}
.assign-picker-clear:hover { background: var(--bg-hover, #f3f3f3); color: var(--text); }
.assign-picker-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 200;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.14); max-height: 220px; overflow-y: auto;
}
.apc-item {
    padding: 9px 14px; cursor: pointer; font-size: 14px; color: var(--text);
    transition: background .12s;
}
.apc-item:hover { background: var(--bg-hover, #f5f5f5); }
.apc-loading, .apc-empty {
    padding: 10px 14px; font-size: 13px; color: var(--text-muted); text-align: center;
}

@media (max-width: 1100px) {
    .kpi-grid, .grid-2, .details, .kpi-grid-5, .plan-grid, .wa-compose { grid-template-columns: 1fr 1fr; }
    .top-search input { width: 180px; }
    .filter-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; transform: translateX(-105%); z-index: 40; width: var(--sidebar); transition: transform .2s; }
    body.nav-open .sidebar { transform: none; }
    .menu-btn { display: grid; }
    .kpi-grid, .grid-2, .details, .auth-shell, .filter-form, .kpi-grid-5, .plan-grid, .wa-compose { grid-template-columns: 1fr; }
    .wa-template-row { flex-direction: column; }
    .profile-copy { display: none; }
    .app-content, .topbar, .app-footer { padding-left: 16px; padding-right: 16px; }
}
