:root {
    --bg: #eeeeec;
    --surface: #ffffff;
    --surface-soft: #f5f5f3;
    --line: #d0d0d0;
    --text: #222222;
    --muted: #666666;
    --blue: #555555;
    --blue-dark: #3f3f3f;
    --green: #12a579;
    --red: #d44b4b;
    --amber: #f5ad32;
    --shadow: none;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, "Segoe UI", Tahoma, Helvetica, sans-serif;
}

html[dir="rtl"] body {
    font-family: "Segoe UI", Tahoma, Arial, Helvetica, sans-serif;
}

html[dir="rtl"] .app-shell {
    direction: rtl;
}

html[dir="rtl"] .sidebar {
    border-left: 1px solid var(--line);
    border-right: 0;
}

html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] textarea {
    text-align: right;
}

a {
    color: var(--blue-dark);
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.public-shell {
    display: block;
}

.public-shell .topbar {
    justify-content: center;
}

.public-shell .topbar-title {
    justify-content: center;
    width: 100%;
}

.public-shell .topbar nav {
    display: none;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    align-items: center;
    display: flex;
    font-size: 20px;
    font-weight: 800;
    gap: 12px;
    margin-bottom: 20px;
}

.sidebar-logo {
    display: block;
    filter: grayscale(1);
    height: auto;
    max-width: 132px;
}

.side-nav {
    display: grid;
    gap: 3px;
}

.side-nav a {
    border-radius: 8px;
    color: #333333;
    display: block;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    padding: 8px 10px;
}

.side-nav a:hover,
.side-nav a.active {
    background: var(--blue);
    color: white;
}

.sidebar-footer {
    border-top: 1px solid var(--line);
    margin-top: auto;
    padding-top: 18px;
}

.user-chip {
    background: var(--surface-soft);
    border-radius: 8px;
    color: #333333;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 10px 12px;
}

.sidebar-footer .footer-link {
    color: #333333;
    display: block;
    font-weight: 700;
    padding: 0 12px;
}

.content-shell {
    min-width: 0;
}

.topbar {
    align-items: center;
    background: rgba(238, 238, 236, 0.96);
    display: flex;
    justify-content: space-between;
    min-height: 74px;
    padding: 18px 28px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-title {
    align-items: center;
    display: flex;
    gap: 12px;
}

.topbar strong {
    display: block;
    font-size: 18px;
}

.topbar span {
    color: #333333;
    font-size: 13px;
    font-weight: 800;
}

.topbar nav {
    display: flex;
    gap: 8px;
}

.topbar nav a {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #333333;
    font-weight: 700;
    padding: 9px 12px;
}

main {
    margin: 0 auto;
    max-width: 1500px;
    padding: 8px 28px 36px;
}

.page-head {
    margin: 10px 0 22px;
}

.page-head h1 {
    font-size: 26px;
    margin: 0 0 6px;
}

.page-head p,
.panel p {
    color: var(--muted);
}

h1, h2 {
    letter-spacing: 0;
}

h2 {
    font-size: 18px;
    margin: 0 0 16px;
}

.login-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    padding: 20px;
}

.login-panel {
    max-width: 400px;
    margin: 12vh auto;
}

.login-title {
    color: var(--text);
    font-size: 1.8em;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 10px;
}

.login-panel h1 {
    font-size: 1.8em;
}

.login-panel input,
.login-panel select,
.login-panel button {
    width: 100%;
}

.grid.two {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
}

.narrow {
    max-width: 1200px;
}

label {
    color: #444444;
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin: 8px 0 5px;
}

input, select, button {
    border: 1px solid #cfcfcf;
    border-radius: 8px;
    font-size: 13px;
    min-height: 34px;
    padding: 6px 10px;
}

input, select {
    background: #ffffff;
    color: var(--text);
}

input[readonly] {
    background: #f1f1ef;
    color: #666666;
}

button {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
    cursor: pointer;
    font-weight: 800;
}

button:hover {
    background: var(--blue-dark);
}

table {
    background: white;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 6px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-soft);
    color: #444444;
    font-size: 12px;
    font-weight: 900;
    position: sticky;
    top: 0;
    z-index: 1;
}

