:root {
    --tar-red: #d90429;
    --tar-red-dark: #9d0208;
    --tar-ink: #111827;
    --tar-muted: #6b7280;
    --tar-surface: #ffffff;
    --tar-bg: #f4f6f9;
    --tar-border: #e5e7eb;
}

html {
    min-height: 100%;
}

body.app-shell {
    margin: 0;
    min-height: 100vh;
    background: var(--tar-bg);
    color: var(--tar-ink);
    font-family: "Segoe UI", Arial, sans-serif;
}

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

.app-sidebar {
    width: 280px;
    background: linear-gradient(to bottom, #ef233c 0%, #d90429 48%, #b20d1c 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    inset-block-start: 0;
    height: 100vh;
    z-index: 1040;
}

.sidebar-header {
    padding: 0 0 14px;
    border-bottom: 1px solid rgba(255,255,255,.16);
    text-align: center;
}

.sidebar-logo-wrap {
    display: block;
    width: 100%;
    text-decoration: none;
    box-shadow: 0 1px 0 rgba(255,255,255,.22), 0 10px 22px rgba(0,0,0,.16);
}

.sidebar-logo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar-brand {
    display: block;
    margin-top: 12px;
    padding-inline: 14px;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    text-decoration: none;
}

.sidebar-subtitle {
    margin-top: 4px;
    padding-inline: 14px;
    color: rgba(255,255,255,.78);
    font-size: .82rem;
    line-height: 1.25;
}

.sidebar-nav {
    padding: 10px;
    overflow: auto;
    flex: 1;
}

.nav-section {
    margin: 14px 10px 8px;
    color: rgba(255,255,255,.72);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.nav-item,
.nav-subitem {
    color: rgba(255,255,255,.92);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.nav-item i {
    font-size: 1rem;
}

.nav-item:hover,
.nav-subitem:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
}

.nav-item.active,
.nav-subitem.active {
    color: #fff;
    background: rgba(255,255,255,.18);
}

.nav-group {
    margin-bottom: 5px;
}

.nav-group > summary {
    list-style: none;
    cursor: pointer;
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

.chevron {
    margin-inline-start: auto;
    font-size: .85rem;
}

.nav-group[open] .chevron {
    transform: rotate(180deg);
}

.nav-sub {
    padding-block: 6px 8px;
    padding-inline: 38px 6px;
}

.nav-subitem {
    display: block;
    padding: 8px 10px;
    font-size: .93rem;
}

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

.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.94);
    font-weight: 600;
}

.app-main {
    flex: 1;
    min-width: 0;
    background: var(--tar-bg);
}

.app-topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid rgba(17,24,39,.08);
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-weight: 600;
}

.topbar-breadcrumb .crumb {
    color: var(--tar-ink);
    text-decoration: none;
}

.topbar-breadcrumb .crumb-sep {
    color: #9ca3af;
}

.app-content {
    padding: 18px;
}

.sidebar-toggle {
    display: none;
}

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

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 3px;
}

.page-subtitle {
    color: var(--tar-muted);
    margin: 0;
}

.app-card,
.filter-card,
.table-card,
.section-card,
.kpi-card {
    background: var(--tar-surface);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(15,23,42,.07);
}

.app-card .card-header,
.table-card .card-header,
.section-card .card-header {
    background: #f9fafb;
    border-bottom: 1px solid var(--tar-border);
    font-weight: 700;
}

.filter-card {
    padding: 16px;
    margin-bottom: 16px;
}

.form-label {
    font-weight: 600;
    color: #374151;
    font-size: .9rem;
}

.form-control,
.form-select {
    border-color: #d1d5db;
    border-radius: 7px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tar-red);
    box-shadow: 0 0 0 .18rem rgba(217,4,41,.16);
}

.validation-summary-valid {
    display: none;
}

.btn {
    border-radius: 7px;
    font-weight: 600;
}

.btn-primary {
    background: var(--tar-red);
    border-color: var(--tar-red);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--tar-red-dark);
    border-color: var(--tar-red-dark);
}

.btn-outline-primary {
    color: var(--tar-red);
    border-color: var(--tar-red);
}

.btn-outline-primary:hover {
    background: var(--tar-red);
    border-color: var(--tar-red);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f9fafb;
    color: #374151;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--tar-border);
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #fff5f6;
}

.action-bar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

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

.badge-soft-secondary {
    background: #e5e7eb;
    color: #374151;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #991b1b;
}

.cord-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--tar-border);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: .82rem;
    font-weight: 700;
    background: #fff;
}

.cord-dot,
.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,.16);
}

.profile-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 999px;
    border: 1px solid var(--tar-border);
    background: #fff;
}

.profile-placeholder {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 700;
    border: 1px solid var(--tar-border);
}

.kpi-card {
    padding: 18px;
    height: 100%;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff1f2;
    color: var(--tar-red);
    font-size: 1.25rem;
}

.kpi-label {
    color: var(--tar-muted);
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 750;
    line-height: 1.1;
}

.chart-frame {
    height: 320px;
}

.detail-photo {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--tar-border);
    background: #fff;
}

.photo-preview-frame {
    width: 100%;
}

.photo-preview-image,
.photo-preview-placeholder {
    min-height: 180px;
}

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

.definition-label {
    color: var(--tar-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 700;
}

.definition-value {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.definition-span {
    grid-column: 1 / -1;
}

.attendance-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.attendance-search {
    position: relative;
    flex: 1 1 280px;
}

.attendance-search i {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 12px;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.attendance-search .form-control {
    padding-inline-start: 36px;
}

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

.attendance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

.attendance-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 64px;
    padding: 10px;
    border: 1px solid var(--tar-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.attendance-option:hover {
    border-color: rgba(217,4,41,.4);
    background: #fff7f8;
}

.attendance-option .form-check-input {
    margin: 2px 0 0;
    flex: 0 0 auto;
}

.attendance-name,
.attendance-meta {
    display: block;
}

.attendance-name {
    font-weight: 700;
    line-height: 1.2;
}

.attendance-meta {
    margin-top: 3px;
    color: var(--tar-muted);
    font-size: .82rem;
    line-height: 1.25;
}

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(157,2,8,.88), rgba(17,24,39,.82)),
        radial-gradient(circle at 20% 15%, rgba(255,255,255,.16), transparent 30%),
        #111827;
}

.login-card {
    width: min(430px, 100%);
    margin: 0;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 48px rgba(0,0,0,.36);
}

.login-logo-banner {
    width: 100%;
    background: #b00013;
    line-height: 0;
}

.login-logo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.login-body {
    padding: 26px 28px 28px;
}

@media (max-width: 992px) {
    .sidebar-toggle {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        inset-inline-start: 0;
        width: min(280px, 100vw);
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 18px 36px rgba(0,0,0,.28);
    }

    [dir="rtl"] .app-sidebar {
        transform: translateX(100%);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-main {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .app-content {
        padding: 12px;
    }

    .page-title {
        font-size: 1.35rem;
    }

    .definition-grid {
        grid-template-columns: 1fr;
    }

    .chart-frame {
        height: 270px;
    }

    .attendance-grid {
        grid-template-columns: 1fr;
    }

    .attendance-toolbar {
        display: block;
    }

    .attendance-actions {
        margin-top: 10px;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .no-print {
        display: none !important;
    }

    .app-layout,
    .app-main,
    .app-content {
        display: block;
        min-height: 0;
        padding: 0;
        background: #fff;
    }

    .card,
    .table-card,
    .section-card {
        box-shadow: none;
        border: 1px solid #d1d5db;
    }
}
