:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #dbe3ee;
    --line-strong: #c7d2e0;
    --text: #253244;
    --muted: #6b7a90;
    --accent: #3c7be6;
    --accent-soft: #e8f0ff;
    --accent-strong: #235dc0;
    --success: #198754;
    --success-soft: #e7f7ef;
    --danger: #d63346;
    --danger-soft: #fdecef;
    --warning: #b7791f;
    --warning-soft: #fff4de;
    --shadow: 0 10px 30px rgba(37, 50, 68, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(60, 123, 230, 0.08), transparent 22%),
        linear-gradient(180deg, #fafcff 0%, var(--bg) 22%);
}

a {
    color: inherit;
}

.app-body {
    background:
        linear-gradient(180deg, #fbfdff 0, #f4f6f9 160px),
        var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: 272px 1fr;
    min-height: 100vh;
}

.app-workspace {
    min-width: 0;
}

.app-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 20px;
    background: rgba(255, 255, 255, 0.92);
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 30px rgba(37, 50, 68, 0.03);
    backdrop-filter: blur(12px);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.app-brand__logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #6ea5ff);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(60, 123, 230, 0.28);
}

.app-brand__text strong,
.app-brand__text small {
    display: block;
}

.app-brand__text small {
    margin-top: 3px;
    color: var(--muted);
}

.menu {
    display: grid;
    gap: 8px;
}

.menu__link {
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.menu__link:hover,
.menu__link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    transform: translateX(2px);
}

.app-sidebar__footer {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.profile-card {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.profile-card--sidebar {
    margin-bottom: 4px;
}

.profile-card strong,
.profile-card small {
    display: block;
}

.profile-card small {
    margin-top: 5px;
    color: var(--muted);
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 28px 0;
}

.app-topbar__title,
.app-topbar__user {
    display: grid;
    gap: 4px;
}

.app-topbar__title strong,
.app-topbar__user strong {
    font-size: 18px;
}

.app-topbar__title span,
.app-topbar__user span {
    color: var(--muted);
    font-size: 13px;
}

.app-topbar__user {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(37, 50, 68, 0.05);
}

.app-main {
    padding: 28px;
}

.shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

.main {
    padding: 28px;
}

.main--single {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding-top: 48px;
}

.page-head,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-head {
    margin-bottom: 24px;
}

.page-head h1,
.section-head h2,
.card-surface h2 {
    margin: 0;
}

.page-head p,
.table-row p,
.empty-state,
.stat-card span,
.field-hint,
label span {
    color: var(--muted);
}

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

.stat-card,
.card-surface {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px 20px;
}

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

.card-surface {
    padding: 22px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(340px, 430px) 1fr;
    gap: 24px;
}

.content-grid--wide {
    grid-template-columns: minmax(320px, 380px) 1fr;
}

.grid-single {
    display: grid;
    grid-template-columns: minmax(340px, 560px);
    gap: 24px;
}

.grid-single--wide {
    grid-template-columns: minmax(340px, 1fr);
}

.form-grid,
.table-list {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 8px;
    font-size: 14px;
}

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

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(60, 123, 230, 0.65);
    box-shadow: 0 0 0 4px rgba(60, 123, 230, 0.12);
}

textarea {
    resize: vertical;
}

.form-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-triple {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(60, 123, 230, 0.22);
}

.button--secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line-strong);
    box-shadow: none;
}

