* {
    box-sizing: border-box;
}

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f0f4f3;
    --text: #1f2933;
    --muted: #65717c;
    --line: #d9e0e6;
    --primary: #176b87;
    --primary-dark: #0f4b5f;
    --success: #237a57;
    --warning: #a66a00;
    --danger: #b23b3b;
    --accent: #6b5f9c;
    --radius: 8px;
    --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

button,
input,
select {
    font: inherit;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 16px;
    background: #eef4f2;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.brand {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 700;
}

.brand-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
}

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

.sidebar {
    width: 260px;
    flex: 0 0 260px;
    padding: 18px 14px;
    color: #e8f0f2;
    background: #12343b;
}

.sidebar-brand {
    padding: 8px 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-brand strong {
    display: block;
    font-size: 20px;
}

.sidebar-brand span {
    color: #adc7ce;
}

.nav-section {
    margin-top: 18px;
}

.nav-title {
    margin: 0 0 6px;
    padding: 0 10px;
    color: #9fb8be;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.nav-link,
.logout-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    margin: 2px 0;
    padding: 9px 10px;
    color: #edf6f7;
    background: transparent;
    border: 0;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
}

.nav-link:hover,
.logout-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
}

.main {
    min-width: 0;
    flex: 1;
}

.topbar {
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    margin: 0;
    font-size: 18px;
}

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

.user-chip {
    padding: 6px 10px;
    color: var(--primary-dark);
    background: #e4f1ef;
    border-radius: 6px;
}

.content {
    padding: 24px;
}

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

.page-head h1 {
    margin: 0;
    font-size: 24px;
}

.page-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

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

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
}

.metric-card {
    padding: 18px;
}

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

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

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

.panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

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

.alert-success {
    color: #14543a;
    background: #e5f3ec;
    border-color: #b9dec9;
}

.alert-error {
    color: #7d2222;
    background: #fdebea;
    border-color: #efc4c1;
}

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

.filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 700;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cfd8df;
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(23, 107, 135, 0.16);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.error {
    color: var(--danger);
    font-size: 13px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.btn {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

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

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

.btn-light {
    color: var(--text);
    background: #edf2f4;
    border-color: #d5dde2;
}

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

.btn-warning {
    color: #2f2200;
    background: #ffd166;
}

.btn-small {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 13px;
}

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

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-admin {
    color: #3d326e;
    background: #ece8ff;
}

.badge-staff {
    color: #0d5165;
    background: #e1f2f6;
}

.badge-active {
    color: #14543a;
    background: #dff2e8;
}

.badge-inactive {
    color: #7d2222;
    background: #f7dfdf;
}

.badge-warning {
    color: #7a4b00;
    background: #fff0bf;
}

.badge-muted {
    color: #56616c;
    background: #e9eef2;
}

.env-notice {
    margin-bottom: 16px;
    padding: 14px;
    background: #fff8df;
    border: 1px solid #f1d675;
    border-radius: var(--radius);
}

.env-notice strong {
    display: inline-flex;
    margin-right: 8px;
}

.shop-logo {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #fff;
    background: #ee4d2d;
    border-radius: 6px;
    font-weight: 700;
}

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

.definition-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px 16px;
}

.definition-list dt {
    color: var(--muted);
    font-weight: 700;
}

.definition-list dd {
    margin: 0;
}

.json-box {
    overflow-x: auto;
    padding: 12px;
    background: #101820;
    color: #f1f6f8;
    border-radius: 6px;
    white-space: pre-wrap;
}

.pagination {
    margin-top: 14px;
}

.pagination nav > div:first-child {
    display: none;
}

@media (max-width: 1100px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 760px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-basis: auto;
    }

    .topbar,
    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .content {
        padding: 16px;
    }

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

    .definition-list {
        grid-template-columns: 1fr;
    }
}
