@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f4efe6;
    --bg-accent: #fff8ee;
    --surface: rgba(255, 252, 247, 0.9);
    --surface-strong: #fffdf9;
    --surface-muted: #f5ede1;
    --line: rgba(109, 85, 53, 0.16);
    --line-strong: rgba(109, 85, 53, 0.28);
    --text: #2d241a;
    --muted: #726252;
    --primary: #1f7a74;
    --primary-deep: #145b56;
    --accent: #ea8f47;
    --accent-deep: #c56a28;
    --success: #3f8f5a;
    --danger: #cc5f48;
    --warning: #d89232;
    --shadow-lg: 0 24px 70px rgba(65, 43, 21, 0.12);
    --shadow-md: 0 14px 34px rgba(65, 43, 21, 0.08);
    --shadow-sm: 0 8px 18px rgba(65, 43, 21, 0.06);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    min-height: 100vh;
    padding: 32px 20px 56px;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(234, 143, 71, 0.24), transparent 24%),
        radial-gradient(circle at top right, rgba(31, 122, 116, 0.18), transparent 28%),
        linear-gradient(180deg, #f8f3eb 0%, #efe6d8 100%);
    position: relative;
}

body::before,
body::after {
    content: '';
    position: fixed;
    z-index: 0;
    pointer-events: none;
    border-radius: 999px;
    filter: blur(12px);
}

body::before {
    width: 320px;
    height: 320px;
    top: -60px;
    right: -80px;
    background: rgba(234, 143, 71, 0.18);
}

body::after {
    width: 280px;
    height: 280px;
    bottom: 8%;
    left: -80px;
    background: rgba(31, 122, 116, 0.14);
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1380px;
    margin: 0 auto;
    padding: 34px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 253, 249, 0.96) 0%, rgba(252, 247, 240, 0.92) 100%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

