* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #f1f4f8;
    --border: #d8dee8;
    --text: #1f2937;
    --text-soft: #5b6473;
    --primary: #2f6fed;
    --primary-soft: #e8f0ff;
    --danger: #c24141;
    --danger-soft: #fdecec;
    --success: #177245;
    --success-soft: #e8f8ef;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --radius: 10px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: Tahoma, Arial, "Noto Kufi Arabic", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

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

.sidebar {
    width: 320px;
    background: #101827;
    color: #f8fafc;
    padding: 24px 16px;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    margin-bottom: 24px;
    font-size: 1.4rem;
    font-weight: 700;
}

.sidebar__brand a {
    color: #fff;
}

.sidebar__nav {
    display: grid;
    gap: 16px;
}

.sidebar__home,
.sidebar__link {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #e5e7eb;
    font-size: 0.95rem;
}

.sidebar__home:hover,
.sidebar__link:hover,
.sidebar__home.is-active,
.sidebar__link.is-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar__section {
    display: grid;
    gap: 4px;
}

.sidebar__section-title {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-bottom: 4px;
    padding: 0 8px;
}

.content {
    flex: 1;
    padding: 24px;
    display: grid;
    gap: 16px;
}

.page-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: clamp(1.6rem, 2vw, 2rem);
    line-height: 1.3;
    margin: 0 0 4px;
}

.page-header__subtitle {
    margin: 0;
    color: var(--text-soft);
}

.page-header__actions,
.button-row,
.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.card__header {
    margin-bottom: 16px;
}

.card__header h2,
.related-links h3 {
    margin: 0 0 8px;
    font-size: 1.25rem;
}

.card__header p,
.related-links p {
    margin: 0;
    color: var(--text-soft);
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}

.alert--success {
    background: var(--success-soft);
    border-color: #bee3cf;
    color: var(--success);
}

.alert--error {
    background: var(--danger-soft);
    border-color: #f2c1c1;
    color: var(--danger);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
}

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

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

.button--small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.88rem;
}

.filter-form,
.entity-form,
.delete-form {
    display: grid;
    gap: 16px;
}

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

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

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

label {
    font-size: 0.95rem;
    font-weight: 600;
}

.required {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

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

.field-error {
    font-size: 0.9rem;
    color: var(--danger);
}

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

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

.data-table th,
.data-table td {
    text-align: right;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.93rem;
    vertical-align: top;
}

.data-table th {
    background: var(--surface-alt);
    white-space: nowrap;
}

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

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

.detail-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.detail-item__label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.detail-item__value {
    white-space: pre-wrap;
    word-break: break-word;
}

.related-links {
    margin-top: 24px;
}

.entity-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.entity-card,
.stat-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 16px;
    display: grid;
    gap: 8px;
}

.entity-card {
    transition: transform .15s ease, border-color .15s ease;
}

.entity-card:hover {
    transform: translateY(-2px);
    border-color: #b7c4df;
}

.entity-card strong {
    font-size: 1rem;
}

.entity-card span,
.stat-box__label {
    color: var(--text-soft);
    font-size: 0.92rem;
}

.stat-box__value {
    font-size: 1.6rem;
    font-weight: 700;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.88rem;
}

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

.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.pagination__link {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.pagination__link.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-footer {
    color: var(--text-soft);
    font-size: 0.92rem;
    padding-bottom: 16px;
}

@media (max-width: 1100px) {
    .sidebar {
        width: 280px;
    }
}

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

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding-bottom: 12px;
    }

    .content {
        padding: 16px;
    }

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

@media (max-width: 640px) {
    .card {
        padding: 16px;
    }

    .page-header {
        align-items: stretch;
    }

    .page-header__actions {
        width: 100%;
    }

    .button,
    .button--light,
    .button--danger {
        width: 100%;
    }

    .button-row .button,
    .button-row a {
        width: 100%;
    }
}
