:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #171a1f;
    --muted: #667085;
    --line: #e5e7eb;
    --red: #e60000;
    --red-dark: #b80000;
    --green: #067647;
    --yellow: #a15c07;
    --shadow: 0 12px 28px rgba(16, 24, 40, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 34px);
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    font-weight: 800;
    color: var(--red);
}

nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

nav a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
}

nav a:hover {
    background: #f2f4f7;
    color: var(--text);
}

.page {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 22px clamp(14px, 4vw, 28px) 40px;
}

.auth-card,
.panel,
.hero {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-card {
    max-width: 430px;
    margin: 8vh auto 0;
    padding: 28px;
}

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

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(24px, 4vw, 34px);
    margin-bottom: 8px;
}

h2 {
    font-size: 20px;
    margin-bottom: 18px;
}

p,
.muted {
    color: var(--muted);
    line-height: 1.7;
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

.form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #cfd4dc;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus {
    outline: 2px solid rgba(230, 0, 0, .18);
    border-color: var(--red);
}

button,
.primary {
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    background: #f2f4f7;
    color: var(--text);
}

.primary {
    background: var(--red);
    color: #fff;
}

.primary:hover {
    background: var(--red-dark);
}

.packages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
}

.package {
    position: relative;
    min-height: 112px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.package input {
    position: absolute;
    inset-inline-start: 10px;
    top: 10px;
    width: 18px;
    min-height: 18px;
}

.package:has(input:checked) {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(230, 0, 0, .12);
}

.package span,
.package small {
    display: block;
}

.package .price {
    color: var(--red);
    font-size: 20px;
    font-weight: 900;
}

.package small {
    color: var(--muted);
    margin-top: 6px;
}

.mode,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 800;
    white-space: nowrap;
}

.mode.demo {
    color: var(--yellow);
    background: #fff6df;
}

.mode.live,
.badge.success {
    color: var(--green);
    background: #dcfae6;
}

.badge.failed,
.alert.danger {
    color: #b42318;
    background: #fee4e2;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.alert.success {
    color: var(--green);
    background: #dcfae6;
}

.alert.info {
    color: #175cd3;
    background: #d1e9ff;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.admin-create {
    grid-template-columns: repeat(4, 1fr);
    align-items: end;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form input {
    min-width: 150px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.stats div {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats strong {
    display: block;
    font-size: 28px;
}

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

@media (max-width: 720px) {
    .topbar,
    .hero {
        align-items: stretch;
        flex-direction: column;
    }

    .page {
        padding-bottom: 92px;
    }

    .auth-card,
    .panel,
    .hero {
        box-shadow: none;
    }

    .admin-create {
        grid-template-columns: 1fr;
    }

    .sticky-action {
        position: fixed;
        left: 14px;
        right: 14px;
        bottom: max(14px, env(safe-area-inset-bottom));
        z-index: 20;
        box-shadow: 0 12px 28px rgba(230, 0, 0, .28);
    }

    .packages {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 410px) {
    .packages {
        grid-template-columns: 1fr;
    }
}
