:root {
    --bg-deep: #0a0c10;
    --bg-panel: #12151c;
    --bg-panel-hover: #181c26;
    --border: #252a36;
    --text: #e8ecf4;
    --text-muted: #8b95a8;
    --neon-green: #39ff14;
    --neon-green-dim: #2bcc10;
    --violet: #a855f7;
    --violet-dim: #7c3aed;
    --danger: #ff4d6d;
    --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
    --sans: "Inter", "Segoe UI", system-ui, sans-serif;
    --radius: 10px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.5;
}

body {
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(57, 255, 20, 0.06), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(168, 85, 247, 0.05), transparent);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(18, 21, 28, 0.85);
    backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--neon-green-dim), var(--violet-dim));
    color: var(--bg-deep);
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.brand-text {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--neon-green);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.nav-link:hover {
    text-decoration: underline;
}

.user-badge {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.main-content {
    flex: 1;
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
}

.panel-narrow {
    max-width: 420px;
    margin: 4rem auto 0;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.panel-header-text {
    flex: 1;
    min-width: 200px;
}

.panel-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
}

.panel-subtitle {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo h1 {
    margin: 0.75rem 0 0.25rem;
    font-size: 1.5rem;
}

.login-logo p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--neon-green);
    box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--neon-green);
    color: var(--bg-deep);
}

.btn-primary.btn-inline,
.btn-primary.btn-buy {
    width: auto;
}

.btn-primary:hover {
    background: var(--neon-green-dim);
}

.btn-secondary {
    background: transparent;
    border-color: var(--violet);
    color: var(--violet);
}

.btn-secondary:hover {
    background: rgba(168, 85, 247, 0.12);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
}

.btn-ghost:hover {
    border-color: var(--violet);
    color: var(--violet);
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(255, 77, 109, 0.1);
    border: 1px solid rgba(255, 77, 109, 0.35);
    color: #ffb3c1;
}

.alert-info {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #d8b4fe;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-deep);
}