td {
    font-weight: 400;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.dashboard-cards {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.dashboard-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
    display: block;
    min-height: 92px;
    padding: 18px;
}

.dashboard-card strong {
    color: var(--text);
    display: block;
    font-size: 17px;
    margin-bottom: 7px;
}

.dashboard-card span {
    color: var(--muted);
    display: block;
    line-height: 1.35;
}

.editable-card-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.edit-card {
    background: #fbfdff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}

.compact-card {
    padding: 10px;
}

.edit-card-header {
    align-items: flex-start;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 6px;
}

.edit-card-header strong {
    display: block;
    font-size: 15px;
    margin-bottom: 3px;
}

.edit-card-header span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.35;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.card-actions button {
    min-height: 30px;
    padding: 5px 9px;
}

.card-form-grid {
    display: grid;
    gap: 5px 6px;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.project-card-grid {
    align-items: end;
    grid-template-columns: minmax(190px, 1.6fr) 72px 72px 76px 92px 90px 92px 72px 70px minmax(110px, 1fr);
    overflow-x: auto;
}

.employee-card-grid {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.leave-card-grid,
.salary-card-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.holiday-card-grid {
    grid-template-columns: minmax(150px, 0.45fr) minmax(240px, 1fr) minmax(260px, 0.9fr);
}

.card-form-grid label {
    color: #475569;
    font-size: 11px;
    line-height: 1.15;
    margin: 0;
    min-width: 0;
}

.card-form-grid input,
.card-form-grid select {
    display: block;
    margin-top: 3px;
    min-height: 30px;
    padding: 4px 8px;
    width: 100%;
}

.project-card-grid .small-code-field,
.project-card-grid .tiny-code-field {
    min-width: 0;
}

#projectsCards {
    gap: 0;
    margin-top: 0;
}

#projectsCards .edit-card {
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 2px 4px;
}

#projectsCards .card-actions {
    gap: 3px;
}

#projectsCards .card-actions button {
    min-height: 26px;
    padding: 3px 8px;
}

#projectsCards .project-card-grid {
    gap: 2px 4px;
}

#projectsCards .card-form-grid label {
    font-size: 10px;
}

#projectsCards .card-form-grid input,
#projectsCards .card-form-grid select {
    min-height: 26px;
    padding: 2px 6px;
}

.project-table-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

.table-top-scroll {
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    height: 16px;
    margin-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.table-top-scroll div {
    height: 1px;
}

.table-top-scroll + .project-table-shell {
    border-radius: 0 0 8px 8px;
}

.project-row-grid {
    align-items: center;
    display: grid;
    gap: 3px;
    grid-template-columns: 160px minmax(180px, 1.5fr) 62px 58px 70px 88px 88px 92px 62px 58px minmax(190px, 1.3fr) 34px;
    min-width: 1260px;
}

.projects-header-row {
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
    color: #475569;
    font-size: 11px;
    font-weight: 900;
    padding: 5px 4px;
    position: sticky;
    top: 0;
    z-index: 2;
}

#projectsCards .generated-code {
    color: var(--text);
    font-size: 11px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#projectsCards input {
    min-height: 24px;
    padding: 2px 5px;
    width: 100%;
}

#projectsCards .pending-save {
    background: #fffaf0;
}

#projectsCards .save-error {
    background: #fff1f1;
}

.project-delete-button {
    align-items: center;
    background: #fff;
    border-color: #f1b5b5;
    color: var(--red);
    display: inline-flex;
    font-size: 12px;
    justify-content: center;
    min-height: 24px;
    padding: 0;
    width: 26px;
}

.project-delete-button:hover {
    background: #ffecec;
}

#addProjectPanel {
    margin-bottom: 10px;
    padding-bottom: 12px;
}

#addProjectPanel .project-form {
    gap: 4px 6px;
    grid-template-columns: minmax(180px, 1.5fr) 72px 72px 76px 92px 90px 92px 72px 70px minmax(190px, 1.3fr);
}

#addProjectPanel input {
    min-height: 28px;
    padding: 3px 8px;
}

.empty-state {
    background: var(--surface-soft);
    border: 1px dashed #d8e1eb;
    border-radius: 8px;
    color: var(--muted);
    padding: 14px;
}

.attendance-controls,
.form-grid,
.punch-row,
.project-form {
    display: grid;
    gap: 10px;
    margin: 8px 0;
}

