 :root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --panel-light: #ffffff;
    --panel-muted: #f8fafc;
    --border: #e5e7eb;
    --text: #0f172a;
    --text-soft: #64748b;
    --brand: #2563eb;
    --brand-soft: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #eef2ff;
    color: var(--text);
}

body {
    min-height: 100vh;
}

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

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

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

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #e2e8f0;
    padding: 28px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
}

.brand-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
    font-weight: 800;
    letter-spacing: 0.06em;
}

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

.brand p {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
}

.nav-group {
    display: grid;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    color: #cbd5e1;
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(59, 130, 246, 0.18);
    color: #ffffff;
}

.nav-meta {
    color: #94a3b8;
    font-size: 12px;
}

.main {
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h2 {
    margin: 0 0 8px;
    font-size: 30px;
}

.topbar p {
    margin: 0;
    color: var(--text-soft);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    box-shadow: var(--shadow);
    color: var(--text-soft);
    font-size: 13px;
}

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

.card,
.panel,
.stat-card {
    background: var(--panel-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.stat-card {
    padding: 20px;
}

.stat-card small {
    color: var(--text-soft);
    display: block;
    margin-bottom: 12px;
}

.stat-card strong {
    font-size: 30px;
    display: block;
    margin-bottom: 8px;
}

.stat-card span {
    color: var(--text-soft);
    font-size: 14px;
}

.two-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.panel {
    padding: 22px;
}

.panel h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.panel-subtitle {
    margin: 0 0 18px;
    color: var(--text-soft);
    font-size: 14px;
}

.table-wrap {
    overflow: auto;
}

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

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

.table th {
    color: var(--text-soft);
    font-weight: 600;
    background: #fbfdff;
}

.thumb {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
}

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

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

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

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

.field label {
    font-size: 14px;
    font-weight: 600;
}

.input,
.textarea,
.select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid #dbe2ea;
    padding: 12px 14px;
    background: white;
    transition: 0.2s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.6);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
}

.actions,
.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.row-actions {
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s ease;
}

.btn-primary {
    background: var(--brand);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #334155;
}

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

.btn-outline {
    background: white;
    border: 1px solid #dbe2ea;
    color: #334155;
}

.btn-sm {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #ffedd5;
    color: #9a3412;
}

.badge-muted {
    background: #e2e8f0;
    color: #475569;
}

.alerts {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    background: white;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--brand);
}

.alert-success {
    border-left-color: var(--success);
}

.alert-danger {
    border-left-color: var(--danger);
}

.alert-warning {
    border-left-color: var(--warning);
}

.quick-links {
    display: grid;
    gap: 12px;
}

.quick-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    padding: 14px 16px;
    background: #fff;
}

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

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

.segmented a {
    padding: 10px 14px;
    border-radius: 999px;
    background: white;
    color: var(--text-soft);
    border: 1px solid #dbe2ea;
}

.segmented a.is-active {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: transparent;
}

.kv-list {
    display: grid;
    gap: 12px;
}

.kv-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 12px;
}

.kv-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

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

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-soft);
}

.chart-panel {
    min-height: 380px;
}

.chart-shell {
    height: 320px;
}



html {
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

.mobile-backdrop,
.sidebar-mobile-head,
.nav-toggle {
    display: none;
}

.topbar-main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.topbar-main > div {
    min-width: 0;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    box-shadow: var(--shadow);
}

.icon-btn:hover {
    transform: translateY(-1px);
}

.actions form,
.row-actions form {
    margin: 0;
}

.chart-shell canvas {
    width: 100%;
    height: 100%;
    display: block;
}

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

    .two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 35;
    }

    body.sidebar-open .mobile-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(84vw, 320px);
        height: auto;
        overflow-y: auto;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.3);
        padding-top: 20px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 18px;
        color: #cbd5e1;
        font-size: 14px;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .main {
        padding: 20px 16px 28px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .topbar h2 {
        font-size: 26px;
        line-height: 1.2;
    }

    .pill {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

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

@media (max-width: 760px) {
    .main {
        padding: 16px 12px 24px;
    }

    .brand {
        margin-bottom: 24px;
    }

    .brand h1 {
        font-size: 22px;
    }

    .topbar h2 {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .topbar p,
    .panel-subtitle,
    .stat-card span,
    .muted {
        font-size: 13px;
    }

    .grid-cards {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .stat-card,
    .panel {
        padding: 16px;
        border-radius: 16px;
    }

    .toolbar {
        align-items: stretch;
    }

    .toolbar > * {
        width: 100%;
    }

    .segmented {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .segmented::-webkit-scrollbar {
        display: none;
    }

    .segmented a {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .quick-link,
    .kv-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .actions,
    .filter-form,
    .row-actions {
        width: 100%;
    }

    .actions > *,
    .filter-form > *,
    .row-actions > * {
        flex: 1 1 100%;
    }

    .row-actions form,
    .row-actions .btn,
    .actions .btn,
    .actions form,
    .filter-form .btn,
    .filter-form .select,
    .filter-form .input {
        width: 100%;
    }

    .btn,
    .input,
    .select,
    .textarea {
        min-height: 44px;
    }

    .table-wrap {
        overflow: visible;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table thead {
        display: none;
    }

    .table tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 16px;
        box-shadow: var(--shadow);
        padding: 6px 12px;
        margin-bottom: 12px;
    }

    .table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 10px 0;
        border-bottom: 1px solid #eef2f7;
    }

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

    .table td::before {
        content: attr(data-label);
        color: var(--text-soft);
        font-weight: 600;
        font-size: 13px;
        flex: 0 0 88px;
        max-width: 42%;
    }

    .table td > * {
        min-width: 0;
    }

    .thumb {
        width: 52px;
        height: 52px;
    }

    .chart-panel {
        min-height: 0;
    }

    .chart-shell {
        height: 240px;
    }
}