header {
    display: grid;
    gap: 18px;
    margin-bottom: 26px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

header h1 {
    font-size: clamp(2rem, 3.2vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.subtitle {
    max-width: 760px;
    margin-top: -8px;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.7;
}

.top-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.top-nav a {
    padding: 11px 16px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease, color 0.22s ease;
}

.top-nav a:hover {
    transform: translateY(-1px);
    color: var(--primary-deep);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.top-nav a.active {
    color: #fefefe;
    background: linear-gradient(135deg, var(--primary) 0%, #2d9088 100%);
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(31, 122, 116, 0.24);
}

.instructions,
.data-section,
.summary-section,
.filter-section,
.results-section,
.log-section {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.76);
    border-radius: 22px;
    box-shadow: var(--shadow-md);
}

.instructions {
    margin-bottom: 24px;
    padding: 22px 24px;
    background:
        linear-gradient(135deg, rgba(255, 248, 238, 0.96) 0%, rgba(246, 239, 226, 0.96) 100%);
}

.instructions h3 {
    margin-bottom: 12px;
    font-size: 1.08rem;
    color: var(--primary-deep);
}

.instructions ul,
.instructions ol {
    margin-left: 18px;
    line-height: 1.85;
    color: var(--muted);
}

.instructions li + li {
    margin-top: 2px;
}

.submit-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 22px;
}

.submit-btn,
.btn-submit {
    background: linear-gradient(135deg, var(--primary) 0%, #2b8c84 100%);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
    box-shadow: 0 14px 28px rgba(31, 122, 116, 0.24);
}

.submit-btn:hover,
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 32px rgba(31, 122, 116, 0.28);
}

.submit-btn:active,
.btn-submit:active {
    transform: translateY(0);
}

.submit-btn:disabled,
.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.status-message {
    margin: 0 0 22px;
    padding: 14px 18px;
    border-radius: 14px;
    font-weight: 700;
    display: none;
    animation: slideIn 0.24s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-message.success {
    display: block;
    color: #14532d;
    background: rgba(191, 245, 210, 0.92);
    border: 1px solid rgba(63, 143, 90, 0.28);
}

.status-message.error {
    display: block;
    color: #7f1d1d;
    background: rgba(255, 226, 221, 0.96);
    border: 1px solid rgba(204, 95, 72, 0.28);
}

.status-message.loading {
    display: block;
    color: #0f4c5c;
    background: rgba(219, 240, 244, 0.96);
    border: 1px solid rgba(31, 122, 116, 0.24);
}

.data-section,
.summary-section,
.results-section,
.filter-section {
    margin-bottom: 24px;
    padding: 24px;
}

.data-section h2,
.summary-section h2,
.results-section h2,
.filter-section h2,
.log-section h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    color: var(--text);
}

.table-container {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.data-section .table-container {
    max-height: 540px;
    overflow-y: auto;
}

.summary-section .table-container {
    max-height: none;
    overflow-y: visible;
}

.data-table,
.summary-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

.data-table thead,
.summary-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table thead {
    background: linear-gradient(135deg, #275f6d 0%, #1f7a74 55%, #2f8c84 100%);
    color: #fff;
}

.summary-table thead {
    background: linear-gradient(135deg, #3c8f5b 0%, #4a9c67 100%);
    color: #fff;
}

.data-table th,
.summary-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.data-table tbody tr,
.summary-table tbody tr,
.results-table tbody tr {
    border-bottom: 1px solid rgba(109, 85, 53, 0.12);
    transition: background-color 0.18s ease;
}

.data-table tbody tr:hover,
.summary-table tbody tr:hover,
.results-table tbody tr:hover {
    background: rgba(244, 239, 230, 0.72);
}

.data-table td,
.summary-table td,
.results-table td,
.results-table th {
    padding: 14px 16px;
    min-width: 120px;
    position: relative;
}

.summary-table td:last-child {
    font-weight: 800;
    color: var(--success);
}

.data-table .editable-cell {
    width: 100%;
    min-height: 1.55rem;
    display: block;
    padding: 4px 2px;
    border-radius: 8px;
    cursor: text;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.data-table .editable-cell:hover {
    background: rgba(31, 122, 116, 0.08);
}

.data-table .editable-cell:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.18);
}

.data-table .editable-cell:empty::before {
    content: attr(data-placeholder);
    color: #b29f89;
    font-style: italic;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.btn-add,
.btn-delete-selected,
.btn-clear-all,
.btn-search,
.btn-clear-log {
    border: none;
    border-radius: 999px;
    padding: 11px 18px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
    color: #fff;
}

.btn-add {
    background: linear-gradient(135deg, var(--success) 0%, #4c9d66 100%);
    box-shadow: 0 12px 24px rgba(63, 143, 90, 0.22);
}

.btn-delete-selected {
    background: linear-gradient(135deg, var(--danger) 0%, #b24f3c 100%);
    box-shadow: 0 12px 24px rgba(204, 95, 72, 0.2);
}

.btn-clear-all {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    box-shadow: 0 12px 24px rgba(234, 143, 71, 0.22);
}

.btn-search {
    background: linear-gradient(135deg, var(--primary) 0%, #2d9088 100%);
    box-shadow: 0 12px 24px rgba(31, 122, 116, 0.2);
}

.btn-clear-log {
    background: linear-gradient(135deg, #6c5f4f 0%, #554838 100%);
    box-shadow: 0 12px 24px rgba(84, 72, 56, 0.18);
}

.btn-add:hover,
.btn-delete-selected:hover,
.btn-clear-all:hover,
.btn-search:hover,
.btn-clear-log:hover {
    transform: translateY(-2px);
}

.btn-remove {
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(204, 95, 72, 0.14);
    color: var(--danger);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.btn-remove:hover {
    background: rgba(204, 95, 72, 0.22);
    transform: scale(1.04);
}

.work-types-info {
    margin-top: 12px;
    padding: 14px 16px;
    background: rgba(31, 122, 116, 0.08);
    border: 1px solid rgba(31, 122, 116, 0.1);
    border-radius: 14px;
    font-size: 0.92rem;
    color: var(--muted);
}

.work-types-info strong {
    color: var(--text);
}

.log-section {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(180deg, #32291f 0%, #231c15 100%);
    color: #f7f1e8;
}

.log-section h2 {
    color: #fff6eb;
}

.log-container,
.log-box {
    background: rgba(10, 9, 7, 0.36);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px 18px;
    min-height: 180px;
    max-height: 320px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    color: #f2e7d8;
}

.log-container:empty::before,
.log-box:empty::before {
    content: 'Chưa có nhật ký nào. Hệ thống sẽ hiển thị trạng thái xử lý tại đây.';
    color: rgba(242, 231, 216, 0.56);
    font-style: italic;
}

.log-entry {
    margin-bottom: 8px;
}

.log-entry.info {
    color: #9fd3f8;
}

.log-entry.success {
    color: #8de1a8;
}

.log-entry.error {
    color: #ffb4a6;
}

.log-entry.warning {
    color: #f7cf8f;
}

.log-timestamp {
    color: rgba(255, 255, 255, 0.48);
    margin-right: 8px;
}

.search-row {
    background: rgba(255, 248, 238, 0.92);
}

.search-row th {
    padding: 10px 12px;
}

.search-input,
.filter-group input,
.filter-group select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid rgba(109, 85, 53, 0.18);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.86);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.search-input::placeholder,
.filter-group input::placeholder {
    color: #af9c87;
}

.search-input:focus,
.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: rgba(31, 122, 116, 0.42);
    box-shadow: 0 0 0 4px rgba(31, 122, 116, 0.12);
    background: #fff;
}

.validation-errors {
    background: rgba(255, 234, 228, 0.92);
    border: 1px solid rgba(204, 95, 72, 0.3);
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 16px;
    color: #7f1d1d;
}

.validation-errors .error-header {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.validation-errors ul {
    margin: 0;
    padding-left: 20px;
}

.validation-errors li + li {
    margin-top: 4px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-button {
    padding: 12px 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tab-button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #2d9088 100%);
    border-color: transparent;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.log-header h3 {
    font-size: 1rem;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

@media (max-width: 900px) {
    .container {
        padding: 24px 18px;
    }

    .submit-container {
        flex-direction: column;
        align-items: stretch;
    }

    .submit-btn,
    .btn-submit {
        width: 100%;
    }

    .top-nav {
        gap: 10px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px 12px 36px;
    }

    .container {
        padding: 20px 14px;
        border-radius: 22px;
    }

    header h1 {
        font-size: 1.85rem;
    }

    .data-section,
    .summary-section,
    .results-section,
    .filter-section,
    .instructions,
    .log-section {
        padding: 18px;
        border-radius: 18px;
    }

    .data-table th,
    .summary-table th,
    .data-table td,
    .summary-table td,
    .results-table th,
    .results-table td {
        padding: 12px 10px;
        min-width: 88px;
        font-size: 0.88rem;
    }

    .action-buttons,
    .top-nav {
        flex-direction: column;
    }

    .btn-add,
    .btn-delete-selected,
    .btn-clear-all,
    .btn-search,
    .btn-clear-log {
        width: 100%;
        justify-content: center;
    }
}
