:root {
    --bg: #0c1424;
    --bg-soft: #101a2f;
    --panel: #121d33;
    --panel-soft: #19253f;
    --panel-strong: #0d1526;
    --line: #24314d;
    --line-soft: #314162;
    --text: #e8eefc;
    --muted: #97a5c1;
    --accent: #4f7cff;
    --accent-soft: rgba(79, 124, 255, 0.16);
    --success: #26d07c;
    --danger: #ff5d73;
    --warning: #ffc857;
    --shadow: 0 24px 48px rgba(4, 10, 22, 0.38);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top center, rgba(79, 124, 255, 0.15), transparent 30%),
        linear-gradient(180deg, #0f172a 0%, #0a1220 100%);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: #8ab0ff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.auth-theme {
    background:
        radial-gradient(circle at top left, rgba(79, 124, 255, 0.18), transparent 35%),
        linear-gradient(180deg, #0b1325 0%, #08101d 100%);
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel-section,
.stats-card,
.modal-card,
.card-form {
    background: linear-gradient(180deg, rgba(24, 37, 63, 0.98) 0%, rgba(15, 24, 42, 0.98) 100%);
    border: 1px solid rgba(53, 73, 111, 0.72);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 430px);
    padding: 32px;
}

.hero-badge {
    display: inline-flex;
    margin-bottom: 14px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(92, 132, 255, 0.35);
    color: #c7d6ff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.alert {
    margin: 16px 0;
    padding: 12px 14px;
    border-radius: 14px;
}

.alert.error {
    background: rgba(255, 93, 115, 0.12);
    color: #ff9eac;
    border: 1px solid rgba(255, 93, 115, 0.25);
}

.stack-form,
.card-form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
}