.attendance-controls {
    align-items: end;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.section-title-row {
    align-items: start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.month-controls {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: 150px 120px;
    min-width: 280px;
}

.month-controls label {
    grid-column: 1 / -1;
    margin: 0;
}

.monthly-kpis {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    margin: 12px 0;
}

.monthly-kpis span {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    padding: 10px 12px;
}

.monthly-kpis b {
    color: var(--text);
    display: block;
    font-size: 18px;
    margin-bottom: 3px;
}

.monthly-table-wrap {
    margin-top: 10px;
}

.daily-month-details {
    margin-top: 12px;
}

.daily-month-details summary {
    color: var(--blue-dark);
    cursor: pointer;
    font-weight: 800;
}

.allocation-warning-row td {
    background: #fff7ed;
}

.form-grid {
    grid-template-columns: 130px minmax(180px, 1fr);
}

.punch-row {
    grid-template-columns: 140px 120px 100px;
}

.project-form {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.titled-form label {
    margin: 0;
}

.titled-form input,
.titled-form select {
    display: block;
    margin-top: 4px;
    width: 100%;
}

.allocation-row {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(360px, 1fr) 120px 90px;
    margin: 8px 0;
}

.weekly-table-wrap {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
}

.top-scroll-wrap {
    transform: rotateX(180deg);
}

.top-scroll-wrap > table,
.top-scroll-wrap > div {
    transform: rotateX(180deg);
}

.table-horizontal-scroll,
.table-bottom-scroll {
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
}

.table-top-scroll {
    margin-bottom: 3px;
}

.table-bottom-scroll {
    margin-top: 3px;
}

.table-horizontal-scroll > div,
.table-bottom-scroll > div {
    height: 1px;
}

.project-cost-report-heading {
    align-items: baseline;
    display: flex;
    gap: 10px;
    margin: 8px 0 6px;
}

.project-cost-report-heading h3 {
    margin: 0;
}

.project-cost-report-heading span {
    font-weight: 700;
}

.project-cost-wrap {
    direction: ltr;
    max-height: 68vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

#summaryTopScroll {
    height: 10px;
    margin: 0 0 2px;
    scrollbar-width: thin;
}

#summaryTopScroll::-webkit-scrollbar {
    height: 8px;
}

.project-cost-table {
    direction: ltr;
    table-layout: fixed;
    width: auto;
}

.project-cost-table col.project-name-col {
    width: 210px;
}

.project-cost-table col.project-code-col {
    width: 190px;
}

.project-cost-table col.project-number-col {
    width: 58px;
}

.project-cost-table th,
.project-cost-table td {
    font-size: 10px;
    min-width: 58px;
    padding: 3px 4px;
    text-align: center;
    white-space: nowrap;
}

.project-cost-table .metric-label {
    background: #fff;
    text-align: right;
}

.project-cost-table .salary-input-cell {
    background: #92d050;
    font-weight: 800;
}

.project-cost-table .metric-value,
.project-cost-table .employee-cost-head,
.project-cost-table thead tr:last-child th {
    background: #d9d9d9;
}

.project-cost-table .company-total-cell {
    background: #fff200;
    font-weight: 800;
}

.project-cost-table .company-group-head {
    background: #555;
    color: #fff;
}

.project-cost-table .employee-cost-head {
    font-size: 10px;
    height: 112px;
    min-width: 58px;
    vertical-align: bottom;
}

.project-cost-table .employee-cost-head span {
    display: inline-block;
    font-size: 10px;
    line-height: 1;
    max-height: 104px;
    overflow: hidden;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.project-cost-table .sticky-project-name,
.project-cost-table .sticky-project-code {
    background: #fff;
    position: sticky;
    text-align: left;
    z-index: 4;
}

.project-cost-table .sticky-project-name {
    left: 0;
    min-width: 210px;
    width: 210px;
}

.project-cost-table .sticky-project-code {
    left: 210px;
    min-width: 190px;
    width: 190px;
}

.project-cost-table thead .sticky-project-name,
.project-cost-table thead .sticky-project-code {
    background: #d9d9d9;
    z-index: 8;
}

.project-cost-controls {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.matrix-report-controls {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.matrix-report-controls .control-field,
.project-cost-controls .control-field {
    display: grid;
    gap: 4px;
    margin: 0;
}

.matrix-report-controls .control-field > span,
.project-cost-controls .control-field > span {
    font-weight: 700;
}

html[dir="rtl"] .project-cost-table th,
html[dir="rtl"] .project-cost-table td {
    direction: rtl;
}

html[dir="rtl"] .project-cost-wrap,
html[dir="rtl"] .project-cost-table {
    direction: rtl;
}

html[dir="rtl"] .project-cost-table .metric-label {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .project-cost-table .sticky-project-name,
html[dir="rtl"] .project-cost-table .sticky-project-code {
    left: auto;
    text-align: right;
}

html[dir="rtl"] .project-cost-table .sticky-project-name {
    right: 0;
}

html[dir="rtl"] .project-cost-table .sticky-project-code {
    right: 210px;
}

/* Global compact-density defaults: show more useful rows and columns. */
body {
    font-size: 13px;
}

.app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
    padding: 10px 9px;
}

.brand {
    margin-bottom: 10px;
}

.side-nav {
    gap: 1px;
}

.side-nav a {
    padding: 6px 8px;
}

.sidebar-footer {
    padding-top: 9px;
}

.user-chip {
    margin-bottom: 5px;
    padding: 7px 9px;
}

.topbar {
    min-height: 54px;
    padding: 9px 14px;
}

.topbar nav a {
    padding: 6px 9px;
}

main {
    max-width: none;
    padding: 5px 14px 18px;
}

.page-head {
    margin: 5px 0 10px;
}

.page-head h1 {
    font-size: 22px;
    margin-bottom: 2px;
}

h2 {
    font-size: 16px;
    margin-bottom: 8px;
}

.login-panel,
.panel {
    margin-bottom: 10px;
    padding: 12px;
}

label {
    font-size: 12px;
    margin: 4px 0 3px;
}

input,
select,
button {
    min-height: 30px;
    padding: 4px 7px;
}

th,
td {
    padding: 4px 6px;
}

.actions {
    gap: 5px;
    margin: 8px 0;
}

.attendance-controls,
.form-grid,
.punch-row,
.project-form,
.card-form-grid {
    gap: 6px;
    margin: 5px 0;
}

.weekly-table-wrap.no-x-scroll {
    overflow-x: hidden;
}

.holiday-panel {
    align-self: start;
}

.grid.two.vacation-top-grid {
    grid-template-columns: minmax(360px, 0.7fr) minmax(640px, 1.3fr);
}

.holiday-panel #holidayCards {
    max-height: 330px;
    overflow-y: auto;
    padding-right: 4px;
}

.vacation-records-panel {
    width: 100%;
}

.record-view-controls {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    margin: 8px 0 12px;
}

.record-view-controls label {
    margin: 0;
}

.leave-summary-card details {
    margin-top: 8px;
}

.leave-summary-card summary {
    color: var(--blue-dark);
    cursor: pointer;
    font-weight: 800;
}

.remaining-credit {
    background: #ecfdf5;
    border: 1px solid #b8ead5;
    border-radius: 8px;
    color: #0f7a58;
    min-width: 44px;
    padding: 6px 8px;
    text-align: center;
}

.leave-metric-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(6, minmax(88px, 1fr));
}

.leave-metric-grid span {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #64748b;
    font-size: 12px;
    padding: 6px 8px;
}

.leave-metric-grid b {
    color: var(--text);
    display: block;
    font-size: 14px;
}

.leave-detail-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.leave-grouped-table th,
.leave-grouped-table td {
    font-size: 12px;
    padding: 5px 6px;
}

.leave-grouped-table td:last-child {
    white-space: normal;
}

.leave-calendar {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
}

.leave-calendar > b {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #475569;
    font-size: 12px;
    padding: 7px;
    text-align: center;
}

.leave-calendar-cell {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 82px;
    padding: 6px;
}

.leave-calendar-cell.muted {
    background: #f7f9fc;
}

.leave-calendar-cell strong,
.leave-calendar-cell span {
    display: block;
}

.leave-calendar-cell span {
    background: #eef7ff;
    border-radius: 6px;
    font-size: 11px;
    margin-top: 4px;
    padding: 3px 5px;
}

.company-table-stack {
    display: grid;
    gap: 16px;
}

.company-salary-table h3 {
    font-size: 16px;
    margin: 0 0 8px;
}

.salary-year-table {
    table-layout: fixed;
}

.salary-year-table th,
.salary-year-table td {
    font-size: 11px;
    padding: 4px 3px;
    text-align: center;
}

.salary-year-input {
    font-size: 11px;
    min-height: 26px;
    padding: 3px 4px;
    text-align: center;
    width: 100%;
}

.salary-change-form {
    margin-bottom: 1rem;
    align-items: end;
}

.salary-readonly-value {
    display: inline-block;
    min-width: 4.5rem;
    padding: 0.25rem 0.35rem;
    text-align: end;
    color: #333;
}

.salary-change-link {
    display: block;
    font-size: 10px;
    margin-top: 2px;
    min-height: 22px;
    padding: 2px 6px;
}

.salary-year-table th:nth-child(1),
.salary-year-table td:nth-child(1) {
    width: 72px;
}

.salary-year-table th:nth-child(2),
.salary-year-table td:nth-child(2) {
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 170px;
}

.salary-year-table th:nth-child(3),
.salary-year-table td:nth-child(3) {
    width: 86px;
}

.chart-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(280px, 1fr));
}

.chart-card {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}

.chart-card h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

.chart-card canvas {
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    height: auto;
    max-width: 100%;
    width: 100%;
}

#weeklyProjectsTable {
    min-width: 1180px;
}

