:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-soft: #eef2ff;
    --accent: #0ea5e9;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --ink: #172033;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.96);
    --shadow: 0 18px 45px rgba(30, 41, 59, 0.1);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 10% 10%, rgba(14, 165, 233, 0.14), transparent 28rem),
        radial-gradient(circle at 90% 20%, rgba(79, 70, 229, 0.14), transparent 30rem),
        linear-gradient(145deg, #f8fafc 0%, #eef2ff 52%, #f0f9ff 100%);
    background-attachment: fixed;
}

body::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    content: "";
    opacity: 0.3;
    background-image: radial-gradient(rgba(79, 70, 229, 0.18) 0.75px, transparent 0.75px);
    background-size: 22px 22px;
}

a {
    text-decoration: none;
}

.app-shell {
    width: min(1540px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 54px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 22px 26px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: grid;
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.26);
}

.brand-mark svg {
    width: 27px;
    height: 27px;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.page-title {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.4rem, 2vw, 2rem);
    font-weight: 800;
}

.page-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.content-card {
    padding: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.section-heading {
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.section-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-panel {
    margin-bottom: 20px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fafc;
}

.form-label {
    margin-bottom: 7px;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 700;
}

.form-control,
.form-select {
    min-height: 48px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    color: var(--ink);
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(79, 70, 229, 0.75);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-control::placeholder {
    color: #a0aec0;
}

.form-control[readonly] {
    border-style: dashed;
    color: #475569;
    background: #f1f5f9;
}

.btn {
    min-height: 43px;
    padding: 0.58rem 1rem;
    border: 0;
    border-radius: 11px;
    font-weight: 700;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.btn:hover:not(:disabled):not(.disabled) {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    box-shadow: 0 7px 16px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-secondary {
    color: #475569;
    background: #e2e8f0;
}

.btn-secondary:hover {
    color: #1e293b;
    background: #cbd5e1;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    color: #fff;
    background: var(--danger);
}

.btn-warning {
    color: #92400e;
    background: #fef3c7;
}

.btn-warning:hover {
    color: #fff;
    background: var(--warning);
}

.btn-sm {
    min-height: 34px;
    padding: 0.35rem 0.7rem;
    border-radius: 9px;
    font-size: 0.78rem;
}

.btn-outline-secondary {
    border: 1px solid var(--line);
    color: #475569;
    background: #fff;
}

.btn-outline-secondary:hover {
    border-color: #cbd5e1;
    color: #1e293b;
    background: #f8fafc;
}

.btn-icon {
    display: inline-grid;
    width: 43px;
    padding: 0;
    place-items: center;
}

.btn-icon svg {
    width: 21px;
    height: 21px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    padding: 18px 20px;
    overflow: hidden;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: linear-gradient(135deg, #fff, #eff6ff);
}

.stat-card::after {
    position: absolute;
    top: -28px;
    left: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    content: "";
    background: rgba(79, 70, 229, 0.08);
}

.stat-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 700;
}

.stat-value {
    display: block;
    color: var(--primary-dark);
    font-size: 1.45rem;
    font-weight: 900;
    line-height: 1.2;
}

.alert {
    border: 0;
    border-radius: 13px;
    font-weight: 600;
}

.alert-success {
    color: #047857;
    background: #d1fae5;
}

.alert-danger {
    color: #b91c1c;
    background: #fee2e2;
}

.table-panel {
    padding-block: 18px;
    border: 1px solid var(--line);
    border-radius: 15px;
}

.table-panel .dataTables_scrollBody {
    overflow-x: auto !important;
}

.table-panel .dataTables_length,
.table-panel .dataTables_filter,
.table-panel .dataTables_info,
.table-panel .dataTables_paginate {
    padding-inline: 18px;
}

table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border: 0 !important;
}

table.dataTable thead th {
    padding: 15px 13px !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
    background: #27324a;
}

table.dataTable tbody td {
    padding: 13px !important;
    border-color: #edf2f7 !important;
    color: #334155;
    font-size: 0.83rem;
    vertical-align: middle;
    white-space: nowrap;
}

table.dataTable tbody tr:nth-child(even) td {
    background: #f8fafc;
}

table.dataTable tbody tr:hover td {
    background: var(--primary-soft);
}

.dataTables_wrapper {
    color: var(--muted);
    font-size: 0.88rem;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 14px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    min-height: 39px;
    margin-inline: 6px;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    background: #fff;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding-top: 16px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 0 !important;
    border-radius: 8px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    border: 0 !important;
    color: #fff !important;
    background: var(--primary) !important;
}

.form-page {
    width: min(760px, calc(100% - 28px));
    margin: 0 auto;
    padding: 28px 0 50px;
}

.form-page .app-header {
    margin-bottom: 16px;
}

.form-card {
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 18px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.form-actions .btn-primary {
    flex: 1;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(430px, 100%);
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(30, 41, 59, 0.14);
}

.login-brand {
    margin-bottom: 28px;
    text-align: center;
}

.login-brand .brand-mark {
    margin: 0 auto 15px;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 900;
}

.login-brand p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.form-check-input:checked {
    border-color: var(--primary);
    background-color: var(--primary);
}

.modal-content {
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.modal-header {
    border: 0;
    background: linear-gradient(135deg, var(--success), #10b981) !important;
}

.modal-footer {
    border-color: var(--line);
}

@media (max-width: 767.98px) {
    .app-shell {
        width: min(100% - 20px, 1540px);
        padding-top: 12px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions > *,
    .header-actions form,
    .header-actions .btn {
        flex: 1;
    }

    .content-card,
    .form-card {
        padding: 18px;
    }

    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .full-width {
        grid-column: auto;
    }

    .filter-panel .btn {
        margin-top: 0 !important;
    }

    .login-card {
        padding: 26px 20px;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: right;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
