* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    background: #eef2f6;
    color: #243044;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    color: #1d4ed8;
}

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

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

.app-shell-login {
    display: block;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 272px;
    height: 100vh;
    padding: 18px 14px;
    border-right: 1px solid #162433;
    background: #1a2b3c;
    color: #c8d5e4;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 20px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #0d9488;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand strong {
    font-size: 16px;
    color: #ffffff;
}

.sidebar-brand div span {
    margin-top: 2px;
    color: #7a9ab8;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #94afc7;
    font-weight: 600;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, .08);
    color: #ffffff;
}

.sidebar-nav a.active {
    background: rgba(13, 148, 136, .28);
    color: #ffffff;
    box-shadow: inset 3px 0 0 #0d9488;
}

.nav-title {
    margin: 20px 12px 6px;
    color: #5b7898;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding: 12px 8px 0;
    border-top: 1px solid #263c52;
    color: #7a9ab8;
    font-size: 13px;
}

.sidebar-footer a {
    color: #94afc7;
}

.sidebar-footer a:hover {
    color: #ffffff;
}

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

.page {
    width: min(1400px, 100%);
    padding: 28px;
}

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

.eyebrow {
    margin-bottom: 4px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.page-header h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 750;
    color: #243044;
    letter-spacing: 0;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    gap: 3px;
    width: 40px;
    height: 40px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.icon-button span {
    display: block;
    width: 16px;
    height: 2px;
    background: #344054;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f5f6f8;
}

.login-box {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .10);
}

.login-box h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    color: #243044;
}

.login-box p {
    margin: 8px 0 22px;
    color: #667085;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card,
.admin-block,
.surface {
    border: 1px solid #dde3ea;
    border-radius: 8px;
    background: #ffffff;
}

.stat-card {
    position: relative;
    padding: 18px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.stat-card:before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 3px;
    background: #0d9488;
}

.stat-card span {
    display: block;
    margin-bottom: 10px;
    color: #667085;
    font-size: 13px;
    font-weight: 600;
}

.stat-card strong {
    display: block;
    font-size: 32px;
    line-height: 1;
    color: #243044;
}

.admin-block,
.surface {
    padding: 18px;
}

.surface {
    box-shadow: 0 12px 32px rgba(15, 23, 42, .06);
}

.block-head,
.surface-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.block-head h2,
.surface-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 750;
    color: #243044;
}

.surface-header p {
    margin: 5px 0 0;
    color: #667085;
}

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

.filter-panel {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(240px, 1.6fr) minmax(130px, .7fr) minmax(140px, .8fr) minmax(120px, .6fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid #dde5ee;
    border-radius: 8px;
    background: #f8fafc;
}

.logs-filter-panel {
    grid-template-columns: minmax(140px, .8fr) minmax(150px, .9fr) minmax(180px, 1fr) minmax(130px, .7fr) minmax(130px, .7fr) minmax(220px, 1.4fr);
}

.filter-panel label {
    display: grid;
    gap: 6px;
    color: #475467;
    font-size: 12px;
    font-weight: 700;
}

.filter-panel input,
.filter-panel select {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #243044;
}

.filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.list-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}

.list-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #667085;
    font-size: 13px;
}

.list-summary strong {
    color: #243044;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 260px;
}

.search-field span {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid #98a2b3;
    border-radius: 999px;
}

.search-field span:after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: -4px;
    width: 7px;
    height: 2px;
    background: #98a2b3;
    transform: rotate(45deg);
}

.search-field input {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px 9px 38px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    outline: none;
}

.search-field input:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .18);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
}

.segmented button {
    min-height: 32px;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-weight: 700;
}

.segmented button.active {
    background: #e7f5f2;
    color: #0d9488;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #dde5ee;
    border-radius: 8px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    font-size: 13px;
}

.table th,
.table td {
    padding: 11px 14px;
    border-bottom: 1px solid #eef1f5;
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: #f6f8fb;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

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

.table tbody tr:hover td {
    background: #fbfdff;
}

.products-table th:last-child,
.products-table td:last-child {
    text-align: right;
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 260px;
}

.product-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #dff3ee;
    color: #0d9488;
    font-weight: 800;
}

.product-thumb-small {
    width: 28px;
    height: 28px;
    background: #eef4ff;
    color: #1d4ed8;
    font-size: 12px;
}

