:root {
    color-scheme: light;
    --visa-surface: #f6f7fb;
    --visa-panel: #ffffff;
    --visa-text: #1f2937;
    --visa-muted: #6b7280;
    --visa-border: #d8dee9;
    --visa-accent: #0d6efd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--visa-surface);
    color: var(--visa-text);
    direction: rtl;
    text-align: right;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

a {
    color: var(--visa-accent);
}

.min-h-screen {
    min-height: 100vh;
}

.bg-gray-100 {
    background: var(--visa-surface);
}

.bg-white {
    background: var(--visa-panel);
}

.text-gray-500,
.text-gray-600,
.text-gray-700 {
    color: var(--visa-muted);
}

.text-gray-900 {
    color: var(--visa-text);
}

.shadow,
.shadow-md {
    box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

.rounded-lg,
.sm\:rounded-lg {
    border-radius: .5rem;
}

.w-full {
    width: 100%;
}

.sm\:max-w-md {
    max-width: 28rem;
}

.max-w-7xl {
    max-width: 80rem;
}

.mx-auto {
    margin-inline: auto;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.px-4,
.px-6 {
    padding-inline: 1.5rem;
}

.py-4 {
    padding-block: 1rem;
}

.py-6 {
    padding-block: 1.5rem;
}

.flex {
    display: flex;
}

.hidden {
    display: none;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.flex-col {
    flex-direction: column;
}

.overflow-hidden {
    overflow: hidden;
}

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

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--visa-border);
    border-radius: .375rem;
    padding: .65rem .75rem;
    background: #fff;
}

textarea {
    min-height: 7rem;
}

button,
.inline-flex {
    align-items: center;
    border-radius: .375rem;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    flex: 0 0 260px;
    height: 100vh;
    padding: 1.25rem;
    background: #111827;
    color: #e5e7eb;
}

.sidebar-brand {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.brand-logo {
    width: 2rem;
    height: 2rem;
    fill: currentColor;
}

.sidebar-nav {
    display: grid;
    gap: .35rem;
    padding-block: 1.25rem;
}

.sidebar-link,
.logout-button {
    display: block;
    width: 100%;
    padding: .7rem .85rem;
    border: 0;
    border-radius: .45rem;
    color: #cbd5e1;
    background: transparent;
    text-align: right;
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active,
.logout-button:hover {
    color: #fff;
    background: rgba(59, 130, 246, .18);
}

.sidebar-link.subtle {
    margin-top: .75rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.user-summary {
    display: grid;
    gap: .2rem;
    color: #fff;
    overflow-wrap: anywhere;
}

.user-summary span {
    color: #94a3b8;
    font-size: .85rem;
}

.app-main {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.page-header {
    padding: 1.5rem 2rem;
    background: #fff;
    border-bottom: 1px solid var(--visa-border);
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.page-content {
    padding: 2rem;
}

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

.metric-card,
.empty-panel {
    border: 1px solid var(--visa-border);
    border-radius: .5rem;
    background: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

.metric-card {
    display: grid;
    gap: .75rem;
    min-height: 8rem;
    padding: 1.25rem;
}

.metric-card span {
    color: var(--visa-muted);
    font-size: .9rem;
}

.metric-card strong {
    font-size: 2.25rem;
    line-height: 1;
}

.empty-panel {
    margin-top: 1rem;
    padding: 1.5rem;
}

.empty-panel h2 {
    margin: 0 0 .5rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.empty-panel p {
    margin: 0;
    color: var(--visa-muted);
}

.page-title-row,
.form-actions,
.filter-actions,
.table-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.page-title-row {
    justify-content: space-between;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.35rem;
    padding: .55rem .85rem;
    border-radius: .45rem;
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
}

.button.primary {
    background: #2563eb;
    color: #fff;
}

.button.secondary {
    background: #fff;
    color: var(--visa-text);
    border-color: var(--visa-border);
}

.notice {
    margin-bottom: 1rem;
    padding: .8rem 1rem;
    border-radius: .5rem;
}

.notice.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.notice.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.filter-panel,
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-panel {
    align-items: end;
    padding: 1rem;
    border: 1px solid var(--visa-border);
    border-radius: .5rem;
    background: #fff;
}

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

.form-grid label,
.filter-panel label {
    display: grid;
    gap: .4rem;
    color: var(--visa-muted);
    font-size: .9rem;
    font-weight: 600;
}

.checkbox-field {
    display: flex !important;
    align-items: center;
    gap: .5rem;
}

.checkbox-field input {
    width: auto;
}

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

.field-error {
    color: #b91c1c;
    font-size: .8rem;
}

.table-panel {
    overflow-x: auto;
    border: 1px solid var(--visa-border);
    border-radius: .5rem;
    background: #fff;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--visa-border);
    text-align: right;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    font-size: .85rem;
    white-space: nowrap;
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: .35rem .65rem;
    border-radius: .4rem;
    border: 1px solid transparent;
    font-size: .85rem;
    font-weight: 700;
    text-decoration: none;
}

.action-button.view {
    background: #eff6ff;
    color: #1d4ed8;
}

.action-button.edit {
    background: #ecfdf5;
    color: #047857;
}

.action-button.success {
    background: #16a34a;
    color: #ffffff;
}

.action-button.delete {
    background: #fef2f2;
    color: #b91c1c;
}

.inline-form {
    display: inline;
}

.inline-form button {
    cursor: pointer;
}

.empty-cell {
    color: var(--visa-muted);
    text-align: center;
}

.pagination-wrap {
    margin-top: 1rem;
}

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

.detail-list {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: .65rem 1rem;
    margin: 0;
}

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

.detail-list dd {
    margin: 0;
}

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

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

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

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

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

@media (max-width: 560px) {
    .page-header,
    .page-content {
        padding: 1rem;
    }

    .sidebar-nav,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .table-panel {
        overflow-x: visible;
        border: 0;
        background: transparent;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--visa-border);
        border-radius: .5rem;
        background: #fff;
        box-shadow: 0 10px 25px rgba(15, 23, 42, .05);
        overflow: hidden;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border-bottom: 1px solid var(--visa-border);
        text-align: left;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--visa-muted);
        font-weight: 700;
        text-align: right;
    }

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

    .table-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}
