:root {
    --brand-primary: #3b82f6;
    --brand-primary-dark: #2563eb;
    --brand-ink: #0f172a;
    --brand-muted: #64748b;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border-soft: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 0% 0%, #e0ecff 0%, transparent 45%),
        radial-gradient(circle at 100% 10%, #efe9ff 0%, transparent 40%),
        #f6f8fc;
    color: var(--brand-ink);
}

.app-shell .sidebar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-soft);
}

.app-shell .sidebar-header h4 {
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}

.app-shell .sidebar-nav .nav-link {
    margin: 0.15rem 0.65rem;
    border-radius: 0.65rem;
    font-weight: 500;
}

.app-shell .sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, #e6f0ff 0%, #edf4ff 100%);
    box-shadow: 0 6px 16px -12px rgba(37, 99, 235, 0.95);
}

.app-shell .top-bar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}

.app-shell .content-area {
    padding: 1.75rem;
}

.card {
    border: 1px solid var(--border-soft);
    border-radius: 1rem;
    box-shadow: 0 12px 30px -22px rgba(15, 23, 42, 0.55);
}

.card-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-bottom: 1px solid var(--border-soft);
    border-top-left-radius: 1rem !important;
    border-top-right-radius: 1rem !important;
    padding: 0.95rem 1.1rem;
}

.btn {
    border-radius: 0.65rem;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
    border-color: transparent;
    box-shadow: 0 12px 24px -16px rgba(37, 99, 235, 0.85);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: transparent;
}

.btn-outline-primary {
    border-color: #bfdbfe;
    color: var(--brand-primary-dark);
}

.btn-outline-primary:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.form-control,
.form-select {
    border: 1px solid #d9e3f3;
    border-radius: 0.65rem;
    padding: 0.62rem 0.8rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    background: #f7faff;
    border-top: 0;
}

.table tbody tr {
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.nav-tabs {
    border: 0;
    gap: 0.55rem;
}

.nav-tabs .nav-link {
    border: 1px solid #dbe5f5;
    border-radius: 999px;
    color: #334155;
    font-weight: 600;
}

.nav-tabs .nav-link.active {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: #eaf3ff;
}

.alert {
    border: 1px solid #dbeafe;
    border-radius: 0.75rem;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background:
        radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.23), transparent 38%),
        radial-gradient(circle at 100% 0%, rgba(124, 58, 237, 0.2), transparent 34%),
        linear-gradient(160deg, #eef4ff 0%, #f8fbff 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dfe8f7;
    border-radius: 1rem;
    box-shadow: 0 22px 60px -34px rgba(30, 64, 175, 0.45);
    padding: 1.75rem;
}

.auth-logo {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    display: grid;
    place-items: center;
    margin: 0 auto 0.85rem;
    font-size: 1.3rem;
}

.auth-subtitle {
    color: var(--brand-muted);
    font-size: 0.95rem;
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.error-card {
    max-width: 540px;
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe5f5;
    border-radius: 1rem;
    box-shadow: 0 20px 48px -34px rgba(15, 23, 42, 0.6);
    padding: 2rem;
    text-align: center;
}

.error-card h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .app-shell .content-area {
        padding: 1rem;
    }
}

/* Legacy class compatibility while templates are progressively simplified. */
body {
    margin: 0;
    line-height: 1.5;
}

a {
    color: inherit;
}

.container {
    width: min(100%, 1200px);
    margin-inline: auto;
    padding-inline: 1rem;
}

.container-fluid {
    width: 100%;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-inline: -0.5rem;
}

.row > * {
    width: 100%;
    padding-inline: 0.5rem;
}

.g-3 { row-gap: 1rem; }
.g-4 { row-gap: 1.5rem; }

.col-6 { width: 50%; }
.col-12 { width: 100%; }

@media (min-width: 640px) {
    .col-sm-3 { width: 25%; }
    .col-sm-4 { width: 33.333333%; }
    .col-sm-6 { width: 50%; }
    .col-sm-8 { width: 66.666667%; }
    .col-sm-9 { width: 75%; }
}

@media (min-width: 768px) {
    .col-md-2 { width: 16.666667%; }
    .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.333333%; }
    .col-md-6 { width: 50%; }
    .col-md-8 { width: 66.666667%; }
    .d-md-none { display: none !important; }
}

@media (min-width: 1024px) {
    .col-lg-3 { width: 25%; }
    .col-lg-4 { width: 33.333333%; }
    .col-lg-6 { width: 50%; }
    .col-lg-8 { width: 66.666667%; }
}

