:root {
    --primary: #2563eb;
    --primary-dark: #153e75;
    --primary-light: #dbeafe;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #dbe3ee;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #b45309;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

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

.topbar {
    min-height: 68px;
    background: var(--primary-dark);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 24px;
}

.brand {
    font-size: 19px;
    font-weight: 750;
}

.brand small {
    display: block;
    font-size: 11px;
    color: #bfdbfe;
    font-weight: 400;
}

.shell {
    display: grid;
    grid-template-columns: 235px minmax(0, 1fr);
    min-height: calc(100vh - 68px);
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
}

.sidebar a {
    display: block;
    padding: 11px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 500;
}

.sidebar a:hover,
.sidebar a.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.content {
    min-width: 0;
    padding: 26px;
}

h1 {
    font-size: 27px;
    margin: 0 0 20px;
}

h2 {
    font-size: 19px;
    margin: 0 0 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 2px 6px rgba(15,23,42,.03);
}

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

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    font-size: 30px;
    font-weight: 750;
    color: var(--primary);
    overflow-wrap: anywhere;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

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

.btn-secondary {
    background: white;
    color: var(--text);
    border-color: var(--border);
}

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

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input:not([type="checkbox"]):not([type="radio"]),
select, textarea {
    width: 100%;
    padding: 11px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

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

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

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #eff6ff;
    font-size: 13px;
}

.status {
    display: inline-block;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
}

.status-success {
    background: #dcfce7;
    color: var(--success);
}

.status-warning {
    background: #fef3c7;
    color: var(--warning);
}

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

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

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

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(
        135deg, #eff6ff, #dbeafe
    );
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 15px 40px rgba(30,64,175,.10);
}

.login-card .btn {
    width: 100%;
}

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

.footer {
    padding: 20px 0;
    color: var(--muted);
    font-size: 12px;
}

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

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

    .sidebar {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 10px;
    }

    .sidebar a {
        font-size: 13px;
        padding: 8px 10px;
        margin: 0;
    }

    .content {
        padding: 15px;
    }

    .topbar {
        padding: 12px 15px;
    }

    .card {
        padding: 15px;
    }

    .stat-value {
        font-size: 24px;
    }
}

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

/* IX1ADS Dashboard 1.0 */

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

.dashboard-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.dashboard-row:last-child {
    border-bottom: 0;
}

.dashboard-chart {
    display: block;
    width: 100%;
    height: auto;
}

.dashboard-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

@media (max-width: 760px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

/* IX1 MANAGEMENT UI V1 */

.ix1-management {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.ix1-management-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.ix1-management-heading h1 {
    margin: 0 0 6px;
    color: #17365d;
}

.ix1-management-heading p {
    margin: 0;
    color: #64748b;
}

.ix1-management-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.ix1-management-summary > div {
    background: #fff;
    border: 1px solid #dbe5f1;
    border-radius: 12px;
    padding: 20px;
}

.ix1-management-summary span {
    display: block;
    font-size: 13px;
    color: #64748b;
}

.ix1-management-summary strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    color: #1d4ed8;
}

.ix1-management-panel {
    background: #fff;
    border: 1px solid #dbe5f1;
    border-radius: 12px;
    padding: 22px;
    min-width: 0;
}

.ix1-management-panel h2 {
    margin: 0 0 20px;
    font-size: 18px;
    color: #17365d;
}

.ix1-management-empty {
    padding: 30px 16px;
    text-align: center;
    background: #f5f9ff;
    border-radius: 10px;
    color: #64748b;
}

.ix1-table-scroll {
    overflow-x: auto;
}

.ix1-management-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ix1-management-table th,
.ix1-management-table td {
    padding: 13px 10px;
    text-align: left;
    border-bottom: 1px solid #e5edf5;
    overflow-wrap: anywhere;
}

.ix1-management-table th {
    background: #f1f6fc;
    color: #334155;
}

.ix1-state-active,
.ix1-state-inactive {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.ix1-state-active {
    background: #dcfce7;
    color: #166534;
}

.ix1-state-inactive {
    background: #e2e8f0;
    color: #475569;
}

.ix1-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    color: #fff;
    border: 1px solid #2563eb;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.ix1-action:hover {
    background: #1d4ed8;
    color: #fff;
}

.ix1-action-small {
    padding: 6px 12px;
    font-size: 12px;
}

.ix1-action-secondary {
    padding: 10px 16px;
    color: #475569;
    text-decoration: none;
}

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

.ix1-form-grid label {
    display: grid;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.ix1-form-grid input,
.ix1-form-grid textarea,
.ix1-form-grid select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font: inherit;
    font-weight: 400;
}

.ix1-form-grid input:focus,
.ix1-form-grid textarea:focus,
.ix1-form-grid select:focus {
    outline: 2px solid #93c5fd;
    border-color: #2563eb;
}

.ix1-form-wide {
    grid-column: 1 / -1;
}

.ix1-form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.ix1-management-error,
.ix1-management-success {
    padding: 14px;
    border-radius: 8px;
}

.ix1-management-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.ix1-management-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

@media (max-width: 700px) {
    .ix1-management-summary,
    .ix1-form-grid {
        grid-template-columns: 1fr;
    }

    .ix1-management-panel {
        padding: 15px;
    }

    .ix1-management-heading {
        align-items: flex-start;
    }
}