label span,
.section-title {
    font-size: 13px;
    font-weight: 700;
    color: #d9e5ff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input,
textarea,
select {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line-soft);
    background: #0f182b;
    color: var(--text);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:hover,
textarea:hover,
select:hover,
input:focus,
textarea:focus,
select:focus {
    border-color: #597ed9;
    box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
}

input[type="date"] {
    cursor: pointer;
}

textarea {
    min-height: 132px;
    resize: vertical;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.nav-btn,
.subnav-btn,
.icon-btn,
.action-chip {
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.nav-btn:hover,
.subnav-btn:hover,
.icon-btn:hover,
.action-chip:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none !important;
}

.primary-btn,
.danger-btn,
.ghost-btn {
    min-height: 46px;
    padding: 11px 18px;
    font-weight: 700;
}

.primary-btn {
    background: linear-gradient(180deg, #4c79ff 0%, #3e62d2 100%);
    color: #fff;
    border-color: #5b83f2;
}

.ghost-btn {
    background: #1a2640;
    color: #dfe9ff;
    border-color: #304261;
}

.danger-btn {
    background: rgba(255, 93, 115, 0.16);
    color: #ffb1bd;
    border-color: rgba(255, 93, 115, 0.3);
}

.full-width {
    width: 100%;
}

#app {
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 18px;
}

.brand-block h1 {
    margin: 0;
    font-size: clamp(26px, 3vw, 38px);
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.country-switcher {
    min-width: 190px;
}

.country-switcher span {
    font-size: 11px;
}

.current-user {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(10, 18, 33, 0.78);
    color: #d9e5ff;
}

.topbar-actions form {
    display: flex;
}

.main-nav,
.subnav,
.toolbar,
.filters-row,
.inline-actions,
.file-picker {
    display: flex;
    gap: 12px;
    align-items: center;
}

.main-nav {
    margin-bottom: 18px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(12, 20, 36, 0.78);
    border: 1px solid var(--line);
    overflow-x: auto;
}

.nav-btn,
.subnav-btn {
    min-height: 44px;
    padding: 10px 18px;
    background: #15213a;
    color: #c5d5f8;
    border-color: #293755;
    font-weight: 700;
    white-space: nowrap;
}

.nav-btn.active,
.subnav-btn.active {
    background: linear-gradient(180deg, #4c79ff 0%, #3f63d4 100%);
    color: #fff;
    border-color: rgba(92, 132, 255, 0.42);
    box-shadow: 0 10px 22px rgba(79, 124, 255, 0.22);
}

.content-grid {
    display: grid;
}

.panel-section {
    display: none;
    padding: 24px;
}

.panel-section.active,
.subpanel.active {
    display: block;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
}

.panel-header h2 {
    margin: 0 0 6px;
}

.subnav {
    margin-bottom: 18px;
}

.toolbar {
    margin-bottom: 18px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(8, 14, 25, 0.82);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(35, 50, 80, 0.9);
    text-align: left;
    vertical-align: top;
}

th {
    background: #09111f;
    color: #c4d5fa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

tbody tr:nth-child(odd) td {
    background: rgba(13, 21, 38, 0.86);
}

tbody tr:nth-child(even) td {
    background: rgba(17, 28, 48, 0.86);
}

tr:last-child td {
    border-bottom: 0;
}

.action-chip {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 13px;
    background: #1a2640;
    color: #e2ebff;
    border-color: #314261;
}

.action-chip.edit {
    color: #9dc0ff;
    border-color: rgba(79, 124, 255, 0.28);
}

.action-chip.delete {
    color: #ffacb7;
    border-color: rgba(255, 93, 115, 0.25);
}

.action-chip.status {
    color: #b7ffc8;
    border-color: rgba(38, 208, 124, 0.25);
}

.subpanel {
    display: none;
}

.card-form {
    width: min(100%, 740px);
    padding: 22px;
}

.template-selector {
    display: grid;
    gap: 12px;
}

.template-option {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 14px;
    align-items: start;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(11, 19, 35, 0.84);
}

.template-option strong {
    display: block;
    margin-bottom: 6px;
}

.upload-block {
    display: grid;
    gap: 10px;
}

.file-picker {
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line-soft);
    background: #0f182b;
    justify-content: space-between;
}

.file-name {
    color: #c8d8f8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 18px 0;
}

.stats-card {
    padding: 20px;
}

.stats-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9fb1d3;
}

.stats-value {
    margin: 12px 0 18px;
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 800;
}

.filters-row {
    flex-wrap: wrap;
}

.filters-row-tight {
    align-items: stretch;
}

.filters-row-tight > * {
    align-self: stretch;
}

.filters-row label {
    min-width: 132px;
}

.filters-row .wide {
    flex: 1 1 240px;
}

.wrap {
    flex-wrap: wrap;
}

.date-field input {
    min-height: 46px;
}

.status-pill {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-pill.NEW {
    color: #d1ddff;
    background: rgba(80, 110, 176, 0.2);
    border-color: rgba(80, 110, 176, 0.34);
}

.status-pill.IN_PROGRESS {
    color: #ffe3a4;
    background: rgba(255, 200, 87, 0.16);
    border-color: rgba(255, 200, 87, 0.28);
}

.status-pill.COMPLETED,
.status-pill.ACCEPTED,
.status-pill.QUEUED,
.status-pill.UPDATED {
    color: #c0ffd4;
    background: rgba(38, 208, 124, 0.12);
    border-color: rgba(38, 208, 124, 0.28);
}

.status-pill.ERROR,
.status-pill.REJECTED,
.status-pill.FAILED {
    color: #ffbcc5;
    background: rgba(255, 93, 115, 0.16);
    border-color: rgba(255, 93, 115, 0.3);
}

.campaign-status {
    display: grid;
    gap: 8px;
}

.campaign-summary {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.result-list {
    margin-top: 16px;
}

.result-link {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.result-link:last-child {
    border-bottom: 0;
}

.download-links {
    display: grid;
    gap: 6px;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 10, 18, 0.72);
    backdrop-filter: blur(8px);
    z-index: 20;
}

.modal.hidden,
.toast.hidden {
    display: none;
}

.modal-card {
    width: min(100%, 620px);
    padding: 24px;
}

.modal-card.wide {
    width: min(100%, 860px);
}

.confirm-card {
    width: min(100%, 480px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: #1a2640;
    color: #dbe6ff;
    border-color: #314261;
    font-size: 18px;
}

.preview-content {
    display: grid;
    gap: 16px;
    margin-bottom: 18px;
}

.preview-box,
.preview-item,
.confirm-message {
    padding: 16px;
    border-radius: 16px;
    background: rgba(10, 18, 33, 0.82);
    border: 1px solid var(--line);
}

.preview-list {
    display: grid;
    gap: 12px;
}

.confirm-message {
    margin-bottom: 18px;
    line-height: 1.6;
    color: #dbe6ff;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: 400px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #0f1a2f;
    color: #fff;
    border: 1px solid rgba(56, 82, 132, 0.9);
    box-shadow: var(--shadow);
    z-index: 30;
}

@media (max-width: 980px) {
    #app {
        padding: 18px;
    }

    .topbar,
    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
