:root {
    --bg: #ffffff;
    --bg-soft: #f5f6f7;
    --bg-muted: #eceef0;
    --border: #e4e6e8;
    --border-strong: #d1d5d8;
    --text: #1f2328;
    --text-muted: #6b7280;
    --text-soft: #4b5563;
    --accent: #111827;
    --accent-soft: #374151;
    --danger: #6b7280;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-soft);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    min-height: 100vh;
    margin: 0;
}

.navbar {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1030;
    color: var(--text);
}

.navbar .text-white {
    color: var(--text) !important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    color: var(--text);
}

.btn-outline-light {
    border-width: 1px;
    font-weight: 500;
    padding: 0.4rem 0.9rem;
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--bg);
    transition: all 0.18s ease;
}

.btn-outline-light:hover {
    background: var(--bg-soft);
    color: var(--accent);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.app-card,
.control-panel,
.info-panel,
.table-container,
.stats-bar,
.login-card,
.action-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
}

.control-panel,
.info-panel,
.stats-bar {
    padding: 22px;
    margin-bottom: 22px;
}

.control-panel h5,
.info-panel h3,
.info-panel h5 {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 18px;
}

.form-label {
    font-weight: 500;
    color: var(--text-soft);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.form-control,
.form-select {
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 8px 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.92rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.15rem rgba(17, 24, 39, 0.08);
}

.btn-secondary-custom {
    background: var(--bg-muted);
    color: var(--text-soft);
    border: 1px solid transparent;
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
}

.btn-secondary-custom:hover {
    background: var(--border-strong);
    color: var(--text);
    transform: translateY(-1px);
}

.btn-action,
.btn-custom,
.btn-primary-custom,
.btn-success-custom {
    padding: 9px 18px;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
}

.btn-primary-custom,
.btn-create,
.btn-edit {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

.btn-primary-custom:hover,
.btn-create:hover,
.btn-edit:hover {
    background: var(--accent-soft);
    color: var(--bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

.btn-success-custom,
.btn-view,
.btn-export {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-success-custom:hover,
.btn-view:hover,
.btn-export:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

.btn-download-sm {
    padding: 5px 11px;
    font-size: 0.82rem;
    border-radius: 6px;
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s ease;
}

.btn-download-sm:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn-excel {
    background: var(--bg);
    color: #16794e;
    border: 1px solid #cfe7d9;
    box-shadow: 0 1px 2px rgba(22, 121, 78, 0.05);
}

.btn-excel:hover {
    background: #e6f4ec;
    color: #16794e;
    border-color: #16794e;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(22, 121, 78, 0.18);
}

.btn-excel-sm {
    background: var(--bg);
    color: #16794e;
    border: 1px solid #cfe7d9;
    padding: 5px 11px;
    font-size: 0.82rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s ease;
}

.btn-excel-sm:hover {
    background: #e6f4ec;
    color: #16794e;
    border-color: #16794e;
    transform: translateY(-1px);
}

.btn-success-soft {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-success-soft:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

.btn-warning-soft {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-warning-soft:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

.btn-danger-soft {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    cursor: not-allowed;
    opacity: 0.85;
}

.btn-danger-soft:hover {
    background: var(--bg-soft);
    color: var(--accent);
    border-color: var(--border-strong);
    transform: none;
}

.review-comment {
    background: #fbe5e5;
    border: 1px solid #f1c4c4;
    border-radius: 6px;
    padding: 16px 20px;
    margin: 20px 0;
}

.review-comment-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #a02b2b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.review-comment-text {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.overdue-warning {
    background: rgba(177, 91, 8, 0.10);
    border: 1px solid rgba(177, 91, 8, 0.35);
    border-left: 3px solid #b15b08;
    color: #b15b08;
    border-radius: 6px;
    padding: 12px 18px;
    margin: 20px 0;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.overdue-warning i {
    font-size: 1.1rem;
}

.review-actions {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 22px;
    margin: 22px 0;
}

.review-form .form-label {
    margin-bottom: 6px;
}

.review-form textarea.form-control {
    margin-bottom: 14px;
    resize: vertical;
}

.review-form-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-export-group {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.dropdown-menu {
    border-radius: 4px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.dropdown-item {
    padding: 8px 16px;
    font-weight: 400;
    color: var(--text-soft);
}

.dropdown-item:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.table-container {
    overflow: hidden;
    margin-bottom: 22px;
}

.table {
    margin-bottom: 0;
    color: var(--text);
}

.table thead {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}

.table thead th {
    color: var(--text-soft);
    font-weight: 600;
    border: none;
    padding: 12px 14px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bg-soft);
    color: var(--text);
}

.table tbody tr:hover {
    background: var(--bg-muted);
}

.table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
    font-size: 0.93rem;
}

.sort-link {
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sort-link:hover,
.sort-link.active {
    color: var(--text);
}

.sort-link.active i {
    color: var(--accent);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.status-approved {
    background: #e6f4ec;
    color: #16794e;
    border-color: #cfe7d9;
}

.status-not-approved,
.status-submitted {
    background: #fdeed9;
    color: #b15b08;
    border-color: #f6d8b0;
}

.status-returned {
    background: #fbe5e5;
    color: #a02b2b;
    border-color: #f1c4c4;
}

.status-no-report,
.status-no-report-create,
.status-draft {
    background: var(--bg-muted);
    color: var(--text-soft);
    border-color: var(--border);
}

.status-draft-soft {
    background: var(--bg-muted);
    color: var(--text-soft);
    border-color: var(--border);
}

.score-value {
    font-weight: 600;
    color: var(--text);
    font-size: 0.98rem;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.stats-info {
    color: var(--text-muted);
    margin-top: 12px;
    font-size: 0.85rem;
    padding-left: 4px;
}

.periods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.period-card,
.assistant-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 16px;
    overflow: hidden;
}

.period-card > *:not(.period-header) {
    padding-left: 18px;
    padding-right: 18px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.period-card > .mt-3 {
    padding-top: 14px;
    padding-bottom: 18px;
}

.period-card.has-draft,
.period-card.has-returned,
.period-card.no-report {
    border-left: 3px solid var(--border-strong);
}

.period-card.has-submitted {
    border-left: 3px solid #b15b08;
}

.period-card.has-approved {
    border-left: 3px solid #16794e;
}

.period-card.no-report {
    opacity: 0.85;
}

.period-header,
.assistant-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.period-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.period-header > div:last-child {
    flex: 0 0 auto;
}

.period-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.period-year {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.3;
}

.periods-list {
    padding: 16px 20px;
}

.period-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    transition: background 0.15s;
    gap: 12px;
}

.period-item > .period-info {
    flex: 1 1 auto;
    min-width: 0;
}

.period-item:hover {
    background: var(--bg-muted);
}

.period-item.active,
.period-item.has-report {
    border-color: var(--border-strong);
    background: var(--bg);
}

.period-item.closed {
    opacity: 0.7;
}

.period-title-line {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.35;
    word-break: break-word;
}

.period-deadline {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    padding-left: 2px;
    min-height: 2.8em;
    display: flex;
    align-items: center;
}

.period-deadline i {
    margin-right: 4px;
    flex-shrink: 0;
}

.period-deadline.urgent {
    color: var(--text);
    font-weight: 500;
}

.period-deadline.overdue {
    color: #b15b08;
    font-weight: 500;
}

.period-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    margin-left: 8px;
    background: var(--bg-muted);
    color: var(--text-soft);
    vertical-align: middle;
}

.period-score {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text);
    margin-right: 12px;
    min-width: 80px;
    text-align: right;
    flex: 0 0 auto;
}

.stats-bar {
    padding: 18px 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.category-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 16px;
    overflow: hidden;
}

.category-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
}

.category-header h5 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
}

.info-panel {
    border-left: 3px solid var(--accent);
}

.info-panel h3 {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 8px;
}

.criterion-name {
    font-weight: 500;
    color: var(--text);
}

.criterion-name.parent {
    font-weight: 600;
    color: var(--text);
}

.criterion-name.child {
    padding-left: 24px;
    font-size: 0.92rem;
    color: var(--text-soft);
}

.criterion-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.score-cell {
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.detail-link {
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

.detail-link:hover {
    color: var(--accent-soft);
    text-decoration: underline;
}

.auto-value {
    color: var(--text-muted);
    font-style: italic;
}

.auto-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.total-card,
.total-panel {
    background: var(--accent);
    color: var(--bg);
    border-radius: 6px;
    padding: 22px;
    margin-top: 22px;
    margin-bottom: 22px;
}

.total-card h4,
.total-panel h4 {
    margin: 0;
    font-weight: 600;
    font-size: 1.3rem;
}

.total-item {
    text-align: center;
    padding: 10px;
}

.total-item h5 {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 8px;
    font-weight: 400;
}

.total-item h4 {
    font-size: 1.7rem;
    font-weight: 600;
    margin: 0;
}

.total-item small {
    display: block;
    margin-top: 4px;
    opacity: 0.7;
    font-size: 0.78rem;
}

.total-panel-success {
    background: #e6f4ec;
    color: #16794e;
    border: 1px solid #cfe7d9;
}

.total-panel-success .total-item h5 {
    opacity: 0.75;
}

.total-panel-success .total-item small {
    opacity: 0.65;
}

.action-bar {
    position: sticky;
    bottom: 20px;
    z-index: 100;
    margin-top: 24px;
}

.action-card {
    padding: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-card-navbar {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 14px 18px;
    max-width: 520px;
    margin: 18px auto;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.action-card-navbar .btn:hover {
    background: var(--bg-soft);
    color: var(--accent);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1040;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: opacity 0.25s ease, transform 0.25s ease;
    text-decoration: none;
    padding: 0;
}

.scroll-top-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
}

.scroll-top-btn svg {
    display: block;
    margin: 0 auto;
}

.scroll-top-btn.visible {
    display: flex;
}

.scroll-top-btn:hover {
    background: var(--bg-soft);
    color: var(--accent);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

input[type="number"] {
    text-align: right;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.9rem;
}

input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.15rem rgba(17, 24, 39, 0.08);
    outline: none;
}

input[type="number"]:read-only {
    background: var(--bg-soft);
}

.status-banner {
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-weight: 500;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.status-banner.draft {
    background: var(--bg-muted);
}

.status-banner.submitted {
    background: var(--bg);
}

.status-banner.approved {
    background: var(--accent);
    color: var(--bg);
}

.status-banner.returned {
    background: #fbe5e5;
    color: #a02b2b;
    border-color: #f1c4c4;
}

.login-card {
    padding: 32px;
    max-width: 380px;
    width: 100%;
    margin: auto;
}

.login-card h2 {
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 1.4rem;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    border-radius: 8px;
    padding: 9px 18px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
    transition: all 0.18s ease;
}

.btn-primary:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.12);
}

body.login-body {
    background: var(--bg-soft);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-hint {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    text-align: right;
}

.export-toast,
.toast-notify {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    background: rgba(160, 43, 43, 0.12);
    color: #a02b2b;
    border: 1px solid rgba(160, 43, 43, 0.35);
    border-left: 3px solid #a02b2b;
    border-radius: 8px;
    padding: 12px 18px;
    box-shadow: 0 6px 24px rgba(160, 43, 43, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    max-width: 380px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: auto;
    cursor: pointer;
}

.toast-notify.toast-success {
    background: rgba(22, 121, 78, 0.12);
    color: #16794e;
    border: 1px solid rgba(22, 121, 78, 0.35);
    border-left: 3px solid #16794e;
    box-shadow: 0 6px 24px rgba(22, 121, 78, 0.12);
}

.toast-notify.toast-success:hover {
    background: rgba(22, 121, 78, 0.18);
    border-color: rgba(22, 121, 78, 0.5);
}

.toast-notify.toast-warning {
    background: rgba(177, 91, 8, 0.12);
    color: #b15b08;
    border: 1px solid rgba(177, 91, 8, 0.35);
    border-left: 3px solid #b15b08;
    box-shadow: 0 6px 24px rgba(177, 91, 8, 0.12);
}

.toast-notify.toast-warning:hover {
    background: rgba(177, 91, 8, 0.18);
    border-color: rgba(177, 91, 8, 0.5);
}

.toast-notify.toast-error {
    background: rgba(160, 43, 43, 0.12);
    color: #a02b2b;
    border: 1px solid rgba(160, 43, 43, 0.35);
    border-left: 3px solid #a02b2b;
    box-shadow: 0 6px 24px rgba(160, 43, 43, 0.12);
}

.toast-notify.toast-error:hover {
    background: rgba(160, 43, 43, 0.18);
    border-color: rgba(160, 43, 43, 0.5);
}

.export-toast:hover {
    background: rgba(160, 43, 43, 0.18);
    border-color: rgba(160, 43, 43, 0.5);
}

.export-toast.show,
.toast-notify.show {
    opacity: 1;
    transform: translateY(0);
}

.export-toast i,
.toast-notify i {
    font-size: 1.1rem;
}

.toast-notify.toast-success i {
    color: #16794e;
}

.toast-notify.toast-warning i {
    color: #b15b08;
}

.toast-notify.toast-error i {
    color: #a02b2b;
}

@media (max-width: 768px) {