#projectsTable {
    min-width: 1550px;
}

#yearMatrixTable {
    font-size: 12px;
    min-width: 1800px;
}

#yearMatrixTable.year-summary {
    table-layout: fixed;
    min-width: 0;
}

#yearMatrixTable.year-summary th,
#yearMatrixTable.year-summary td {
    font-size: 11px;
    padding: 4px 3px;
    text-align: center;
}

#yearMatrixTable.year-summary th {
    font-weight: 800;
}

#yearMatrixTable.year-summary td {
    font-weight: 400;
}

#yearMatrixTable.year-summary th:nth-child(1),
#yearMatrixTable.year-summary td:nth-child(1),
#yearMatrixTable.year-summary th:nth-child(2),
#yearMatrixTable.year-summary td:nth-child(2) {
    width: 46px;
}

#yearMatrixTable.year-summary th:nth-child(3),
#yearMatrixTable.year-summary td:nth-child(3) {
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 160px;
}

#yearMatrixTable.year-summary.year-detail-groups {
    table-layout: fixed;
    min-width: max-content;
    width: max-content;
}

#yearMatrixTable.year-detail-groups col.employee-name-col {
    width: 260px;
}

#yearMatrixTable.year-detail-groups col.year-metric-col {
    width: 104px;
}

#yearMatrixTable.year-detail-groups col.year-leave-col {
    width: 82px;
}