th,
td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.sortable-th {
    padding: 0;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.85rem 1rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.sort-link:hover {
    color: var(--neon-green);
    background: rgba(57, 255, 20, 0.04);
}

.sort-link.is-active {
    color: var(--neon-green);
}

.sort-indicator {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.35;
}

.sort-link.is-active .sort-indicator {
    opacity: 1;
}

.sort-link.sort-asc .sort-indicator {
    border-bottom: 6px solid currentColor;
}

.sort-link.sort-desc .sort-indicator {
    border-top: 6px solid currentColor;
}

tbody tr:hover {
    background: var(--bg-panel-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.mono {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--neon-green);
}

.mono-muted {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cap-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    margin: 0.1rem 0.15rem 0.1rem 0;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(168, 85, 247, 0.15);
    color: var(--violet);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.meta-line {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.meta-note {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
    max-width: 52rem;
}

.webhook-log {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 70vh;
    overflow: auto;
}

.expiry-badge {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.78rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.expiry-ok {
    color: var(--neon-green);
    border-color: rgba(57, 255, 20, 0.25);
}

.expiry-soon {
    color: #ffd166;
    border-color: rgba(255, 209, 102, 0.35);
    background: rgba(255, 209, 102, 0.08);
}

.expiry-expired {
    color: #ffb3c1;
    border-color: rgba(255, 77, 109, 0.35);
    background: rgba(255, 77, 109, 0.08);
}

.expiry-unknown {
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-weight: 500;
}

.status-0 {
    color: var(--neon-green);
    border-color: rgba(57, 255, 20, 0.25);
}

.status-1 {
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.35);
    background: rgba(167, 139, 250, 0.08);
}

.status-2 {
    color: #ffb3c1;
    border-color: rgba(255, 77, 109, 0.35);
    background: rgba(255, 77, 109, 0.08);
}

.status-3 {
    color: var(--text-muted);
    border-color: var(--border);
    background: rgba(139, 149, 168, 0.08);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.25rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.kpi-balance {
    color: var(--neon-green);
}

.kpi-balance-error {
    font-size: 0.85rem;
    color: #ff8fa3;
    line-height: 1.35;
}

.kpi-balance-link {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    align-self: flex-start;
}

.kpi-balance-link:hover {
    color: var(--neon-green);
    text-decoration: underline;
}

.kpi-balance-btn {
    margin-top: 0.35rem;
    align-self: flex-start;
    min-height: auto;
    padding: 0.45rem 0.9rem;
}

.kpi-card-switch {
    position: relative;
}

.kpi-card-switch.is-on {
    border-color: rgba(57, 255, 20, 0.35);
    background:
        linear-gradient(180deg, rgba(57, 255, 20, 0.06), transparent),
        var(--bg-deep);
}

.kpi-card-switch.is-off {
    border-color: rgba(255, 77, 109, 0.4);
    background:
        linear-gradient(180deg, rgba(255, 77, 109, 0.08), transparent),
        var(--bg-deep);
}

.kpi-card-switch.is-auto {
    border-color: rgba(245, 158, 11, 0.45);
    background:
        linear-gradient(180deg, rgba(245, 158, 11, 0.08), transparent),
        var(--bg-deep);
}

.kpi-switch-state {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.1;
}

.kpi-card-switch.is-on .kpi-switch-state {
    color: var(--neon-green);
}

.kpi-card-switch.is-off .kpi-switch-state {
    color: #ff8fa3;
}

.kpi-card-switch.is-auto .kpi-switch-state {
    color: #fbbf24;
}

.kpi-switch-hint {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-muted);
}

.kpi-card-redirect {
    min-width: 240px;
}

.kpi-switch-form {
    margin: 0.55rem 0 0;
}

.btn-switch {
    width: 100%;
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-switch-stop {
    background: transparent;
    border-color: rgba(255, 77, 109, 0.5);
    color: #ff8fa3;
}

.btn-switch-stop:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-switch-start {
    background: var(--neon-green);
    border-color: var(--neon-green);
    color: var(--bg-deep);
}

.btn-switch-start:hover {
    background: var(--neon-green-dim);
    border-color: var(--neon-green-dim);
}

.btn-switch-group {
    display: flex;
    gap: 0.3rem;
}

.btn-switch-group .btn-switch {
    flex: 1;
    padding: 0.45rem 0.25rem;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-switch-group .btn-switch:hover {
    border-color: var(--text-muted);
    color: var(--text);
    background: var(--bg-panel-hover);
}

.kpi-card-switch.is-on .btn-switch-group .btn-switch.is-active {
    background: var(--neon-green);
    border-color: var(--neon-green);
    color: var(--bg-deep);
}

.kpi-card-switch.is-off .btn-switch-group .btn-switch.is-active {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.kpi-card-switch.is-auto .btn-switch-group .btn-switch.is-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: var(--bg-deep);
}

.activity-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.activity-tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.3rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    flex-wrap: wrap;
}

.activity-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: 7px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
}

.activity-tab:hover {
    color: var(--text);
    background: var(--bg-panel-hover);
}

.activity-tab.is-active {
    color: var(--bg-deep);
    background: var(--neon-green);
}

.activity-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(139, 149, 168, 0.18);
    color: inherit;
}

.activity-tab.is-active .activity-tab-count {
    background: rgba(10, 12, 16, 0.25);
}

.activity-limit-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
}

.activity-limit-label {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}

.activity-limit-form select {
    width: auto;
    min-width: 6rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
}

.activity-days {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: -0.65rem 0 1.5rem;
}

.activity-day {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 650;
    background: var(--bg-deep);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.activity-day:hover {
    color: var(--text);
    border-color: #3a4152;
    background: var(--bg-panel-hover);
}

.activity-day.is-active {
    color: var(--bg-deep);
    background: var(--neon-green);
    border-color: var(--neon-green);
}

.activity-day-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    padding: 0.02rem 0.32rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(139, 149, 168, 0.18);
    color: inherit;
}

.activity-day.is-active .activity-day-count {
    background: rgba(10, 12, 16, 0.25);
}

.activity-status-ok {
    color: var(--neon-green);
    border-color: rgba(57, 255, 20, 0.25);
}

.activity-status-warn {
    color: #ffd166;
    border-color: rgba(255, 209, 102, 0.35);
    background: rgba(255, 209, 102, 0.08);
}

.activity-status-bad {
    color: #ffb3c1;
    border-color: rgba(255, 77, 109, 0.35);
    background: rgba(255, 77, 109, 0.08);
}

.buyer-cell {
    white-space: nowrap;
}

.buyer-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: help;
    outline: none;
}

.buyer-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
    flex-shrink: 0;
}

.sms-thread-pop {
    position: fixed;
    z-index: 80;
    width: min(26rem, calc(100vw - 1.5rem));
    max-height: 22rem;
    overflow: auto;
    padding: 0.7rem;
    border-radius: 10px;
    border: 1px solid #3a3326;
    background: #16130f;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.sms-thread-msg {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    margin-bottom: 0.45rem;
}

.sms-thread-msg:last-child {
    margin-bottom: 0;
}

.sms-thread-msg.is-buyer {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.sms-thread-msg.is-us {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.22);
}

