:root {
    --ink: #202825;
    --muted: #68716d;
    --background: #f3f4f2;
    --surface: #ffffff;
    --line: #dfe3e0;
    --soft: #f7f8f7;
    --brand: #263d35;
    --brand-hover: #1b3029;
    --accent: #9a4033;
    --accent-soft: #f7eae7;
    --warning: #9a5a19;
    --warning-soft: #fff4e4;
    --success: #287052;
    --success-soft: #e8f4ee;
    --radius: 8px;
    --shadow: 0 8px 30px rgba(25, 35, 31, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: Inter, "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, select, .file-picker { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.hidden { display: none !important; }

.welcome { display: grid; min-height: 100vh; padding: 28px; place-items: center; background: #eef0ed; }
.welcome-card { width: min(560px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.welcome-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.welcome-brand strong, .welcome-brand small { display: block; }
.welcome-brand strong { font-size: 15px; }
.welcome-brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; color: white; border-radius: 7px; background: var(--brand); }
.brand-mark.small { width: 38px; height: 38px; }
.brand-mark svg { width: 23px; }
.welcome-copy { margin: 38px 0 28px; }
.section-label { margin: 0 0 6px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: 30px; line-height: 1.2; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.welcome-copy > p:last-child { max-width: 475px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.file-picker { display: flex; min-height: 82px; padding: 18px 20px; align-items: center; gap: 15px; color: white; border-radius: var(--radius); background: var(--brand); transition: background .15s; }
.file-picker:hover, .file-picker.dragging { background: var(--brand-hover); }
.file-picker > svg { flex: 0 0 auto; width: 27px; }
.file-picker span, .file-picker strong, .file-picker small { display: block; }
.file-picker strong { font-size: 14px; }
.file-picker small { margin-top: 5px; color: rgba(255,255,255,.68); font-size: 11px; font-weight: 400; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.privacy-note { display: flex; margin: 18px 0 0; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: 11px; }
.privacy-note svg { width: 15px; }
.upload-status { display: flex; min-height: 54px; margin-top: 12px; padding: 10px 13px; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); }
.upload-status strong, .upload-status small { display: block; font-size: 11px; }
.upload-status small { margin-top: 3px; color: var(--muted); }
.upload-status.error { color: var(--accent); border-color: #e5beb8; background: var(--accent-soft); }
.loader { width: 17px; height: 17px; border: 2px solid #c9cfcb; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.upload-status.error .loader { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.report { min-height: 100vh; }
.report-header { position: sticky; z-index: 20; top: 0; display: flex; min-height: 76px; padding: 13px max(24px, calc((100vw - 1320px) / 2)); align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.header-period { display: grid; width: min(440px, 48vw); gap: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.header-period select { width: 100%; height: 40px; color: var(--ink); font-size: 12px; font-weight: 650; letter-spacing: normal; text-transform: none; }
.header-actions { display: flex; gap: 8px; }
.button { display: inline-flex; height: 42px; padding: 0 15px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 700; }
.button svg { width: 17px; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-hover); }
.button.secondary { color: var(--ink); border-color: var(--line); background: white; }
.button.secondary:hover { border-color: #aeb7b2; }
.report-body { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0 60px; }
select { height: 38px; padding: 0 34px 0 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; background: white; font-size: 12px; text-transform: none; }

.management-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.summary-card { min-height: 244px; padding: 24px; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: var(--radius); background: white; }
.summary-card.control-card { border-top-color: var(--accent); }
.summary-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.summary-icon { display: grid; width: 38px; height: 38px; place-items: center; color: var(--brand); border-radius: 6px; background: #edf2ef; }
.summary-icon.warning { color: var(--accent); background: var(--accent-soft); }
.summary-icon svg { width: 20px; }
.summary-total { display: block; margin-top: 23px; font-size: 36px; line-height: 1; letter-spacing: -.025em; }
.summary-total.warning-number { color: var(--accent); }
.summary-card > p { min-height: 16px; margin: 8px 0 20px; color: var(--muted); font-size: 10px; }
.summary-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); padding-top: 17px; border-top: 1px solid var(--line); }
.summary-breakdown span { padding: 0 15px; border-right: 1px solid var(--line); }
.summary-breakdown span:first-child { padding-left: 0; }
.summary-breakdown span:last-child { padding-right: 0; border-right: 0; }
.summary-breakdown strong, .summary-breakdown small, .control-breakdown strong, .control-breakdown small { display: block; }
.summary-breakdown strong { margin-bottom: 3px; font-size: 18px; }
.summary-breakdown small { color: var(--muted); font-size: 9px; }
.control-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border: 1px solid var(--line); border-radius: 5px; background: var(--line); overflow: hidden; }
.control-breakdown span { min-height: 49px; padding: 9px 11px; background: var(--soft); }
.control-breakdown strong { float: left; min-width: 22px; margin-right: 7px; color: var(--muted); font-size: 15px; }
.control-breakdown span.has-issue strong { color: var(--accent); }
.control-breakdown small { color: var(--muted); font-size: 9px; line-height: 1.35; }

.report-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 18px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: #e9ecea; }
.report-tabs button { display: flex; min-height: 46px; padding: 0 15px; align-items: center; justify-content: center; gap: 9px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; font-size: 11px; font-weight: 700; }
.report-tabs button:hover { color: var(--ink); background: rgba(255,255,255,.55); }
.report-tabs button.active { color: var(--ink); background: white; box-shadow: 0 1px 5px rgba(25,35,31,.08); }
.report-tabs small { display: grid; min-width: 22px; height: 20px; padding: 0 6px; place-items: center; color: var(--muted); border-radius: 10px; background: var(--soft); font-size: 9px; }
.report-tabs button.active small { color: white; background: var(--brand); }
.report-view-panel { margin-top: 8px; }

.panel { margin-top: 12px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.panel-heading { display: flex; min-height: 35px; margin-bottom: 18px; align-items: center; justify-content: space-between; gap: 15px; }
.muted { color: var(--muted); font-size: 10px; }

.table-heading { min-height: 38px; }
.table-help { margin: -10px 0 16px; color: var(--muted); font-size: 10px; }
.search { display: flex; width: 235px; height: 38px; padding: 0 11px; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 5px; }
.search svg { width: 16px; color: var(--muted); }
.search input { min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.table-wrap { margin: 0 -21px -21px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 16px; color: var(--muted); background: var(--soft); font-size: 9px; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: #fafbfa; }
.employee-row.expanded { background: #f3f6f4; }
.employee-toggle { display: flex; padding: 0; align-items: center; gap: 9px; color: var(--ink); border: 0; background: transparent; text-align: left; }
.employee-toggle > svg { width: 16px; color: var(--muted); transition: transform .15s; }
.employee-toggle[aria-expanded="true"] > svg { transform: rotate(90deg); }
.person strong, .person small { display: block; }
.person small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.duration { font-weight: 750; }
.status { display: inline-flex; padding: 4px 7px; border-radius: 3px; color: var(--success); background: var(--success-soft); font-size: 9px; font-weight: 750; }
.status.warning { color: var(--accent); background: var(--accent-soft); }
.shift-note { display: block; max-width: 420px; margin-top: 6px; color: var(--muted); font-size: 9px; font-weight: 400; line-height: 1.45; white-space: normal; }
.issue-count { color: var(--accent); font-weight: 750; }
.employee-details-row > td { padding: 0; background: #f7f9f7; white-space: normal; }
.employee-details-row:hover { background: #f7f9f7; }
.employee-details { padding: 20px 24px 24px 48px; border-bottom: 1px solid var(--line); }
.detail-period { display: flex; align-items: baseline; gap: 8px; }
.detail-period span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.detail-period strong { font-size: 11px; }
.detail-stats { display: flex; gap: 35px; margin: 17px 0; }
.detail-stats span { min-width: 110px; }
.detail-stats strong, .detail-stats small { display: block; }
.detail-stats strong { font-size: 16px; }
.detail-stats small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.detail-table { border: 1px solid var(--line); border-radius: 5px; background: white; overflow-x: auto; }
.detail-table td { padding-block: 10px; }
.detail-table td:last-child { min-width: 300px; white-space: normal; }
.raw-heading { align-items: flex-start; }
.raw-heading p { max-width: 700px; margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.raw-table-wrap td { vertical-align: middle; }
.raw-line { width: 72px; color: var(--muted); font-variant-numeric: tabular-nums; }
.raw-time { color: var(--brand); font-family: Consolas, "Courier New", monospace; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.quality-heading { align-items: flex-start; }
.quality-intro { max-width: 700px; margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.quality-stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.quality-stats span { padding: 13px; color: var(--muted); border-right: 1px solid var(--line); font-size: 10px; }
.quality-stats span:last-child { border-right: 0; }
.quality-stats strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 18px; }
.quality-table-wrap { margin-top: 18px; margin-bottom: 0; border-top: 1px solid var(--line); }
.quality-table-wrap td { vertical-align: top; white-space: normal; line-height: 1.45; }
.quality-table-wrap td:nth-child(1), .quality-table-wrap td:nth-child(3) { white-space: nowrap; }
.quality-reason { display: block; max-width: 390px; margin-top: 3px; color: var(--muted); font-size: 9px; }
.quality-notes { margin-top: 13px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 44px)); padding: 13px 16px; color: white; border-radius: 5px; background: var(--ink); box-shadow: var(--shadow); font-size: 11px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 960px) {
    .management-summary { grid-template-columns: 1fr; }
    .report-tabs { display: flex; overflow-x: auto; }
    .report-tabs button { flex: 1 0 190px; }
}
@media (max-width: 680px) {
    .welcome { padding: 14px; }
    .welcome-card { padding: 25px; }
    .report-header { position: static; align-items: flex-start; flex-direction: column; }
    .header-period { width: 100%; }
    .header-actions, .button { width: 100%; }
    .report-body { width: calc(100% - 24px); padding-top: 12px; }
    .management-summary { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .table-wrap { margin: 0 -16px -16px; }
    .table-heading { align-items: stretch; flex-direction: column; }
    .search { width: 100%; }
    .quality-stats { grid-template-columns: 1fr 1fr; }
    .quality-stats span:nth-child(2) { border-right: 0; }
    .quality-stats span { border-bottom: 1px solid var(--line); }
    .employee-details { padding: 15px; }
    .detail-stats { gap: 15px; justify-content: space-between; }
    .detail-stats span { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