#yearMatrixTable.year-detail-groups th,
#yearMatrixTable.year-detail-groups td {
    border-right: 1px solid #cbd5e1;
    font-size: 11px;
    line-height: 1.15;
    box-sizing: border-box;
    min-width: 104px;
    padding: 4px 5px;
    text-align: center;
    white-space: normal;
    width: 104px;
}

#yearMatrixTable.year-detail-groups thead th,
#yearMatrixTable.year-detail-groups .month-group-head {
    vertical-align: middle;
    background: #374151;
    color: #fff;
    font-weight: 700;
}

#yearMatrixTable.year-detail-groups .month-group-head,
#yearMatrixTable.year-detail-groups .month-group-start {
    border-inline-start: 3px solid #111827;
}

#yearMatrixTable.year-detail-groups .month-group-head {
    min-width: 312px;
    padding: 0;
    text-align: center;
    vertical-align: middle;
    width: 312px;
}

#yearMatrixTable.year-detail-groups .month-group-label {
    display: block;
    line-height: 20px;
    text-align: center;
    width: 312px;
}

#yearMatrixTable.year-detail-groups .leave-month-head {
    min-width: 410px;
    width: 410px;
}

#yearMatrixTable.year-detail-groups .leave-month-label {
    width: 410px;
}

#yearMatrixTable.year-detail-groups th:nth-child(1),
#yearMatrixTable.year-detail-groups td:nth-child(1),
#yearMatrixTable.year-detail-groups th:nth-child(2),
#yearMatrixTable.year-detail-groups td:nth-child(2),
#yearMatrixTable.year-detail-groups th:nth-child(3),
#yearMatrixTable.year-detail-groups td:nth-child(3) {
    width: 104px;
}

#yearMatrixTable.year-detail-groups .year-employee-head,
#yearMatrixTable.year-detail-groups .year-employee-cell {
    left: 0;
    min-width: 260px;
    position: sticky;
    text-align: left;
    width: 260px;
    z-index: 4;
}

#yearMatrixTable.year-detail-groups .year-employee-cell {
    overflow: visible;
    text-overflow: clip;
}

#yearMatrixTable.year-detail-groups .year-employee-head {
    background: #374151;
    color: #fff;
    z-index: 5;
}

#yearMatrixTable.year-detail-groups .year-employee-cell {
    background: #fff;
}

#yearMatrixTable.year-detail-groups tbody td {
    white-space: nowrap;
}

html[dir="rtl"] #yearMatrixTable.year-detail-groups .year-employee-head,
html[dir="rtl"] #yearMatrixTable.year-detail-groups .year-employee-cell {
    left: auto;
    right: 0;
    text-align: right;
}

