/* Shared presentation layer. Business-specific status colours stay in app.css. */
:root {
    --bg: #f5f5f6;
    --surface: #fff;
    --surface-muted: #f0f1f4;
    --border: #dfe1e6;
    --text: #171819;
    --muted: #56657f;
    --primary: #b83d08;
    --primary-dark: #923006;
    --accent: #f15210;
}
body { font-family: "Segoe UI", Arial, sans-serif; line-height: 1.5; }
.shell { grid-template-columns: 252px minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 24px 16px; background: #171819; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { margin: 0 0 26px; gap: 12px; font-size: 18px; color: #fff; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; background: #322720; color: #e19849; border: 1px solid #704631; }
.brand small { color: #aab4c6; font-size: 12px; }
.nav { display: block; }
.nav-group { margin-bottom: 21px; }
.nav-group:last-child { margin-bottom: 0; }
.nav-group-title { margin: 0 12px 7px; color: #aab4c6; font-size: 10px; font-weight: 600; letter-spacing: 1.3px; text-transform: uppercase; }
.nav a { min-height: 43px; padding: 8px 12px; margin: 3px 0; border-radius: 9px; color: #d7dce5; gap: 11px; }
.nav-label { font-size: 13px; font-weight: 500; }
.nav-icon { width: 25px; height: 25px; color: #aab4c6; background: transparent; }
.nav a:hover { background: #292b30; }
.nav a.active { background: #3b2922; box-shadow: inset 3px 0 0 #f15210; color: #fff; }
.nav a.active .nav-label { font-weight: 650; }
.nav a.active .nav-icon, .nav a:hover .nav-icon { color: #e19849; background: transparent; }
.topbar { min-height: 76px; padding: 14px 28px; gap: 20px; }
.branch-switcher { grid-template-columns: auto minmax(150px, 240px); }
.branch-switcher select { background: #f7f7f8; border-color: #dfe1e6; color: #414e65; }
.user-menu { flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.user-menu > span { overflow-wrap: anywhere; }
.user-menu button { min-height: 36px; font-weight: 500; }
.content { padding: 28px; }
.panel, .day-grid > *, .recommendation-grid > *, .attendance-chat-grid > *, .operation-layout > * { min-width: 0; }
.content:focus { outline: none; }
.page-title { margin-bottom: 24px; align-items: center; gap: 18px; }
.page-title h1, .salary-page .page-title h1 { font-size: 27px; line-height: 1.25; letter-spacing: -.6px; font-weight: 650; }
.page-title p { margin-top: 7px; font-size: 13px; line-height: 1.5; }
.page-actions { align-items: center; }
button, .button { min-height: 40px; border-radius: 9px; padding: 9px 15px; font-weight: 600; transition: background-color .15s, border-color .15s; background: #f15210; color: #171819; }
button:hover, .button:hover { background: #e19849; color: #171819; }
button.danger { color: #fff; }
input[type="checkbox"], input[type="radio"] { accent-color: #b83d08; }
input, select, textarea { border-radius: 8px; }
input, select { min-height: 40px; }
/* Explicit intrinsic sizing avoids oversized or collapsed native iOS date fields. */
.field { min-width: 0; }
input[type="date"], input[type="time"], input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
    text-align: left;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
    min-height: 1.5em;
    text-align: left;
}
input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit { min-width: 0; padding: 0; }
label { font-size: 11px; letter-spacing: .35px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.table-wrap:focus-visible { outline: 3px solid #b83d08; outline-offset: 3px; }
.toolbar, .panel, .table-wrap, .salary-filter-card, .salary-table-card { border-radius: 12px; border-color: var(--border); box-shadow: 0 2px 4px rgba(30, 57, 63, .025); }
.toolbar, .panel { padding: 18px; margin-bottom: 18px; }
.toolbar { gap: 16px; align-items: flex-end; }
.toolbar .field { min-width: 160px; }
.table-wrap { max-width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.salary-table-wrap { overflow: auto; border-radius: 0 0 12px 12px; }
th { background: #f0f1f4; color: #56657f; font-size: 11px; letter-spacing: .35px; font-weight: 650; }
th, td { padding: 13px 16px; vertical-align: middle; border-bottom-color: #e8e9ed; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fff6ef; }
table { font-variant-numeric: tabular-nums; }
td button.secondary { min-height: 32px; padding: 5px 12px; font-size: 12px; color: #a83b0d; border-color: #e8d8cc; }
.badge { padding: 3px 9px; font-size: 11px; font-weight: 600; }
.excel-wrap { max-height: 72vh; }
.excel-table { font-size: 12px; }
.excel-table th, .excel-table td { padding: 8px; }
.excel-table th, .excel-table th.sticky-col { background: #eef0f4; color: #414e65; }
.excel-table .name-col { min-width: 174px; max-width: 174px; }
.excel-table input { min-height: 32px; }
.salary-table th, .salary-table td { padding: 8px; }
.salary-table { border-collapse: separate; border-spacing: 0; }
.salary-table .salary-employee-cell {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 190px;
    max-width: 220px;
    white-space: normal;
    overflow-wrap: break-word;
    background: #fff;
    box-shadow: 2px 0 0 #dfe1e6;
}
.salary-table th.salary-employee-cell { z-index: 3; background: #f8fafc; }
.salary-table tr.row-no-rate .salary-employee-cell { box-shadow: 2px 0 0 #dfe1e6, inset 0 -2px 0 #ef4444; }
.attendance-help { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
#attendanceTable .time-pair { grid-template-columns: repeat(2, 106px); gap: 6px; }
.attendance-time-field { display: flex; align-items: stretch; min-width: 0; }
#attendanceTable .attendance-time-field input { min-width: 0; width: 76px; flex: 1 1 0; border-radius: 6px 0 0 6px; min-height: 34px; }
.attendance-time-field .time-clear {
    flex: 0 0 30px;
    min-width: 30px;
    min-height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 6px 6px 0;
    font-size: 20px;
    font-weight: 400;
    background: #f2f3f5;
    color: #56657f;
}
.attendance-time-field .time-clear:hover { background: #fee2e2; color: #991b1b; }
.attendance-time-field .time-clear:disabled { opacity: .4; cursor: default; }
.salary-table-title, .filter-title { border-bottom-color: var(--border); font-size: 16px; font-weight: 600; flex-wrap: wrap; }
.salary-table-meta { background: #f0f1f4; color: #56657f; font-weight: 500; }
.salary-filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.salary-search input { min-width: 0; }
.salary-summary { gap: 14px; margin: 20px 0; }
.day-stats { gap: 14px; margin-bottom: 22px; }
.day-stat, .salary-stat { background: #fff; color: var(--text); border: 1px solid var(--border); border-top: 3px solid #56657f; border-radius: 12px; padding: 18px; box-shadow: 0 2px 4px rgba(30,57,63,.025); }
.day-stat span, .salary-stat span { color: #56657f; font-size: 12px; font-weight: 500; opacity: 1; }
.day-stat strong, .salary-stat strong { font-size: 30px; font-weight: 650; line-height: 1.25; font-variant-numeric: tabular-nums; }
.day-stat-primary, .salary-stat-employees { border-top-color: #f15210; }
.day-stat-danger { border-top-color: #d77d7d; }
.day-stat-danger strong { color: #a74343; }
.day-stat-success, .salary-stat-hours { border-top-color: #329c7d; }
.day-stat-success strong, .salary-stat-hours strong { color: #167459; }
.salary-stat-total { border-top-color: #56657f; }
.salary-stat-orders { border-top-color: #e19849; }
.day-alert { border-radius: 12px; padding: 16px; }
.day-grid h2, .current-table-panel h2 { font-size: 17px; font-weight: 650; }
.vertical-chart-bar i { background: linear-gradient(180deg, #e19849, #f15210); }
.top-hours-list { gap: 13px; }
.top-hours-list div { grid-template-columns: 26px minmax(80px,1fr) minmax(35px,.5fr) 62px; gap: 8px; }
.top-hours-list .rank { color: #a83b0d; background: #fff0e5; }
.top-hours-list i b { background: #e19849; }
.stat, .recommendation-source, .position-load-card, .uniform-warehouse-card { border-radius: 12px; }
.uniform-tabs { padding: 6px; border-radius: 12px; }
.uniform-tabs .uniform-tab { min-height: 40px; font-weight: 600; }
.uniform-tabs .uniform-tab.active, .uniform-tabs .uniform-tab.active:hover { background: #b83d08; color: #fff; }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; }
.modal-header, .modal-body, .modal-footer { padding: 20px; }
.modal-header { background: #f6f6f8; }
.modal-footer { flex-wrap: wrap; }
.compact-ui .content { padding: 24px; }
.compact-ui th, .compact-ui td { padding: 9px 10px; }
.compact-ui .excel-table th, .compact-ui .excel-table td { padding: 6px; }
.compact-ui .toolbar, .compact-ui .panel { padding: 16px; margin-bottom: 16px; }
.menu-toggle { display: none; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 12px 18px; background: #fff; color: #a83b0d; border: 2px solid #b83d08; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.pagination-wrap nav > div:last-child { flex-wrap: wrap; }
.pagination-wrap nav > div:last-child > div:last-child { min-width: 0; max-width: 100%; }
.pagination-wrap nav > div:last-child > div:last-child > span { flex-wrap: wrap; }
@media (min-width: 901px) and (max-height: 800px) {
    .sidebar { padding-top: 16px; padding-bottom: 16px; }
    .brand { margin-bottom: 18px; }
    .nav-group { margin-bottom: 12px; }
    .nav a { min-height: 38px; padding-top: 5px; padding-bottom: 5px; }
}
@media (min-width: 901px) and (max-width: 1180px) {
    .shell { grid-template-columns: 224px minmax(0,1fr); }
    .content, .compact-ui .content { padding: 20px; }
    .topbar { padding: 14px 20px; }
    .day-grid { grid-template-columns: 1fr; }
    .day-stats, .salary-summary, .recommendation-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .attendance-chat-grid, .operation-layout { grid-template-columns: 1fr; }
    .uniform-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 900px) {
    .shell { display: block; }
    .sidebar { position: relative; height: auto; padding: 14px 18px; overflow: visible; }
    .brand { margin: 0; font-size: 16px; }
    .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
    .panel-ui-ready .menu-toggle { display: inline-flex; flex: 0 0 auto; gap: 7px; min-height: 40px; background: #292b30; border-color: #56657f; color: #fff; padding: 8px 10px; font-size: 12px; }
    .menu-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
    .nav { margin-top: 24px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
    .nav-group { margin: 0; min-width: 0; }
    .panel-ui-ready .sidebar:not(.menu-open) .nav { display: none; }
    .topbar { min-height: 0; padding: 12px 18px; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 18px; }
    .branch-switcher { width: auto; flex: 1 1 200px; grid-template-columns: auto minmax(110px,1fr); }
    .branch-switcher label { font-size: 10px; }
    .branch-switcher select { min-height: 38px; }
    .user-menu { margin-left: auto; }
    .content, .compact-ui .content { padding: 20px 18px; }
    .page-title { flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
    .page-title h1, .salary-page .page-title h1 { font-size: 24px; }
    .page-actions { justify-content: flex-start; }
    .day-stats, .salary-summary, .recommendation-stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
    .day-stat, .salary-stat { padding: 14px; }
    .salary-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .grid { grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); }
    .field, .toolbar .field { min-width: 0; }
    .toolbar .field { flex: 1 1 160px; }
    .table-wrap { max-width: 100%; }
    .panel, .toolbar, .compact-ui .panel, .compact-ui .toolbar { padding: 14px; }
    .excel-wrap { max-height: 70vh; }
    .uniform-warehouse-cards { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
    .salary-table-title { font-size: 15px; }
}
@media (max-width: 480px) {
    .sidebar { padding: 12px 14px; }
    .nav { display: block; }
    .nav-group { margin-bottom: 16px; }
    .nav a { min-height: 44px; }
    .topbar { padding: 10px 14px; }
    .branch-switcher { flex-basis: 100%; }
    .user-menu { width: 100%; justify-content: space-between; }
    .user-menu > span { flex: 1; min-width: 0; }
    .content, .compact-ui .content { padding: 18px 12px; }
    .page-title { display: block; }
    .page-actions { margin-top: 14px; width: 100%; }
    .page-actions > button, .page-actions > .button { flex: 1 1 125px; min-height: 44px; font-size: 12px; }
    .page-title > .button { margin-top: 12px; }
    .page-title h1, .salary-page .page-title h1 { font-size: 23px; }
    .toolbar { gap: 12px; }
    .toolbar .field, .toolbar .field.compact { flex: 1 1 100%; max-width: none; }
    .toolbar .inline { flex-wrap: wrap; }
    input, select, textarea { font-size: 16px; }
    .excel-table input, .order-input { font-size: 13px; }
    .salary-filters, .access-grid { grid-template-columns: minmax(0,1fr); }
    .salary-stat strong, .day-stat strong { font-size: 25px; }
    .salary-stat span, .day-stat span { font-size: 11px; }
    .day-stats, .salary-summary { gap: 8px; }
    .salary-stat, .day-stat { padding: 12px; }
    .excel-table .code-col { min-width: 50px; max-width: 50px; }
    .excel-table .name-col { left: 50px; min-width: 118px; max-width: 118px; }
    .top-hours-list div { grid-template-columns: 24px minmax(0,1fr) 42px 55px; gap: 6px; }
    .modal { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
    .modal-header, .modal-body, .modal-footer { padding: 14px; }
    .modal-footer button { min-height: 44px; }
    .modal .grid { grid-template-columns: minmax(0,1fr); }
    .modal .field { min-width: 0; }
    .salary-table-meta { white-space: normal; }
    .salary-table .salary-employee-cell { min-width: 124px; max-width: 144px; }
    #attendanceTable .time-pair { grid-template-columns: 124px; }
    #attendanceTable .attendance-time-field input { min-height: 40px; font-size: 16px; }
    .attendance-time-field .time-clear { flex-basis: 40px; min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
    button, .button { transition: none; }
}
@media print {
    .sidebar, .topbar, .skip-link, .menu-toggle { display: none !important; }
    .shell { display: block; }
    .content, .compact-ui .content { padding: 0; }
    .table-wrap { max-height: none; overflow: visible; }
}

/* Rate history and branch-specific lateness settings. */
.rate-upcoming { margin-top: 7px; padding: 6px 8px; background: #fff3e8; border-radius: 6px; color: #a83b0d; white-space: normal; }
#historyModal { width: min(920px, calc(100vw - 32px)); }
#historyModal small, .salary-period-rate small { display: block; color: #64748b; margin-top: 4px; }
.salary-period-rate { white-space: normal; min-width: 145px; padding: 5px 0; }
.salary-period-rate + .salary-period-rate { border-top: 1px solid #dfe1e6; }
.lateness-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap: 16px; }
.lateness-rule { margin: 0; min-width: 0; }
.lateness-rule h2 { margin: 0 0 14px; font-size: 18px; }
.rule-result { display: inline-block; padding: 8px; color: #b83d08; }
@media (max-width: 480px) { .lateness-grid { grid-template-columns: minmax(0,1fr); } #historyModal { width: calc(100vw - 20px); } }
