@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-muted: #f8fafc;
    --bg-soft: #f8fafc;
    --text-primary: #020617;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary-color: #0f172a;
    --primary-hover: #1e293b;
    --primary-soft: #f1f5f9;
    --success-bg: #f0fdf4;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --warning-bg: #fefce8;
    --warning-text: #854d0e;
    --focus-ring: #cbd5e1;
    --flag-bg: #fff7ed;
    --flag-text: #7c2d12;
    --flag-border: #ea580c;
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --font-heading: 'IBM Plex Sans', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
    --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.04);
    --shadow-md: 0 4px 12px rgba(2, 6, 23, 0.06);
    --ease-std: 200ms ease;
}

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

html {
    color-scheme: light;
}

body {
    min-height: 100dvh;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input {
    font: inherit;
}

button {
    touch-action: manipulation;
}

button,
label,
input[type="checkbox"] {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

::selection {
    background: var(--primary-color);
    color: #ffffff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 2000;
    transform: translateY(-150%);
    background: var(--text-primary);
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.is-hidden {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.app-container {
    width: min(100%, 1600px);
    min-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem;
}



.header-actions,
.footer-content {
    display: flex;
    align-items: center;
}

/* HEADER */
.header{
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    padding: 2rem 2rem;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    border-radius: 0 0 50px 50px;

}
.header .logo-group{
    display: flex;
    flex-direction: column;
}
.header .logo-group img{
    height: 32px;
}
.header .header-title{
    font-size: 36px;
    color: black;
    font-weight: 400;
    line-height: 1.3;
    font-family: var(--font-mono);
}
.header .header-subtitle{
    font-size: 14px;
    color: #64748b;
}

/* MAIN */
.main-content {
    flex: 1;
}

.section-heading {
    grid-column: 1 / -1;
    text-align: center;
    width: 100%;
    /* background-color: white; */
}

.section-heading h2 {
    font-weight: 300;
    margin-top: 1rem;
    font-size: 20px;
}

.btn,
.btn-master-upload,
.stat-button,
.column-toggle-btn {
    min-height: 44px;
    border-radius: var(--radius-sm);
    transition: background-color var(--ease-std), color var(--ease-std), border-color var(--ease-std), box-shadow var(--ease-std);
}

.btn,
.btn-master-upload,
.stat-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-strong);
    font-weight: 500;
    background: var(--bg-surface);
    color: var(--text-primary);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:not(:disabled):hover,
.btn-primary:not(:disabled):focus-visible {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn:disabled {
    opacity: 0.48;
}

.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1.5rem;
}

.upload-card {
    width: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: border-color var(--ease-std), box-shadow var(--ease-std), background-color var(--ease-std);
}

.upload-card:hover,
.upload-card:focus-within {
    border-color: var(--primary-color);
    background: var(--primary-soft);
    box-shadow: var(--shadow-md);
}

.upload-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.clm-logo {
    height: min(220px, 42vw);
    max-width: 100%;
    object-fit: contain;
}

.upload-title {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.upload-helper {
    max-width: fit-content;
    font-size: 0.95rem;
    padding: 0 1rem;
    border-radius: 50px;
    background-color: var(--border-strong);
}

.master-upload-wrapper {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-master-upload:hover,
.stat-button:hover,
.column-toggle-btn:hover {
    background: var(--bg-muted);
}

.master-file-badge {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: nowrap;
}

.master-file-badge--idle {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.master-file-badge--loading {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.master-file-badge--success {
    background: var(--success-bg);
    color: var(--success-text);
}

.master-file-badge--error {
    background: var(--error-bg);
    color: var(--error-text);
}

.bypass-checkbox-label {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.bypass-checkbox-label:has(input:checked) {
    background: var(--warning-bg);
    border-color: var(--warning-text);
    color: var(--warning-text);
}

.status-section {
    margin-bottom: 1.5rem;
}

.status-card,
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.status-card {
    padding: 1.25rem;
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.status-header h2 {
    font-size: 1rem;
}

.badge {
    background: var(--text-primary);
    color: #ffffff;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
}

.status-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.status-item .file-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.status-item.success {
    background: var(--success-bg);
    border-color: var(--success-text);
}

.status-item.error {
    background: var(--error-bg);
    border-color: var(--error-text);
}

.status-item .status-text {
    font-weight: 700;
}

.data-section {
    width: 100%;
    margin: 0 auto 3rem;
}

.table-container {
    width: 100%;
    min-height: 480px;
    padding: 1rem;
    overflow-x: auto;
}

.data-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-box {
    position: relative;
    flex: 1 1 280px;
    min-width: min(100%, 280px);
    display: flex;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 1rem 0.65rem 2.6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--bg-surface);
}

.search-box input::placeholder {
    color: #64748b;
}

.stat-button-danger {
    background: var(--error-bg);
    border-color: var(--error-text);
    color: var(--error-text);
}

.stat-button-danger:hover,
.stat-button-danger:focus-visible {
    background: #fee2e2;
}

.column-picker-container {
    position: relative;
    display: flex;
}

.column-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 1000;
    width: max-content;
    max-width: min(92vw, 320px);
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.column-dropdown-header {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.column-toggle-btn {
    min-height: 36px;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.column-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 36px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

caption {
    text-align: left;
    color: var(--text-secondary);
    padding: 0 0 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--primary-color);
    color: #ffffff;
    padding: 0.75rem 0.85rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid var(--primary-hover);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    vertical-align: middle;
}

thead th:last-child,
tbody td:last-child {
    border-right: none;
}

.highlight-header {
    background: var(--primary-hover);
    color: #ffffff;
}

.sortable-header {
    padding: 0;
}

.sort-header-button {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 0.75rem 0.85rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
}

.sort-header-button:hover,
.sort-header-button:focus-visible {
    background: rgba(255, 255, 255, 0.16);
}

.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    line-height: 0.75;
    font-size: 0.58rem;
}

.sort-arrow {
    opacity: 0.45;
}

.sort-arrow.active {
    opacity: 1;
}

tbody td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid #e2e8f0;
    color: var(--text-primary);
    background: var(--bg-surface);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

tbody tr:nth-child(even) td {
    background: var(--bg-soft);
}

tbody tr:hover td {
    background: #e6f6fb;
}

tbody td:nth-child(1) {
    text-align: center;
    color: var(--text-secondary);
}

tbody td:nth-child(4),
tbody td:nth-child(7),
.highlight-hours {
    font-weight: 700;
}

tbody td:nth-child(4),
tbody td:nth-child(5),
tbody td:nth-child(6),
tbody td:nth-child(8),
tbody td:nth-child(9),
tbody td:nth-child(15),
tbody td:nth-child(16),
.highlight-hours {
    background: #f8fafc;
}

tbody tr:nth-child(even) td:nth-child(4),
tbody tr:nth-child(even) td:nth-child(5),
tbody tr:nth-child(even) td:nth-child(6),
tbody tr:nth-child(even) td:nth-child(8),
tbody tr:nth-child(even) td:nth-child(9),
tbody tr:nth-child(even) td:nth-child(15),
tbody tr:nth-child(even) td:nth-child(16),
tbody tr:nth-child(even) .highlight-hours {
    background: #f1f5f9;
}

tbody td:nth-child(20) {
    max-width: 18ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flagged-shift {
    background: var(--flag-bg) !important;
    color: var(--flag-text);
    border: 2px solid var(--flag-border);
    font-weight: 700;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state-icon {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.empty-state p {
    font-weight: 700;
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
    background: var(--bg-muted);
}

::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: var(--radius-sm);
    border: 2px solid var(--bg-muted);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

.footer {
    display: flex;
    height: fit-content;
    padding: .3rem 0;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.footer-icon {
    width: 16px;
    height: 16px;
}

.footer-email,
.footer-brand {
    font-size: 0.9rem;
}

.footer-brand {
    font-weight: 700;
}

@media (max-width: 760px) {
    .app-container {
        padding-inline: 1rem;
    }

    .header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions,
    .btn-primary,
    .btn-master-upload,
    .stat-button {
        width: 100%;
    }

    .upload-section {
        grid-template-columns: 1fr;
    }

    .upload-card {
        min-height: 220px;
    }

    .master-file-badge,
    .bypass-checkbox-label,
    .search-box,
    .column-picker-container {
        width: 100%;
    }

    .column-dropdown {
        left: 0;
        right: auto;
    }

    .status-item {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}