.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-break { word-break: break-word !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-nowrap { white-space: nowrap !important; }
.flex-grow-1 { flex: 1 1 auto !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.gap-2 { gap: 0.5rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 2rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-auto { margin-left: auto !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.my-2 { margin-block: 0.5rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.py-4 { padding-block: 1.5rem !important; }
.py-5 { padding-block: 2rem !important; }

.h3 { font-size: 1.5rem; }
.fs-1 { font-size: 2.25rem; }
.display-1 { font-size: 4rem; line-height: 1; }
.small, small { font-size: 0.875rem; }
.lead { font-size: 1.125rem; }

.fw-bold { font-weight: 700 !important; }

.text-muted { color: #64748b !important; }
.text-primary { color: #2563eb !important; }
.text-success { color: #059669 !important; }
.text-warning { color: #d97706 !important; }
.text-danger { color: #dc2626 !important; }
.text-info { color: #0284c7 !important; }
.text-dark { color: #0f172a !important; }
.text-secondary { color: #475569 !important; }
.text-white { color: #fff !important; }

.bg-light { background: #f8fafc !important; }
.bg-dark { background: #0f172a !important; color: #fff !important; }
.bg-primary { background: #2563eb !important; color: #fff !important; }
.rounded { border-radius: 0.75rem !important; }
.border { border: 1px solid #dbe3f0 !important; }

.card-body { padding: 1.1rem; }
.card-footer { padding: 0.9rem 1.1rem; border-top: 1px solid #e2e8f0; }

.btn {
    border: 1px solid transparent;
    border-radius: 0.65rem;
    padding: 0.55rem 0.9rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.btn-secondary {
    color: #fff;
    background: #475569;
}

.btn-outline-primary {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #fff;
}

.btn-outline-primary:hover { background: #eff6ff; }

.btn-outline-secondary {
    color: #334155;
    border-color: #cbd5e1;
    background: #fff;
}

.btn-outline-success {
    color: #047857;
    border-color: #a7f3d0;
    background: #fff;
}

.btn-outline-warning {
    color: #b45309;
    border-color: #fcd34d;
    background: #fff;
}

.btn-outline-danger {
    color: #b91c1c;
    border-color: #fca5a5;
    background: #fff;
}

.btn-outline-info {
    color: #0369a1;
    border-color: #7dd3fc;
    background: #fff;
}

.btn-success {
    color: #fff;
    background: #059669;
}

.btn-link {
    color: #334155;
    background: transparent;
    border-color: transparent;
    padding: 0.25rem 0.35rem;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.4rem 0.65rem;
}

.btn-group {
    display: inline-flex;
    border-radius: 0.75rem;
    overflow: hidden;
}

.btn-group > .btn,
.btn-group > label.btn {
    border-radius: 0;
}

.btn-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.btn-check:checked + .btn-outline-primary {
    background: #e0edff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.form-label {
    display: inline-block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: #334155;
}

.form-control,
.form-select {
    width: 100%;
    border: 1px solid #cfd9ea;
    border-radius: 0.7rem;
    background: #fff;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
}

.form-control-sm { padding: 0.4rem 0.6rem; font-size: 0.85rem; }

.form-control:focus,
.form-select:focus {
    border-color: #93c5fd;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-floating {
    position: relative;
}

.form-floating > .form-control {
    padding-top: 1.4rem;
    padding-bottom: 0.45rem;
}

.form-floating > label {
    position: absolute;
    left: 0.75rem;
    top: 0.6rem;
    font-size: 0.82rem;
    color: #64748b;
}

.form-text {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #64748b;
}

.input-group {
    display: flex;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn,
.input-group .input-group-text {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-text {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border: 1px solid #cfd9ea;
    background: #f8fafc;
    color: #475569;
}

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

.table th,
.table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.7rem 0.65rem;
    vertical-align: middle;
}

.table th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    background: #f8fbff;
}

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

.table-dark th { background: #0f172a !important; color: #fff !important; }
.table-light th { background: #f8fafc !important; color: #475569 !important; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.bg-danger { background: #fee2e2 !important; color: #991b1b !important; }
.bg-secondary { background: #e2e8f0 !important; color: #334155 !important; }
.bg-info { background: #e0f2fe !important; color: #075985 !important; }

.nav {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.nav-tabs {
    display: flex;
    gap: 0.45rem;
    border-bottom: 0;
}

.nav-tabs .nav-link {
    border: 1px solid #d7e3f5;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
}

.nav-tabs .nav-link.active {
    border-color: #93c5fd;
    background: #eaf3ff;
    color: #1d4ed8;
}

.tab-content > .tab-pane {
    display: none;
}

.tab-content > .active {
    display: block;
}

.fade { transition: opacity 0.18s linear; }
.fade:not(.show) { opacity: 0; }

.pagination {
    display: flex;
    gap: 0.35rem;
    list-style: none;
    padding: 0;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.55rem;
    background: #fff;
    color: #334155;
    text-decoration: none;
}

.page-item.active .page-link {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.page-item.disabled .page-link {
    opacity: 0.55;
    pointer-events: none;
}

.alert {
    border-radius: 0.75rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid;
    margin-bottom: 1rem;
}

.alert-success { color: #14532d; border-color: #86efac; background: #f0fdf4; }
.alert-info { color: #0c4a6e; border-color: #7dd3fc; background: #f0f9ff; }
.alert-warning { color: #78350f; border-color: #fcd34d; background: #fffbeb; }
.alert-danger,
.alert-error { color: #7f1d1d; border-color: #fca5a5; background: #fef2f2; }

.alert-dismissible {
    position: relative;
    padding-right: 2.3rem;
}

.btn-close {
    position: absolute;
    right: 0.6rem;
    top: 0.55rem;
    width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    opacity: 0.65;
}

.btn-close::before {
    content: "×";
    font-size: 1.2rem;
    line-height: 1;
    color: #334155;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
    overflow-x: hidden;
    overflow-y: auto;
}

.modal.show { display: block; }

.modal-dialog {
    width: min(100% - 1.5rem, 560px);
    margin: 1.75rem auto;
}

.modal-dialog-centered {
    display: flex;
    min-height: calc(100% - 3.5rem);
    align-items: center;
}

.modal-content {
    width: 100%;
    background: #fff;
    border: 1px solid #dbe3f0;
    border-radius: 1rem;
}

.modal-header,
.modal-body,
.modal-footer {
    padding: 1rem 1.1rem;
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-title {
    margin: 0;
    font-size: 1.05rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(15, 23, 42, 0.55);
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15rem;
}

.spinner-border {
    display: inline-block;
    border: 0.2rem solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-rotate 0.75s linear infinite;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}