#yearMatrixTable.month-fit {
    table-layout: fixed;
    min-width: 0;
}

#yearMatrixTable.month-fit th,
#yearMatrixTable.month-fit td {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 10px;
    padding: 3px 2px;
    text-align: center;
}

#yearMatrixTable.month-fit th {
    font-weight: 800;
}

#yearMatrixTable.month-fit td {
    font-weight: 400;
}

#yearMatrixTable.month-fit th:nth-child(1),
#yearMatrixTable.month-fit td:nth-child(1),
#yearMatrixTable.month-fit th:nth-child(2),
#yearMatrixTable.month-fit td:nth-child(2) {
    width: 42px;
}

#yearMatrixTable.month-fit th:nth-child(3),
#yearMatrixTable.month-fit td:nth-child(3) {
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 148px;
}

#yearMatrixTable.monthly-transposed {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    min-width: max-content;
}

#yearMatrixTable.monthly-transposed th,
#yearMatrixTable.monthly-transposed td {
    border-right: 1px solid #cbd5e1;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.1;
    min-width: 54px;
    padding: 4px 5px;
    text-align: center;
    width: 54px;
}

#yearMatrixTable.monthly-transposed thead tr {
    height: 270px;
}

#yearMatrixTable.monthly-transposed th:first-child,
#yearMatrixTable.monthly-transposed td:first-child {
    background: var(--surface-soft);
    border-right: 2px solid #94a3b8;
    min-width: 138px;
    width: 138px;
}

#yearMatrixTable.monthly-transposed .rotated-name {
    height: 270px;
    min-width: 58px;
    overflow: visible;
    padding: 6px 3px;
    position: relative;
    vertical-align: bottom;
    width: 58px;
}

#yearMatrixTable.monthly-transposed .rotated-name span {
    bottom: 128px;
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 700;
    left: 50%;
    letter-spacing: 0.7px;
    line-height: 1.15;
    max-width: 235px;
    overflow: visible;
    position: absolute;
    text-align: left;
    transform: translateX(-50%) rotate(-90deg);
    transform-origin: center;
    white-space: nowrap;
    width: 235px;
}

#yearMatrixTable.monthly-transposed .monthly-date-cell {
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

#yearMatrixTable.monthly-transposed .employee-day-cell {
    border-right: 1px solid #cbd5e1;
    min-width: 54px;
    width: 54px;
}

#yearMatrixTable.monthly-detail-groups {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    min-width: max-content;
}

#yearMatrixTable.monthly-detail-groups th,
#yearMatrixTable.monthly-detail-groups td {
    border-right: 1px solid #cbd5e1;
    font-size: 11px;
    line-height: 1.15;
    min-width: 72px;
    padding: 4px 5px;
    text-align: center;
    white-space: nowrap;
}

#yearMatrixTable.monthly-detail-groups thead th {
    background: #374151;
    color: #fff;
}

#yearMatrixTable.monthly-detail-groups .employee-group-head {
    background: #374151;
    border-inline-start: 3px solid #111827;
    color: #fff;
    font-weight: 700;
    min-width: 504px;
}

#yearMatrixTable.monthly-detail-groups .leave-employee-head {
    min-width: 150px;
}

#yearMatrixTable.monthly-detail-groups .employee-group-start {
    border-inline-start: 3px solid #111827;
}

#yearMatrixTable.monthly-detail-groups .monthly-date-head,
#yearMatrixTable.monthly-detail-groups td:first-child {
    background: var(--surface-soft);
    border-right: 2px solid #94a3b8;
    min-width: 138px;
    position: sticky;
    text-align: left;
    width: 138px;
    z-index: 4;
}

html:not([dir="rtl"]) #yearMatrixTable.monthly-detail-groups .monthly-date-head,
html:not([dir="rtl"]) #yearMatrixTable.monthly-detail-groups td:first-child {
    left: 0;
}

html[dir="rtl"] #yearMatrixTable.monthly-detail-groups .monthly-date-head,
html[dir="rtl"] #yearMatrixTable.monthly-detail-groups td:first-child {
    left: auto;
    right: 0;
    text-align: right;
}

#yearMatrixTable.monthly-detail-groups .monthly-date-head {
    background: #374151;
    color: #fff;
    z-index: 5;
}

#yearMatrixTable.monthly-detail-groups tbody tr:nth-child(even) td {
    background: #f8fbff;
}