.button--danger {
    background: linear-gradient(135deg, #e35d6a, var(--danger));
    box-shadow: 0 10px 22px rgba(214, 51, 70, 0.18);
}

.button--full {
    width: 100%;
}

.alert {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.alert--success {
    background: var(--success-soft);
    border-color: rgba(25, 135, 84, 0.18);
    color: var(--success);
}

.alert--error {
    background: var(--danger-soft);
    border-color: rgba(214, 51, 70, 0.18);
    color: var(--danger);
}

.pill {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-soft);
}

.table-row--stack {
    display: grid;
}

.table-row strong,
.table-row p {
    margin: 0;
}

.table-row__metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-row__metrics span {
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 13px;
}

.code-block {
    display: grid;
    gap: 8px;
}

.code-block textarea {
    min-height: 92px;
    font-family: Consolas, monospace;
    background: #1f2937;
    color: #ecf3ff;
    border-color: #1f2937;
}

.checkbox-line {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.checkbox-line input {
    width: 18px;
    height: 18px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.field-hint {
    margin: 0;
    font-size: 13px;
}

.finance-balance {
    display: grid;
    gap: 10px;
}

.finance-balance strong {
    font-size: 34px;
    line-height: 1.1;
}

.category-select {
    display: grid;
    gap: 10px;
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-soft);
    cursor: pointer;
}

.category-chip input {
    width: 16px;
    height: 16px;
}

.country-select {
    display: grid;
    gap: 10px;
}

.country-select__toggle {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    box-shadow: none;
}

.country-select__panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    box-shadow: 0 14px 30px rgba(37, 50, 68, 0.08);
}

.country-select__search {
    background: #fff;
}

.country-select__search-wrap {
    position: relative;
}

.country-select__search-wrap .country-select__search {
    padding-right: 48px;
}

.country-select__clear {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    box-shadow: none;
    cursor: pointer;
    transform: translateY(-50%);
}

.country-select__clear:hover {
    background: #dce9ff;
}

.country-select__clear svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.country-select__list {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    gap: 8px;
    padding-right: 4px;
}

.country-select__item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(219, 227, 238, 0.8);
}

.country-select__item input {
    width: 16px;
    height: 16px;
}

.country-select__empty {
    display: none;
    margin: 0;
}

.country-flag {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(37, 50, 68, 0.12);
    object-fit: cover;
    background: #fff;
}

.country-flag--rect {
    width: 24px;
    height: 18px;
}

.country-flag--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
}

.country-admin-search {
    margin-bottom: 16px;
}

.country-option__meta {
    display: grid;
    gap: 2px;
}

.country-option__meta strong {
    font-size: 13px;
}

.country-option__meta small {
    color: var(--muted);
    font-size: 11px;
}

.country-admin-table {
    display: grid;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-soft);
}

.country-admin-table__head,
.country-admin-table__row {
    display: grid;
    grid-template-columns: minmax(220px, 1.45fr) 90px minmax(240px, 1.4fr) 120px 132px 120px;
    gap: 12px;
    align-items: center;
}

.country-admin-table__head {
    padding: 14px 18px;
    background: #eef3fb;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.country-admin-table__row {
    padding: 14px 18px;
}

.country-admin-table__row--new {
    margin-bottom: 18px;
    padding: 0;
}

.country-admin-table__item {
    margin: 0;
    border-top: 1px solid var(--line);
}

.country-admin-table__item:first-of-type {
    border-top: 0;
}

.country-admin-table__field {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}

.country-admin-table__field input {
    min-width: 0;
}

.country-admin-table__row .checkbox-line {
    margin: 0;
    grid-template-columns: auto auto;
    gap: 8px;
}

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(320px, 380px) 1fr;
    gap: 24px;
}

.ticket-layout--wide-form {
    grid-template-columns: minmax(420px, 500px) 1fr;
}

.ticket-list-item {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    text-decoration: none;
}

.ticket-list-item.is-active {
    border-color: rgba(60, 123, 230, 0.45);
    background: #eef5ff;
}

.ticket-list-item span,
.ticket-list-item small {
    color: var(--muted);
}

.ticket-thread {
    display: grid;
    gap: 14px;
    margin: 18px 0 20px;
}

.ticket-message {
    display: grid;
    gap: 10px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
}

.ticket-message--admin {
    background: #eef5ff;
    border-color: rgba(60, 123, 230, 0.18);
}

.ticket-message__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.ticket-message p {
    margin: 0;
    line-height: 1.55;
}

.ticket-files {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ticket-file {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    text-decoration: none;
}

.section-head--spaced {
    margin-top: 24px;
}

@media (max-width: 1180px) {
    .app-shell,
    .content-grid,
    .content-grid--wide,
    .ticket-layout {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: static;
        min-height: auto;
    }

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

@media (max-width: 760px) {
    .app-main,
    .app-sidebar,
    .main {
        padding: 18px;
    }

    .app-topbar {
        padding: 18px 18px 0;
        align-items: flex-start;
        flex-direction: column;
    }

    .page-head,
    .section-head,
    .table-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .form-split,
    .form-triple,
    .grid-single,
    .grid-single--wide {
        grid-template-columns: 1fr;
    }

    .ticket-message__meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .country-admin-table__head,
    .country-admin-table__row {
        grid-template-columns: 1fr;
    }
}