.sms-thread-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.sms-thread-msg.is-us .sms-thread-meta span:first-child {
    color: #c4a0ff;
}

.sms-thread-msg.is-buyer .sms-thread-meta span:first-child {
    color: #f5b942;
}

.sms-thread-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text);
}

.activity-status-muted {
    color: var(--text-muted);
}

select {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font-size: 1rem;
}

select:focus {
    outline: none;
    border-color: var(--neon-green);
    box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.12);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group-grow {
    flex: 1;
    min-width: 220px;
}

.form-group-action {
    flex-shrink: 0;
}

.btn-inline {
    width: auto;
    min-height: 2.75rem;
    padding: 0.65rem 1.25rem;
}

.btn-search {
    min-width: 9.5rem;
}

.btn-buy {
    min-width: 4.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-release {
    min-width: 4.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-color: rgba(255, 77, 109, 0.4);
    color: #ff8fa3;
}

.btn-release:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.search-toolbar {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.35rem;
    margin-bottom: 1.75rem;
}

.search-toolbar__fields {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-form {
    margin: 0;
}

.search-form .form-group {
    margin-bottom: 0;
}

.field-hint {
    margin: 0.45rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.label-spacer {
    visibility: hidden;
    margin-bottom: 0.4rem;
}

.form-group-action {
    flex-shrink: 0;
}

.results-header {
    margin-bottom: 1rem;
}

.results-title {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.results-state {
    color: var(--neon-green);
    font-weight: 600;
}

.numbers-table .col-action {
    width: 6.5rem;
    text-align: right;
}

.numbers-table td.col-action {
    vertical-align: middle;
}

.state-combobox {
    position: relative;
}

.state-combobox__control {
    position: relative;
    display: flex;
    align-items: stretch;
}

.state-combobox__input {
    width: 100%;
    padding: 0.75rem 2.75rem 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.state-combobox__input:focus {
    outline: none;
    border-color: var(--neon-green);
    box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.12);
}

.state-combobox.is-invalid .state-combobox__input {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.12);
}

.state-combobox.is-valid .state-combobox__input {
    border-color: rgba(57, 255, 20, 0.45);
}

.state-combobox__toggle {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    width: 2.5rem;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0 7px 7px 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.15s, background 0.15s;
}

.state-combobox__toggle:hover {
    color: var(--neon-green);
    background: rgba(57, 255, 20, 0.06);
}

.state-combobox__list {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.state-combobox.is-open .state-combobox__list {
    display: block;
}

.state-combobox__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.state-combobox__option:last-child {
    border-bottom: none;
}

.state-combobox__option:hover,
.state-combobox__option.is-active {
    background: var(--bg-panel-hover);
}

.state-combobox__option-name {
    flex: 1;
}

.state-combobox__option-code {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--violet);
    letter-spacing: 0.04em;
}

.state-combobox__empty {
    padding: 0.85rem 0.9rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.inline-form {
    margin: 0;
    display: flex;
    justify-content: flex-end;
}

.alert-success {
    background: rgba(57, 255, 20, 0.08);
    border: 1px solid rgba(57, 255, 20, 0.3);
    color: #b8ffb0;
}

@media (max-width: 640px) {
    .main-content {
        padding: 1.25rem 1rem 2rem;
    }

    .panel {
        padding: 1.25rem;
    }

    .search-toolbar {
        padding: 1rem;
    }

    .search-toolbar__fields {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group-action,
    .btn-search {
        width: 100%;
    }

    .panel-actions {
        width: 100%;
        justify-content: flex-start;
    }

    th,
    td {
        padding: 0.65rem 0.75rem;
    }
}

.resend-form {
    margin-top: 0.4rem;
}

.resend-btn.btn-inline {
    min-height: 2rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.sms-reply-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

.sms-reply-overlay[hidden] {
    display: none;
}

.sms-reply-card {
    width: min(32rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1rem 1.1rem 1.05rem;
    border-radius: 10px;
    border: 1px solid #3a3326;
    background: #16130f;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.sms-reply-thread {
    max-height: 16rem;
    overflow: auto;
    margin: 0 0 0.85rem;
    padding: 0.55rem;
    border-radius: 8px;
    border: 1px solid #3a3326;
    background: #100e0b;
}

.sms-reply-thread .sms-thread-msg:last-child {
    margin-bottom: 0;
}

.sms-reply-title {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
}

.sms-reply-to {
    margin: 0 0 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.sms-reply-card textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 7.5rem;
    margin: 0 0 0.85rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.sms-reply-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.activity-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.dismiss-reply-form {
    margin: 0;
}

.dismiss-reply-btn {
    min-width: 2rem;
    padding: 0.3rem 0.55rem;
    color: #ff8fa3;
    border-color: rgba(255, 77, 109, 0.35);
}

.dismiss-reply-btn:hover {
    background: rgba(255, 77, 109, 0.12);
    color: #ffb3c1;
}

.last-sms-preview {
    display: inline-block;
    max-width: 22rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.toast {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1000;
    max-width: 22rem;
    padding: 0.85rem 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #14161c;
    color: #e6e6e6;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-ok {
    border-color: rgba(57, 255, 20, 0.45);
    color: var(--neon-green);
}

.toast-bad {
    border-color: rgba(255, 90, 90, 0.5);
    color: #ff8080;
}

/* —— Stats page (clean) —— */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-head h1 {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
}

.page-head .muted,
.muted {
    color: var(--text-muted);
    margin: 0;
}

.page-head-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.pill-warn {
    border-color: rgba(255, 77, 109, 0.4);
    color: #ff8fa3;
}

.stats-toolbar {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-simple-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem 0.85rem;
    margin: 0;
}

.stats-simple-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin: 0;
    min-width: 8rem;
}

.stats-simple-form input,
.stats-simple-form select {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-deep);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    text-transform: none;
    letter-spacing: 0;
    width: auto;
}

.stats-simple-form .btn {
    height: 2.35rem;
    padding: 0 0.9rem;
    font-size: 0.85rem;
}

.stats-toolbar-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.inline-refresh {
    display: inline;
    margin: 0;
}

.link-btn {
    background: none;
    border: none;
    color: var(--neon-green);
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.82rem;
}

.link-btn:hover {
    text-decoration: underline;
}

.stats-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.stats-dup-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 0;
}

.stats-kw-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 0;
}

.stats-kw-card {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.stats-kw-card:hover {
    border-color: rgba(57, 255, 20, 0.4);
}

.stats-kw-card.is-active {
    border-color: rgba(255, 153, 0, 0.55);
    background: linear-gradient(180deg, rgba(255, 153, 0, 0.1), transparent), var(--bg-deep);
}

@media (max-width: 780px) {
    .stats-kpis,
    .stats-dup-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .stats-kw-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .stats-kpis,
    .stats-dup-kpis,
    .stats-kw-kpis {
        grid-template-columns: 1fr;
    }
}

.kpi-sub {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

.kpi-sub .muted {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.delta-good { color: var(--neon-green); }
.delta-bad  { color: #ff6b81; }

.stats-panel {
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.stats-panel-head {
    margin-bottom: 0.75rem;
}

.stats-panel-head .panel-title {
    font-size: 1.1rem;
}

.stats-panel-head p {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 340px;
}

.chart-hero {
    height: 460px;
}

@media (max-width: 640px) {
    .chart-wrap { height: 260px; }
    .chart-hero { height: 320px; }
}

.stats-hero-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.stats-hero-kpis {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stats-hero-kpis > div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 5.5rem;
}

.stats-hero-num {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
    font-family: var(--mono);
    color: var(--text);
}

.table-scroll {
    overflow-x: auto;
    max-height: 36rem;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th,
.data-table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    color: var(--text-muted);
    font-weight: 600;
    z-index: 1;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: var(--bg-panel-hover);
}

.data-table a {
    color: var(--neon-green);
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

.data-table-compact {
    font-size: 0.8rem;
}

.data-table-compact th,
.data-table-compact td {
    padding: 0.4rem 0.5rem;
}

.row-weekend > td {
    background: rgba(255, 255, 255, 0.02);
}

.cell-good {
    color: var(--neon-green);
    font-weight: 600;
}

.cell-bad {
    color: #ff8b9d;
    font-weight: 600;
}

.body-cell {
    max-width: 24rem;
    color: var(--text-muted);
}

.sms-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 40rem;
    overflow-y: auto;
}

.sms-row {
    padding: 0.7rem 0.9rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.sms-row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.sms-row-meta .mono {
    font-size: 0.75rem;
}

.sms-row-meta a.mono {
    color: var(--neon-green);
}

.sms-tag {
    margin-left: auto;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.15);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.3);
    font-size: 0.7rem;
    text-decoration: none;
}

.sms-tag:hover {
    background: rgba(168, 85, 247, 0.28);
}

.sms-row-body {
    color: var(--text);
    line-height: 1.45;
    white-space: pre-wrap;
    font-size: 0.92rem;
}

details.stats-panel > summary {
    list-style: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

details.stats-panel > summary::-webkit-details-marker {
    display: none;
}

details.stats-panel > summary::before {
    content: '▸';
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.15s ease;
}

details.stats-panel[open] > summary::before {
    transform: rotate(90deg);
}