#yearMatrixTable.monthly-detail-groups tbody tr:nth-child(even) td:first-child {
    background: var(--surface-soft);
}

#yearMatrixTable.monthly-detail-groups tbody tr.weekend-row td,
#yearMatrixTable.monthly-detail-groups tbody tr.weekend-row td:first-child {
    background: #6b7280;
    color: #fff;
}

#yearMatrixTable.monthly-detail-groups tbody tr.monthly-total-row td,
#yearMatrixTable.monthly-detail-groups tbody tr.monthly-total-row td:first-child {
    background: #374151;
    color: #fff;
    font-weight: 700;
}

#yearMatrixTable .matrix-hours-cell {
    background: #f8fbff;
    color: #172033;
    font-weight: 400;
    letter-spacing: 0;
}

#yearMatrixTable .matrix-empty-cell {
    color: #cbd5e1;
}

#yearMatrixTable .matrix-leave-cell {
    background: #eef6ff;
    color: #172033;
    font-weight: 700;
    text-align: center;
}

.company-attendance-stack {
    display: grid;
    gap: 18px;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
    padding-right: 6px;
}

.attendance-company-section {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    max-width: 100%;
    overflow: hidden;
}

.attendance-company-section h2 {
    margin: 0 0 8px;
}

.panel p,
.panel span,
.panel label,
.panel td,
.panel summary,
.edit-card span,
.dashboard-card span,
.user-chip,
.sidebar-footer .footer-link {
    color: var(--text);
}

.panel button span,
.panel thead th span,
.panel .weekend-row td,
.panel .weekend-row span,
.panel .monthly-total-row td,
.panel .monthly-total-row span,
.panel .employee-group-head span,
.panel .attendance-employee-head span,
.panel .month-group-head span {
    color: inherit;
}

.attendance-grid-top-scroll,
.attendance-grid-bottom-scroll {
    height: 10px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.attendance-grid-top-scroll div,
.attendance-grid-bottom-scroll div {
    height: 1px;
}

.attendance-grid-wrap {
    border: 1px solid var(--line);
    border-radius: 6px;
    max-height: 76vh;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.attendance-grid-wrap::-webkit-scrollbar:horizontal {
    display: none;
}

.attendance-grid-wrap::-webkit-scrollbar:vertical {
    display: initial;
    width: 8px;
}

.attendance-month-grid {
    border-collapse: separate;
    border-spacing: 0;
    min-width: max-content;
    table-layout: auto;
    width: max-content;
}

.attendance-month-grid th,
.attendance-month-grid td {
    border-right: 1px solid #cbd5e1;
    border-bottom: 1px solid #dbe4ef;
    font-size: 11px;
    line-height: 1;
    min-width: 64px;
    padding: 0 1px;
    text-align: center;
    white-space: nowrap;
}

.attendance-month-grid thead th,
.attendance-month-grid .attendance-employee-head {
    background: #374151;
    color: #fff;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 3;
}

.attendance-month-grid thead tr:nth-child(2) th {
    top: 24px;
    z-index: 4;
}

.attendance-month-grid .attendance-employee-head {
    border-inline-start: 3px solid #111827;
    height: 24px;
    min-width: 448px;
    top: 0;
}

.attendance-month-grid .attendance-employee-head span {
    display: block;
    font-size: 10px;
    font-weight: 600;
    opacity: 0.85;
}

.attendance-month-grid .employee-group-start {
    border-inline-start: 3px solid #111827;
}

.attendance-month-grid .attendance-date-head,
.attendance-month-grid .attendance-date-cell {
    border-right: 2px solid #94a3b8;
    left: 0;
    min-width: 98px;
    position: sticky;
    text-align: left;
    width: 98px;
    z-index: 6;
}

.attendance-month-grid .attendance-date-head {
    background: #374151;
    color: #fff;
    top: 0;
    z-index: 8;
}

.attendance-month-grid .attendance-date-cell {
    background: var(--surface-soft);
}

.attendance-month-grid tbody tr:nth-child(even) td {
    background: #f8fbff;
}

.attendance-month-grid tbody tr:nth-child(even) .attendance-date-cell {
    background: var(--surface-soft);
}

.attendance-month-grid tbody tr.weekend-row td,
.attendance-month-grid tbody tr.weekend-row .attendance-date-cell {
    background: #6b7280;
    color: #fff;
}

.attendance-grid-time {
    border: 1px solid transparent;
    border-radius: 2px;
    box-sizing: border-box;
    font: inherit;
    font-size: 11px;
    height: 18px;
    line-height: 16px;
    padding: 0;
    text-align: center;
    width: 62px;
}

.attendance-grid-time:focus {
    border-color: var(--accent);
    outline: none;
}

.attendance-grid-time.pending-save {
    background: #fff7ed;
}

.attendance-grid-time.field-error {
    background: #fee2e2;
    border-color: #dc2626;
}

.attendance-actual-cell,
.attendance-added-cell,
.attendance-deducted-cell {
    background: #eef6ff;
    font-weight: 700;
}

html[dir="rtl"] .attendance-month-grid .attendance-date-head,
html[dir="rtl"] .attendance-month-grid .attendance-date-cell {
    left: auto;
    right: 0;
    text-align: right;
}

#yearMatrixTable.month-fit tbody tr:nth-child(even) .matrix-hours-cell {
    background: #eef7ff;
}

#weeklyProjectsTable input,
#weeklyProjectsTable select,
#projectsTable input {
    width: 100%;
}