.product-group-row td {
    background: #f3f7fb;
    border-top: 1px solid #d8e1eb;
    border-bottom-color: #dfe7ef;
}

.product-group-row .product-title {
    font-size: 14px;
}

.version-row .product-cell {
    position: relative;
    padding-left: 34px;
}

.version-row .product-cell:before {
    content: "";
    position: absolute;
    left: 14px;
    top: 11px;
    width: 12px;
    height: 18px;
    border-left: 2px solid #cbd5e1;
    border-bottom: 2px solid #cbd5e1;
    border-radius: 0 0 0 6px;
}

.product-title {
    color: #243044;
    font-weight: 750;
}

.muted {
    margin-top: 2px;
    color: #667085;
    font-size: 12px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.actions form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.actions .btn {
    min-height: 34px;
}

.label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    margin-right: 4px;
    border-radius: 6px;
    background: #ecfdf3;
    color: #047857;
    font-size: 12px;
    font-weight: 700;
}

.label-blue {
    background: #eef4ff;
    color: #1d4ed8;
}

.label-green {
    background: #ecfdf3;
    color: #047857;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 750;
}

.status:before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
}

.status-live {
    background: #ecfdf3;
    color: #047857;
}

.status-live:before {
    background: #12b76a;
}

.status-off {
    background: #f2f4f7;
    color: #667085;
}

.status-off:before {
    background: #98a2b3;
}

.status-pool {
    background: #fff7ed;
    color: #c2410c;
}

.status-pool:before {
    background: #f97316;
}

.status-log-info {
    background: #eef4ff;
    color: #1d4ed8;
}

.status-log-info:before {
    background: #2563eb;
}

.status-log-warning {
    background: #fff7ed;
    color: #c2410c;
}

.status-log-warning:before {
    background: #f97316;
}

.status-log-error {
    background: #fff1f2;
    color: #b42318;
}

.status-log-error:before {
    background: #ef4444;
}

.json-details summary {
    cursor: pointer;
    color: #2563eb;
    font-weight: 700;
}

.json-details pre {
    max-width: 520px;
    max-height: 220px;
    overflow: auto;
    padding: 10px;
    border: 1px solid #dde5ee;
    border-radius: 8px;
    background: #f8fafc;
    color: #344054;
    white-space: pre-wrap;
}

.empty {
    padding: 28px !important;
    color: #667085;
    text-align: center;
}

.hidden {
    display: none !important;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #344054;
    cursor: pointer;
    font-weight: 700;
}

.btn:hover {
    background: #f8fafc;
    color: #111827;
}

.btn-primary {
    border-color: #0d9488;
    background: #0d9488;
    color: #ffffff;
}

.btn-primary:hover {
    background: #115e59;
    color: #ffffff;
}

.btn-danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b42318;
}

.btn-danger:hover {
    background: #ffe4e6;
    color: #991b1b;
}

.btn-ghost {
    border-color: #dde5ee;
    background: #ffffff;
    color: #475467;
}

.btn-ghost:hover {
    border-color: #b8c4d2;
    background: #f8fafc;
}

.btn.disabled {
    pointer-events: none;
    opacity: .45;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.list-bar .pagination {
    margin-top: 0;
}

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

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

.form label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

.form input,
.form textarea,
.form select {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #243044;
    padding: 10px 12px;
    outline: none;
}

.form textarea {
    resize: vertical;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .18);
}

.span-2 {
    grid-column: span 2;
}

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

.checks label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 700;
}

.checks input {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}

.alert {
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff1f2;
    color: #b42318;
}

.export-links {
    /*display: grid;*/
    display: none;  
    gap: 8px;
    padding: 14px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    background: #f8fafc;
}

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

.settings-section {
    margin-bottom: 16px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    padding: 14px 0 0;
    background: #f5f6f8;
}

code {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef2f6;
    color: #344054;
}

@media (max-width: 980px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid #dde3ea;
    }

    .sidebar-footer {
        margin-top: 14px;
    }

    .page {
        padding: 20px;
    }

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

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

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

    .list-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .filter-actions,
    .pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .search-field {
        min-width: 0;
    }

    .span-2 {
        grid-column: span 1;
    }
}

@media (max-width: 680px) {
    .block-head,
    .surface-header,
    .page-header,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .table {
        display: block;
        overflow-x: auto;
    }
}
