:root {
    color-scheme: light;
    --ink: #18221f;
    --ink-soft: #52635c;
    --muted: #7b8982;
    --line: #dfe6de;
    --line-strong: #cbd7cd;
    --surface: #ffffff;
    --surface-soft: #f7f8f3;
    --surface-warm: #fffaf0;
    --green-950: #0b241d;
    --green-900: #10352a;
    --green-800: #174735;
    --green-700: #23654d;
    --green-600: #2e7b5e;
    --amber-600: #c88120;
    --amber-500: #e1a13a;
    --amber-100: #fff2cf;
    --rose-700: #a71d44;
    --rose-100: #ffe7ee;
    --teal-100: #dff7ee;
    --shadow: 0 18px 50px rgba(23, 71, 53, .12);
    --shadow-soft: 0 8px 26px rgba(24, 34, 31, .08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(225, 161, 58, .18), transparent 28rem),
        linear-gradient(180deg, #f8f5ec 0%, #f4f7f1 42%, #eef4ee 100%);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--green-700);
    text-decoration: none;
}

a:hover {
    color: var(--green-900);
}

button,
input,
select {
    font: inherit;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--green-700);
    color: #fff;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(35, 101, 77, .18);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button:hover,
.button:hover {
    background: var(--green-800);
    color: #fff;
    box-shadow: 0 10px 24px rgba(35, 101, 77, .24);
}

button:active,
.button:active {
    transform: translateY(1px);
}

button:disabled,
.button:disabled {
    cursor: not-allowed;
    opacity: .58;
    box-shadow: none;
}

input,
select {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
}

input[type="checkbox"] {
    width: 18px;
    min-width: 18px;
    min-height: 18px;
    accent-color: var(--green-700);
}

input[type="number"] {
    max-width: 160px;
}

input:focus,
select:focus,
button:focus-visible,
.button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(225, 161, 58, .32);
    outline-offset: 2px;
}

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

h1 {
    margin-bottom: 6px;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 18px;
    line-height: 1.25;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--ink-soft);
    background: #f7faf5;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

td {
    overflow-wrap: anywhere;
}

.app-shell {
    min-height: 100vh;
}

.public-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(225, 161, 58, .20), transparent 22rem),
        linear-gradient(180deg, #f8f5ec 0%, #eef4ee 100%);
}

.public-main {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: clamp(18px, 5vw, 44px);
}

.public-card {
    width: min(100%, 560px);
    padding: clamp(22px, 5vw, 38px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow);
}

.public-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.public-brand .brand-caption {
    color: var(--muted);
}

.public-intro {
    margin-bottom: 22px;
}

.public-upload-form {
    display: grid;
    gap: 18px;
}

.fortune-result {
    display: grid;
    gap: 16px;
}

.fortune-block {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.fortune-block p {
    margin-bottom: 0;
    color: var(--ink-soft);
    font-size: 17px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px clamp(16px, 3vw, 32px);
    background:
        linear-gradient(135deg, rgba(11, 36, 29, .98), rgba(23, 71, 53, .96)),
        var(--green-900);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 12px 30px rgba(11, 36, 29, .18);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: fit-content;
    color: #fff;
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(145deg, var(--amber-500), #ffe1a0);
    color: var(--green-950);
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32), 0 10px 24px rgba(0, 0, 0, .22);
}

.brand-name,
.brand-caption {
    display: block;
}

.brand-name {
    font-size: 17px;
    font-weight: 850;
    line-height: 1.1;
}

.brand-caption {
    margin-top: 2px;
    color: rgba(255, 255, 255, .68);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.app-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 7px;
    color: rgba(255, 255, 255, .86);
    font-weight: 750;
    line-height: 1;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, .11);
    color: #fff;
}

.app-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-kicker {
    margin-bottom: 7px;
    color: var(--amber-600);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.page-subtitle {
    margin: 0;
    color: var(--ink-soft);
}

.surface,
.panel {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid rgba(203, 215, 205, .88);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .88);
    box-shadow: var(--shadow-soft);
}

.surface-accent {
    background:
        linear-gradient(135deg, rgba(255, 242, 207, .92), rgba(255, 255, 255, .92) 48%),
        var(--surface);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    align-items: end;
}

.form-grid-wide {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
    display: grid;
    gap: 6px;
}

.field label,
.field-label {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.form-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline {
    display: inline-flex;
}

.button-secondary {
    border-color: var(--line-strong);
    background: #fff;
    color: var(--green-800);
    box-shadow: none;
}

.button-secondary:hover {
    border-color: var(--green-700);
    background: #eff8f2;
    color: var(--green-900);
    box-shadow: none;
}

.button-ghost {
    border-color: rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    box-shadow: none;
}

.button-ghost:hover {
    background: rgba(255, 255, 255, .16);
    box-shadow: none;
}

.button-compact {
    min-height: 36px;
    padding: 8px 12px;
}

.danger,
.button-danger {
    background: var(--rose-700);
    color: #fff;
}

.danger:hover,
.button-danger:hover {
    background: #871437;
    color: #fff;
}

.confirm-open {
    overflow: hidden;
}

.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(11, 36, 29, .42);
}