#employeesTable input,
#employeesTable select {
    min-width: 120px;
    width: 100%;
}

#employeesTable {
    min-width: 1500px;
}

.row-actions,
#projectsTable th:first-child,
#projectsTable td:first-child,
#employeesTable th:first-child,
#employeesTable td:first-child {
    background: white;
    left: 0;
    position: sticky;
    z-index: 2;
}

#projectsTable th:first-child,
#employeesTable th:first-child {
    background: var(--surface-soft);
    z-index: 3;
}

.row-actions,
#projectsTable td:first-child {
    min-width: 145px;
    white-space: nowrap;
}

.row-actions button,
#projectsTable td:first-child button {
    margin: 0 4px 4px 0;
    padding-left: 9px;
    padding-right: 9px;
}

.project-name-cell {
    min-width: 180px;
}

.small-code {
    min-width: 100px;
}

.tiny-code {
    min-width: 72px;
}

#weeklyProjectsTable small {
    color: var(--muted);
    font-weight: 400;
}

#yearMatrixTable th,
#yearMatrixTable td {
    white-space: nowrap;
}

.generated-code {
    font-family: Consolas, monospace;
    font-size: 12px;
    min-width: 180px;
}

.field-display {
    color: var(--muted);
    display: block;
    font-size: 11px;
    margin-top: 2px;
}

.message {
    min-height: 20px;
}

.soft-message {
    color: #64748b;
    font-size: 13px;
    margin: 8px 0;
}

.excel-update-panel input[type="file"] {
    display: block;
    margin: 12px 0;
    max-width: 100%;
}

.import-report {
    background: #f7f7f5;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.error {
    color: var(--red);
}

.login-error {
    font-weight: 400;
}

.ok,
.ok-total {
    color: var(--green);
}

.bad-total {
    background: #fff1f1;
    color: var(--red);
}

.pct-invalid-day {
    background: #fff4f4;
}

.pct-invalid-day input {
    background: #fff8f8;
    border-color: #f2b8b8;
}

.ok-total {
    background: #ecfdf5;
}

@media (max-width: 1050px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
        position: static;
    }
    .side-nav {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }
    .grid.two {
        grid-template-columns: 1fr;
    }
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .card-form-grid,
    .record-view-controls,
    .section-title-row,
    .project-card-grid,
    .employee-card-grid,
    .leave-card-grid,
    .salary-card-grid,
    .holiday-card-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 720px) {
    main {
        padding: 8px 12px 24px;
    }
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 14px;
    }
    .attendance-controls,
    .form-grid,
    .punch-row,
    .project-form,
    .allocation-row,
    .month-controls,
    .monthly-kpis,
    .card-form-grid,
    .record-view-controls,
    .project-card-grid,
    .employee-card-grid,
    .leave-card-grid,
    .salary-card-grid,
    .holiday-card-grid {
        grid-template-columns: 1fr;
    }
    .leave-metric-grid,
    .leave-calendar {
        grid-template-columns: 1fr;
    }
    .edit-card-header {
        display: block;
    }
    .card-actions {
        justify-content: flex-start;
        margin-top: 10px;
    }
}

@media print {
    body {
        background: white;
    }
    .sidebar,
    .topbar,
    button,
    .actions,
    input,
    select {
        display: none !important;
    }
    .app-shell {
        display: block;
    }
    main {
        max-width: none;
        padding: 0;
    }
    .panel,
    .login-panel {
        border: 0;
        box-shadow: none;
        padding: 0;
    }
}