.confirm-backdrop[hidden] {
    display: none;
}

.confirm-dialog {
    width: min(100%, 440px);
    padding: 22px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.confirm-title {
    margin-bottom: 8px;
    color: var(--rose-700);
    font-size: 20px;
}

.confirm-message {
    margin-bottom: 20px;
    color: var(--ink-soft);
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
    font-weight: 500;
}

.status,
.status-message {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #b9e6cf;
    border-radius: 7px;
    background: var(--teal-100);
    color: #14583f;
    font-weight: 700;
}

.validation-summary-errors,
.error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #ffc6d6;
    border-radius: 7px;
    background: var(--rose-100);
    color: var(--rose-700);
    font-weight: 650;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.empty-state {
    display: grid;
    gap: 8px;
    justify-items: start;
    padding: 28px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .72);
}

.empty-title {
    margin: 0;
    font-weight: 850;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.data-table {
    min-width: 720px;
}

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

.data-table form {
    margin: 0;
}

.table-form {
    display: grid;
    grid-template-columns: minmax(130px, .8fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.table-form-three {
    grid-template-columns: minmax(130px, .8fr) minmax(170px, 1fr) auto;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--teal-100);
    color: #155a40;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.status-pill-muted {
    background: #eef1eb;
    color: var(--muted);
}

.status-pill-warning {
    background: var(--amber-100);
    color: #7c4a03;
}

.status-pill-danger {
    background: var(--rose-100);
    color: var(--rose-700);
}

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

.kpi-card {
    min-height: 104px;
    padding: 18px;
    border: 1px solid rgba(203, 215, 205, .88);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow-soft);
}

.kpi-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    line-height: 1;
}

.kpi-label {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.analytics-chart {
    display: grid;
    gap: 9px;
    margin-top: 18px;
}

.chart-row {
    display: grid;
    grid-template-columns: 56px minmax(160px, 1fr) 48px;
    gap: 10px;
    align-items: center;
}

.chart-date,
.chart-count {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
}

.chart-count {
    text-align: right;
}

.chart-track {
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2eb;
}

.chart-total {
    display: flex;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 999px;
    background: var(--line-strong);
}

.chart-segment {
    display: block;
    height: 100%;
}

.chart-accepted,
.legend-accepted {
    background: var(--green-600);
}

.chart-rejected,
.legend-rejected {
    background: var(--amber-500);
}

.chart-failed,
.legend-failed {
    background: var(--rose-700);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 14px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 750;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.analytics-table {
    min-width: 920px;
}

.analytics-events-table {
    min-width: 1080px;
}

.login-shell {
    min-height: calc(100vh - 128px);
    display: grid;
    place-items: center;
    padding: 18px 0;
}

.login-card {
    width: min(100%, 440px);
    padding: 34px;
    border: 1px solid rgba(203, 215, 205, .95);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 250, 240, .96), rgba(255, 255, 255, .96)),
        #fff;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.login-mark {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: linear-gradient(145deg, var(--green-900), var(--green-700));
    color: #fff7dc;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

.login-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
}

.login-subtitle {
    margin: 5px 0 0;
    color: var(--ink-soft);
}

.login-field {
    display: grid;
    gap: 7px;
    margin-bottom: 16px;
}

.login-field label {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.login-field input {
    padding: 12px 13px;
}

.login-recaptcha {
    display: flex;
    align-items: center;
    min-height: 78px;
    margin: 18px 0;
}

.login-submit {
    width: 100%;
    padding: 12px 16px;
}

.qr-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: start;
}

.qr-preview {
    display: grid;
    gap: 14px;
    justify-items: center;
    text-align: center;
}

.qr-preview img {
    width: min(100%, 320px);
    height: auto;
    border: 12px solid #fff;
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(24, 34, 31, .14);
}

.tariff-list {
    display: grid;
    gap: 18px;
}

.tariff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.limit-table {
    margin: 14px 0;
}

.message-page {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.message-panel {
    width: min(100%, 560px);
}

@media (max-width: 900px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-nav {
        justify-content: flex-start;
        width: 100%;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .qr-layout {
        grid-template-columns: 1fr;
    }

    .table-form,
    .table-form-three {
        grid-template-columns: minmax(180px, 1fr);
    }
}

@media (max-width: 560px) {
    body {
        font-size: 14px;
    }

    .app-main {
        width: min(100% - 24px, 1180px);
        padding-top: 18px;
    }

    .surface,
    .panel,
    .login-card {
        padding: 16px;
    }

    .brand-caption {
        display: none;
    }

    .nav-link,
    .button,
    button {
        width: auto;
    }

    .app-nav {
        gap: 6px;
    }

    .nav-link,
    .button-compact {
        padding: 8px 10px;
    }

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