/**
 * Payslip Calculator Styles
 * Consolidated clean version
 */

/* ===== Base Font Scale - 10% larger (elderly users) ===== */
html {
  font-size: 17.6px; /* 16px * 1.1 = 17.6px */
  height: 100dvh;
}

/* ===== CSS Variables ===== */
:root {
  --ink: #1e293b;
  --ink-secondary: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --line2: #f1f5f9;
  --paper: #ffffff;
  --bg: #f8fafc;
  --accent: #1e40af;
  --accent-light: #3b82f6;
  --accent-dark: #1e3a8a;
  --accent-bg: #eff6ff;
  --accent-border: #bfdbfe;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #86efac;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --cyan: #0891b2;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;
  --row-earnings: #f0fdf4;
  --row-deductions: #fef2f2;
  --row-summary: #eff6ff;
  --row-total: #f1f5f9;
}

/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
  font-family: 'Inter', Arial, sans-serif;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  color: var(--ink);
  margin: 0;
  padding: 0;
  background: var(--bg);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ===== Typography ===== */
h1 {
  font-size: 32px;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--ink);
}

h2 {
  font-size: 22px;
  font-weight: 700;
}

h3 {
  font-size: 20px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 15px;
  margin-top: 6px;
}

/* h2 styled as h3 for heading hierarchy fix (h1 → h2 instead of h1 → h3) */
h2.settings-section-heading {
  font-size: 20px;
  font-weight: 700;
}

.tiny {
  font-size: 13px;
  color: var(--ink-secondary);
}

/* ===== Layout ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--centered {
  max-width: 900px;
  margin: 0 auto;
}

.row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.hr {
  border: none;
  border-top: 2px solid var(--line);
  margin: 24px 0;
}

/* ===== Form Elements ===== */
label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 16px;
}

input,
select {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  color: var(--ink);
  box-sizing: border-box;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.08);
}

input:hover:not(:focus),
select:hover:not(:focus) {
  border-color: #94a3b8;
}

input[readonly] {
  background: var(--bg);
  color: var(--muted);
  cursor: default;
}

input[type="checkbox"] {
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.settings-modal-body input:not([type="checkbox"]),
.settings-modal-body select {
  max-width: 320px;
}

.settings-modal-body .date-input-wrapper {
  max-width: 320px;
}

/* ===== Date Picker ===== */
.date-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.date-input-wrapper input[type="text"] {
  padding-inline-end: 45px;
}

.calendar-icon {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  display: inline-flex;
  align-items: center;
}

.calendar-icon:hover {
  opacity: 0.7;
}

.hidden-date-picker {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg);
  border-color: #94a3b8;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  background: var(--line2);
}

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

#downloadPdf,
#lockPayslipBtn {
  width: auto;
  padding: 18px 28px;
  margin-inline-end: auto;
}

.btn.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: var(--shadow);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ===== Messages ===== */
.warn {
  color: var(--warning);
  font-size: 16px;
  padding: 12px;
  background: #fffbeb;
  border-radius: 10px;
  border: 2px solid #fcd34d;
}

.ok {
  color: var(--success);
  font-size: 16px;
}

.noteBox {
  border: 2px solid var(--line);
  background: #f9fafb;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 16px;
  color: #374151;
  line-height: 1.5;
}

.noteBox--warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: #92400e;
}

.noteBox--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

.noteBox--info {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.noteBox--success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #065f46;
}

.noteBox--holiday {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e3a5f;
}

/* Holiday alert panel */
.holiday-alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.holiday-balance-badge {
  background: #dbeafe;
  color: #1e40af;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.holiday-action-row {
  padding: 10px 0;
  border-bottom: 1px solid #e0e7ff;
}

.holiday-action-row:last-child {
  border-bottom: none;
}

.holiday-auto-status {
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
  margin-top: 2px;
}

.holiday-action-label {
  font-size: 15px;
  margin-bottom: 6px;
}

.holiday-shabbat-tag {
  background: #fef3c7;
  color: #92400e;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
}

.holiday-conflict-note {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 15px;
  color: #856404;
  margin-bottom: 4px;
}

.holiday-action-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.holiday-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.holiday-radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.holiday-hours-input {
  width: 50px;
  font-size: 13px;
  padding: 2px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-align: center;
}

.holiday-hours-label {
  font-size: 15px;
  color: #64748b;
}

/* ===== Compensation Rest Alert Panel ===== */
.noteBox--comprest {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #7f1d1d;
}

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

.comprest-count-badge {
  background: #fecaca;
  color: #991b1b;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.comprest-row {
  padding: 10px 0;
  border-bottom: 1px solid #fecaca;
}

.comprest-row:last-child {
  border-bottom: none;
}

.comprest-row--overdue {
  background: #fef2f2;
  border-radius: 6px;
  padding: 10px 8px;
  margin: 4px 0;
}

.comprest-row--done {
  color: #065f46;
  font-size: 13px;
  opacity: 0.8;
}

.comprest-status {
  display: block;
  font-size: 13px;
  margin: 4px 0;
}

.comprest-overdue {
  color: #dc2626;
  font-weight: 700;
}

.comprest-pending {
  color: #d97706;
  font-weight: 600;
}

.comprest-check {
  color: #059669;
  font-weight: 700;
  margin-right: 4px;
}

.comprest-action {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comprest-action label {
  font-size: 13px;
  font-weight: 600;
}

.comprest-date-input {
  font-size: 15px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  min-height: 32px;
}

.comprest-label {
  font-size: 15px;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 2px solid var(--line);
  padding: 12px;
  text-align: right;
  vertical-align: top;
}

th {
  background: var(--bg);
  font-size: 16px;
}

/* ===== Tooltips ===== */
.field-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  font-size: 15px;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.info-icon span {
  font-weight: bold;
}

.info-icon .tooltip {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
  position: absolute;
  z-index: 1010;
  min-width: 280px;
  max-width: 420px;
  width: max-content;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  top: 22px;
  right: -4px;
}

.info-icon:hover .tooltip,
.info-icon:focus .tooltip,
.info-icon.tooltip-open .tooltip {
  visibility: visible;
  opacity: 1;
}

.tooltip .lang-he,
.tooltip .lang-en {
  display: block;
}

.tooltip .lang-he {
  direction: rtl;
  text-align: right;
  margin-bottom: 4px;
}

.tooltip .lang-en {
  direction: ltr;
  text-align: left;
}

.tooltip .lang-sep {
  display: none;
}

/* A6: Respect language mode in tooltips */
body[data-lang="he"] .tooltip .lang-en { display: none; }
body[data-lang="en"] .tooltip .lang-he { display: none; }

.tooltip p {
  margin: 0 0 6px 0;
}

.tooltip p:last-child {
  margin: 0;
}

/* ===== Termination Sections ===== */
#termResultsSection {
  max-width: 75%;
  margin-left: auto;
  margin-right: auto;
}

.term-section {
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.term-section h3 {
  margin: 0 0 10px 0;
  font-size: 15px;
}

.term-section details summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}
.term-section details summary::-webkit-details-marker { display: none; }
.term-section details summary::before {
  content: '\25BE';
  margin-inline-end: 12px;
  font-size: 36px;
  color: #1e40af;
  font-weight: bold;
  line-height: 0.5;
  display: inline-block;
  animation: term-arrow-lr 1s ease infinite;
}
.term-section details:not([open]) summary::before {
  content: '\25B8';
  animation: term-arrow-lr 1s ease infinite;
}

@keyframes term-arrow-lr {
  0%, 100% { translate: 0 0; }
  50% { translate: 4px 0; }
}
.term-section details summary h3 {
  margin: 0;
  display: inline;
  flex: 1;
  font-size: 18px;
}
.term-section-total {
  font-size: 22px;
  font-weight: 700;
}

.term-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.term-section td {
  padding: 8px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.term-section tr:last-child td {
  border-bottom: none;
}

.term-section-a { background: #f0fdfa; border: 2px solid #5eead4; }
.term-section-b { background: #f0fdf4; border: 2px solid #86efac; }
.term-section-c { background: #f5f3ff; border: 2px solid #c4b5fd; }
.term-section-d { background: #fffbeb; border: 2px solid #fcd34d; }
.term-section-bank { background: #eff6ff; border: 2px solid #93c5fd; }

.term-section .subtotal td {
  font-weight: 600;
  border-top: 2px solid rgba(0, 0, 0, 0.12);
  padding-top: 10px;
}

.term-section .sub-row td {
  color: #6b7280;
  font-size: 13px;
}

/* Value column alignment in settlement tables */
.term-section td.val {
  text-align: left;
}

/* Refund row (green emphasis) */
.term-section .refund-row td {
  font-weight: 600;
  color: #16a34a;
}

.term-section .sub-row td:first-child {
  padding-inline-start: 24px;
}

/* ===== Tabs (Underline Style) ===== */
.tabs {
  display: flex;
  gap: 0;
  margin: 0;
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
  flex: 0 0 100%;
}

.tab {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 20px;
  border-radius: 0;
  cursor: pointer;
  background: transparent;
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--ink);
  background: transparent;
  transform: none;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
  background: linear-gradient(to top, #fef08a 0%, #fef9c3 55%, transparent 100%);
  box-shadow: none;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
  flex: 1;
  overflow-y: auto;
  padding: 8px max(16px, calc((100% - 1100px) / 2)) 24px;
  isolation: isolate;
}

/* ===== Employer Tab: Independent Scroll Panes ===== */
#panelEmployer.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.employer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: start;
}

.payslip-date-card {
  margin-bottom: 20px;
  padding-top: 8px;
  background: #f9fafb;
}

.employer-left,
.employer-right {
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: auto;
  max-height: 100%;
}

/* ===== Collapsible Calculation Column ===== */
.btn-collapse-calc {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 20px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-collapse-calc:hover { color: var(--ink); }

.collapse-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 20px;
}
.employer-right.collapsed .collapse-chevron {
  transform: rotate(180deg);
  animation: chevron-bounce 1s ease infinite;
}
.employer-right:not(.collapsed) .collapse-chevron {
  animation: chevron-bounce-up 1s ease infinite;
}

@keyframes chevron-bounce {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}
@keyframes chevron-bounce-up {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 6px; }
}

.collapse-label {
  font-size: 15px;
  color: var(--muted);
}
.employer-right:not(.collapsed) .collapse-label-show {
  display: none;
}
.employer-right.collapsed .collapse-label-hide {
  display: none;
}

.collapsed-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.employer-right:not(.collapsed) .collapsed-summary {
  display: none;
}
.collapsed-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--row-summary);
}
.collapsed-summary-item:last-child {
  background: var(--row-total);
}
.collapsed-summary-label {
  font-weight: 600;
  font-size: 14px;
}
.collapsed-summary-value {
  font-weight: 700;
  font-size: 18px;
}


/* ===== Employee Payslip ===== */
#employeePayslip {
  max-width: 880px;
  margin: 0 auto;
}

.split3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.offscreen {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 900px;
  background: #fff;
}

.balanceMini {
  margin-top: 10px;
  border: 2px solid #eee;
  border-radius: 10px;
  overflow: hidden;
}

.balanceMini table th {
  background: #f3f4f6;
}

/* ===== Payslip Sheet Styling ===== */
.payslipLogo {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  padding: 12px 0 8px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 16px;
}

.payslipSheet {
  padding: 12px 16px 16px;
}

.payslipTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0 6px;
  margin-bottom: 8px;
}

.payslipTitle {
  line-height: 1.15;
}

.payslipTitle .titleMain {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
}

.payslipTitle .titleSub {
  font-size: 13px;
  color: var(--ink);
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.payslipMeta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 14px;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
}

.payslipMeta .k {
  color: var(--ink-secondary);
}

.payslipMeta #pPeriod {
  font-size: 17px;
  font-weight: 700;
}

/* ===== Party Boxes ===== */
.payslipParties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.partyBox {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  background: #ffffff;
}

.partyBox .role {
  font-size: 13px;
  color: var(--ink-secondary);
  font-weight: 400;
}

.partyBox .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.partyBox .idline {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-top: 1px;
}

/* ===== Slip Tables ===== */
.slipTable {
  table-layout: fixed;
  border: 2px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper);
  font-size: 15px;
}

.slipTable thead th {
  background: #f0f4f8;
  border-bottom: 2px solid var(--line);
  font-weight: 700;
}

.slipTable th,
.slipTable td {
  padding: 8px 10px;
  border-bottom: 2px solid var(--line2);
}

.slipTable td:nth-child(2),
.slipTable th:nth-child(2) {
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slipTable tbody:last-child tr:last-child td {
  border-bottom: none;
}

.slipTable tr td[colspan="2"] {
  background: #f0f4f8;
  font-weight: 700;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}

/* ===== 3-Column Bilingual Table ===== */
.slipTable3 {
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink);
  overflow: hidden;
  background: var(--paper);
  direction: ltr; /* A3: overridden per language below */
}

/* A3: Hebrew-only mode — flip table direction so Hebrew column reads RTL */
body[data-lang="he"] .slipTable3 {
  direction: rtl;
}

.slipTable3 thead th {
  background: #dce5ef;
  border-bottom: 2px solid var(--line);
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-secondary);
  text-align: left;
}

.slipTable3 th,
.slipTable3 td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line2);
}

.slipTable3 td {
  vertical-align: top;
}

.slipTable3 td:nth-child(1) {
  direction: ltr;
  text-align: left;
}

.slipTable3 td:nth-child(2) {
  direction: ltr;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slipTable3 td:nth-child(3) {
  direction: rtl;
  text-align: right;
}

.slipTable3 tr.sectionRow td {
  background: #dce5ef;
  font-weight: 600;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.slipTable3 tr.totalRow td {
  font-weight: 600;
  background: #f0f4f8;
  border-top: 2px solid var(--accent);
}

.slipTable3 tr.totalRow.grandTotal td {
  font-size: 20px;
  font-weight: 700;
  background: #dce5ef;
  padding: 8px 10px 32px;
}

.slipTable3 tbody tr:nth-child(even):not(.sectionRow):not(.totalRow) td {
  background: #f4f6f8;
}

.slipTable3 tbody:last-child tr:last-child td {
  border-bottom: none;
}

/* ===== Balances Grid ===== */
.balancesGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

/* sickBox and eventsBox now sit side-by-side in the 2-column grid */

.balanceBox {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
  min-width: 0;
}

.balanceBox .boxTitle {
  background: #dce5ef;
  padding: 5px 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.balanceBox table {
  table-layout: fixed;
  width: 100%;
  font-size: 16px;
  color: var(--ink);
}

.balanceBox td,
.balanceBox th {
  padding: 4px 10px;
  border-bottom: 1px solid var(--line2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.balanceBox tr:last-child td {
  border-bottom: none;
}

.balanceBox tr.closingRow td {
  font-weight: 600;
  background: #f0f4f8;
  border-top: 1px solid var(--line);
}

/* ===== Balance Cards (Sick / Vacation) ===== */
.balanceCard {
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 16px;
}
.balanceCard--sick {
}
.balanceCard--vacation {
}

/* ===== KV Table (Key-Value bilingual) ===== */
.kvTable {
  direction: ltr;
}

.kvTable td:nth-child(1) {
  direction: ltr;
  text-align: left;
}

.kvTable td:nth-child(2) {
  direction: ltr;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kvTable td:nth-child(3) {
  direction: rtl;
  text-align: right;
}

.slipTable3 td:nth-child(1),
.slipTable3 td:nth-child(3),
.kvTable td:nth-child(1),
.kvTable td:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.slipTable3 td:nth-child(3),
.kvTable td:nth-child(3) {
  text-align: right;
}

/* ===== Sick Box ===== */
.sickBox {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
  min-width: 0;
}

.sickBox .boxTitle {
  background: #dce5ef;
  padding: 5px 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--ink);
  font-size: 15px;
}

.pill .k {
  color: var(--ink-secondary);
  font-weight: 600;
}

.sickBox table {
  table-layout: fixed;
  width: 100%;
  font-size: 16px;
  color: var(--ink);
}

.sickBox td,
.sickBox th {
  padding: 4px 10px;
  border-bottom: 1px solid var(--line2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sickBox tr:last-child td {
  border-bottom: none;
}

/* ===== Events Box (PDF) ===== */
.eventsBox {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
}

.eventsBox .boxTitle {
  background: #dce5ef;
  padding: 5px 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.eventsBox td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--line2);
  font-size: 16px;
  color: var(--ink);
}

.eventsBox tr:last-child td {
  border-bottom: none;
}

/* ===== Events Log Section ===== */
.events-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 24px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f9fafb;
  border: 2px solid var(--line);
  border-radius: 8px;
  flex-wrap: wrap;
}

/* Global emoji icon size (legacy — payslip template only) */
.emoji {
  font-size: 27px;
  line-height: 1;
  vertical-align: middle;
}

/* Smaller emojis inside history panel (legacy) */
#panelHistory .emoji {
  font-size: 18px;
}

/* History card fills full panel width like other tabs */
#panelHistory .card {
  width: 100%;
}
/* Buttons row must NOT drive card width — it wraps within table width */
#panelHistory .row.mt-4 {
  width: 100%;
}
/* History panel buttons — auto-width, taller, direction-aware */
#panelHistory .row.mt-4 {
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}
#panelHistory .row.mt-4 .btn,
#panelHistory .row.mt-4 .input-group__btn {
  width: auto;
  padding: 14px 20px;
  font-size: 16px;
}
.history-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
#panelHistory .row.mt-4 .input-group__select {
  font-size: 16px;
  font-weight: 700;
  padding: 14px 12px;
  border: 3px solid var(--accent);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  background: #e0ecff;
}

/* Image-based icon (Fluent 3D) */
.icon-img {
  vertical-align: middle;
  flex-shrink: 0;
  object-fit: contain;
  display: inline-block;
}

/* Compact action buttons inside history table */
.history-table .btn {
  padding: 2px 6px;
  border-width: 1px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: transparent;
  border-color: transparent;
  width: auto;
}
.history-table .btn:hover {
  background: transparent;
}
.history-table .icon-img {
  width: 25px;
  height: 25px;
}
.history-table td:last-child {
  white-space: nowrap;
}

.event-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.event-label {
  font-weight: 700;
  font-size: 18px;
  min-width: 100px;
  color: var(--ink);
}

.event-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.event-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #e3f2fd;
  border: 2px solid #90caf9;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: #1565c0;
  white-space: nowrap;
}

.event-chip.shabbat { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.event-chip.sick { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.event-chip.holiday { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.event-chip.holiday-off { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.event-chip.holiday-worked { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.event-chip.holiday-forfeited { background: #f3f4f6; border-color: #d1d5db; color: #9ca3af; text-decoration: line-through; }
.event-chip .chip-status { font-size: 15px; opacity: 0.8; }
.event-chip.absence { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.event-chip.vacation-trip { background: #f0f9ff; border-color: #bae6fd; color: #0c4a6e; }

.event-chip .chip-date {
  direction: ltr;
}

.event-chip .chip-trip-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  direction: ltr;
}

.event-chip .chip-calc {
  font-size: 15px;
  opacity: 0.8;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

.event-chip .chip-remove {
  cursor: pointer;
  font-size: 15px;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.event-chip .chip-remove:hover {
  opacity: 1;
}

.btn-chip-add {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-inline-start: 4px;
}

.btn-chip-add:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.deduct-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  color: var(--muted);
  margin-right: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.deduct-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.deduct-checkbox span {
  font-weight: 600;
}

/* Events summary line — hidden (data visible via chips) */
.events-summary {
  display: none !important;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.modal-box h4 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-box .modal-date {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
}

.modal-box input {
  margin-bottom: 16px;
}

.modal-box .date-input-wrapper input {
  margin-bottom: 0;
}

.modal-warning {
  background: var(--warning-bg);
  border: 2px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  text-align: start;
}

.modal-danger {
  background: var(--danger-bg);
  border: 2px solid var(--danger-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  text-align: start;
}

.modal-info {
  background: var(--accent-bg);
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  text-align: center;
}

#sickDaysPreview input[type="checkbox"],
#holidayDaysPreview input[type="checkbox"],
#absenceDaysPreview input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

#sickDaysPreview label,
#holidayDaysPreview label,
#absenceDaysPreview label {
  margin-bottom: 0;
  font-weight: normal;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-actions .btn {
  padding: 10px 20px;
  font-size: 15px;
}

/* ===== Shabbat/Sick Modal Day Lists ===== */
.modal-day-row {
  border-bottom: 2px solid #f0f0f0;
}
.modal-day-row:last-child {
  border-bottom: none;
}

/* Doctor note indicator on sick chips */
.chip-note {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

/* ===== Signatures ===== */
.signatures {
  padding-top: 12px;
  margin-top: 12px;
  font-size: 16px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sigLine {
  flex: 1 1 280px;
  padding-bottom: 50px;
}

/* ===== Payslip Lower Section ===== */
.payslipLower {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

/* ===== Sticky Header ===== */
.sticky-header {
  flex-shrink: 0;
  padding: 12px max(16px, calc((100% - 1100px) / 2)) 0;
  background: var(--bg);
}

.header-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  direction: ltr;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 100%;
}

.header-left h1 {
  margin: 0;
  position: relative;
  line-height: 1;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Round icon buttons in header (gear, language, help) */
.header-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e2e8f0;
  border: 2px solid #cbd5e1;
  color: #475569;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease;
  line-height: 1;
  padding: 0;
}

#settingsGearBtn {
  font-size: 26px;
}

.header-icon-btn:hover {
  transform: scale(1.1);
}

/* ===== Empty State CTA (no payslips yet) ===== */
.empty-state-cta {
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

.onboarding-card {
  width: 100%;
  max-width: 600px;
}

.onboarding-heading {
  text-align: center;
  margin-bottom: 20px;
}

.onboarding-card .grid {
  text-align: start;
}

.empty-state-create-btn {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 12px 28px;
  border-radius: 8px;
  background: var(--accent);
  border: 2px solid #3b82f6;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.2);
  animation: cta-bob 2s ease-in-out infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.empty-state-create-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(30, 64, 175, 0.3);
  animation: none;
}

@keyframes cta-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== Print / A4 Rules ===== */
@page {
  size: A4;
  margin: 30mm;
}

/* ===== Version Badge (in settings modal) ===== */
.settings-version {
  text-align: left;
  padding: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.settings-version span {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ===== Lock Banner ===== */
.lock-banner {
  display: none;
  background: var(--warning-bg);
  border: 2px solid var(--warning-border);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin: 10px 0;
  text-align: center;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.1s ease, background 0.3s ease;
}

/* ===== Partial Badge ===== */
.partial-badge {
  display: none;
  background: var(--warning-bg);
  border: 2px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 15px;
  font-weight: 600;
}

/* ===== History Table ===== */
.table-scroll-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;
  margin: 0 0 24px;
}

.history-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 16px;
}

.history-table th {
  background: var(--bg);
  padding: 6px 12px;
  border-bottom: 2px solid var(--line);
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  white-space: nowrap;
  text-align: center;
}
.history-table th .lang-he,
.history-table th .lang-en {
  display: block;
  white-space: nowrap;
}
.history-table th .lang-sep {
  display: none;
}

.history-table th:nth-child(8),
.history-table th:nth-child(9) {
  min-width: 64px;
}

.history-table td {
  padding: 7px 18px;
  border-bottom: 2px solid var(--line2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-table .row-locked {
  background: var(--row-earnings);
}

.history-table .row-unlocked {
  background: var(--row-deductions);
}

.history-table .row-total {
  background: var(--row-total);
  font-weight: 700;
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* ===== Form 106 Summary ===== */
.form106-summary {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.form106-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  flex-wrap: wrap;
  gap: 16px;
}

.form106-details {
  font-size: 13px;
  color: var(--ink-secondary);
}

/* ===== Period Selector (Dual Dropdowns) ===== */
.period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.period-dropdown {
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.period-dropdown:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.period-dropdown:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
  outline: none;
}

.period-month {
  min-width: auto;
}

.period-year {
  min-width: 90px;
}

#workDaysRow input[type="number"] {
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-md);
  height: 40px;
}


.period-lock-indicator {
  font-size: 36px;
  margin-left: 8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  cursor: pointer;
  user-select: none;
  display: none;
  transition: transform 0.1s ease;
}

.period-lock-indicator.visible {
  display: inline;
}

.period-lock-indicator.pressing {
  transform: scale(1.2);
  animation: lock-pulse 0.5s ease infinite;
}

@keyframes lock-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

button.btn-new-period-full {
  margin-top: 8px;
  padding: 6px 12px !important;
  font-size: 12px !important;
  width: max-content !important;
}

/* ===== New Period Confirmation Modal ===== */
#newPeriodModal .modal-box {
  max-width: 380px;
  direction: rtl;
}
body[data-lang="en"] #newPeriodModal .modal-box {
  direction: ltr;
}

#newPeriodModal .period-preview {
  font-size: 22px;
  font-weight: 700;
  color: #1e40af;
  text-align: center;
  margin: 12px 0;
  padding: 12px;
  background: #dbeafe;
  border-radius: 8px;
}

/* ===== Payslip PDF Enhancement ===== */
.slipTable3 td:nth-child(2) {
  font-variant-numeric: tabular-nums;
}

/* ===== Utility Classes ===== */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex-1 { flex: 1; }
.grid-span-2 { grid-column: span 2; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.input-pair { display: flex; gap: 4px; }
.input-narrow { width: 80px; background: var(--paper); }

/* Welded select + button */
.input-group {
  display: inline-flex;
  align-items: stretch;
}
.input-group__select {
  width: auto;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-inline-start: none;
  height: 100%;
}
.input-group__btn {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}
.input-date { width: 80px; padding: 12px 8px; text-align: center; }
.label-sm { font-size: 15px; }
.label-inline { font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.brand-name { font-size: 138%; }
.sticky-header h1 { direction: ltr; text-align: left; }
.save-notification { display: none; font-size: 15px; font-weight: 600; position: absolute; }
.save-notification--success { color: var(--success); }
.save-notification--error { color: var(--danger); }

/* Gear button now uses .header-icon-btn styles (inline in header) */

/* ===== Clamp Warning (legal limit enforcement) ===== */
.clamp-warning {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  animation: clamp-fade 3s ease forwards;
}

@keyframes clamp-fade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes clamp-flash {
  0%, 60% { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18) !important; }
  100% { border-color: var(--line) !important; box-shadow: none !important; }
}

.input-clamped {
  animation: clamp-flash 2s ease-out !important;
  transition: none !important;
}

/* ===== Settings Modal ===== */
.settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}
.settings-modal {
  background: #fff;
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 1000px;
  width: 95%;
  max-height: 70vh;
  position: relative;
  display: flex;
  flex-direction: column;
}
.settings-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  z-index: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.settings-modal-close:hover {
  background: var(--line, #e5e7eb);
  color: var(--ink, #1a1a2e);
}
.settings-modal-body {
  overflow-y: auto;
  padding: 24px;
  flex: 1;
}

/* ===== Responsive Design ===== */

/* Tablet: 640px - 1024px */
@media (max-width: 1024px) {
  body {
    margin: 16px auto;
  }

  h1 {
    font-size: 26px;
  }

  /* version badge removed from header in tablet+ */

  .card {
    padding: 16px;
  }
}

/* Mobile: < 640px */
@media (max-width: 640px) {
  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
  }

  h1 {
    font-size: 22px;
    text-align: center;
  }

  /* --- Sticky Header --- */
  .sticky-header {
    padding: 8px 12px;
  }

  /* Mobile: two lines — logo+icons line 1, tabs line 2 */
  .header-row {
    gap: 4px;
  }
  .header-left {
    flex: 0 0 100%;
    justify-content: center;
    gap: 8px;
  }
  .header-left h1 {
    font-size: 20px;
  }
  .save-notification {
    position: static;
    font-size: 14px;
    font-weight: 600;
    display: none;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    z-index: auto;
    vertical-align: top;
  }
  .header-controls {
    gap: 22px;
  }
  .header-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-width: 2px;
  }

  /* --- Tabs: bottom bar on mobile --- */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--paper);
    border-top: 2px solid var(--line);
    border-bottom: none;
    justify-content: space-around;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));
    gap: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  }

  .tab {
    text-align: center;
    min-width: 0;
    padding: 14px 4px;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    border-bottom: none;
    border-top: none;
    margin-bottom: 0;
  }

  .tab.active {
    border-top: none;
    border-bottom: 3px solid var(--accent);
    margin-bottom: -3px;
  }

  body {
    padding-bottom: 80px;
  }

  /* --- Single-column layouts --- */
  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .grid > div {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .balanceCard table {
    table-layout: fixed;
    width: 100%;
    font-size: inherit;
  }

  .balanceCard td {
    padding: 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .balanceCard td:first-child {
    padding-inline-end: 8px;
  }

  .balanceCard td:last-child {
    text-align: end;
    font-variant-numeric: tabular-nums;
    padding-inline-start: 20px;
  }

  .balanceCard strong {
    font-size: inherit;
  }

  #panelEmployer.active {
    display: block;
    overflow-y: auto;
  }

  .employer-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .employer-left,
  .employer-right {
    overflow-y: visible;
    min-height: auto;
    width: calc(100% - 12px);
    box-sizing: border-box;
  }

  /* --- Cards --- */
  .card {
    padding: 12px;
    margin: 6px;
    border-radius: var(--radius-lg);
  }

  #panelTermination,
  #panelHistory {
    padding: 8px 16px 24px;
  }
  #panelHistory .card {
    width: calc(100% - 12px);
  }
  #panelTermination .card {
    padding: 12px;
    margin: 6px;
    border-radius: var(--radius-lg);
  }
  /* Wrap termination content in same visual card as employer */
  #panelTermination > .card:first-child {
    margin: 6px;
    width: auto;
  }

  #termResultsSection {
    max-width: 100%;
  }

  .term-section table,
  #panelTermination table {
    display: table;
    overflow-x: visible;
  }

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

  /* Start/End day fields stay side-by-side on mobile */
  #workDaysRow {
    flex-direction: row;
    gap: 2ch;
  }
  #workDaysRow > div {
    flex: 0 0 auto;
    width: auto;
  }
  #workDaysRow input {
    width: 70px !important;
  }

  /* --- Payslip date dropdowns: auto-width on mobile --- */
  .period-dropdown {
    width: auto !important;
    min-width: 0;
  }
  .period-month {
    min-width: 0;
    max-width: none;
    width: auto;
  }
  .period-year {
    min-width: 85px;
    max-width: 100px;
  }

  /* --- New payslip button: 15% bigger on mobile --- */
  button.btn-new-period-full {
    width: auto !important;
    padding: 9px 21px !important;
    font-size: 16px !important;
    margin-top: 16px !important;
  }

  /* --- Month allowance: narrower on mobile --- */
  #e_weeklyCashAllowance {
    width: 140px !important;
  }

  /* --- Touch targets (min 44px) --- */
  .btn {
    width: 100%;
    padding: 6px 14px;
    font-size: 16px;
    min-height: unset;
  }

  input,
  select {
    min-height: 44px;
    font-size: 20px;
    width: 100%;
    box-sizing: border-box;
  }

  /* --- Tables scroll on mobile --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #calcFullContent > table {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  /* Force balance/sick boxes to fit in 2-column grid on mobile */
  .balanceBox,
  .sickBox {
    min-width: 0 !important;
    overflow: hidden !important;
    max-width: 100%;
  }

  .balanceBox table,
  .sickBox table {
    display: table !important;
    width: 100% !important;
    table-layout: fixed !important;
    overflow: hidden;
    font-size: 11px;
  }

  .balanceBox .boxTitle,
  .sickBox .boxTitle {
    font-size: 11px;
    padding: 4px 6px;
    white-space: normal;
  }

  .balanceBox td,
  .balanceBox th,
  .sickBox td,
  .sickBox th {
    padding: 3px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
  }

  .table-scroll-wrapper {
    overflow-x: auto;
    max-width: 100%;
  }

  .history-table {
    display: table;
    table-layout: auto;
    min-width: 620px;
  }

  .payslipParties {
    grid-template-columns: 1fr;
  }

  .balancesGrid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    max-width: calc(100vw - 32px) !important;
    width: calc(100vw - 32px) !important;
    overflow: hidden !important;
    box-sizing: border-box;
  }

  /* --- Events --- */
  .event-row {
    flex-direction: row;
    align-items: center;
    min-height: 44px;
  }

  .event-chips {
    width: 100%;
    margin-top: 8px;
  }

  /* --- Modals --- */
  .modal-box {
    margin: 16px;
    padding: 20px;
    max-width: calc(100vw - 32px);
  }

  /* --- Settings modal full-width on mobile --- */
  .settings-modal {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px 12px 0 0;
    margin-top: auto;
  }

  .settings-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  /* --- Zoom pill smaller on mobile --- */
  .zoom-control {
    padding: 2px 4px;
  }
  .zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .zoom-value {
    font-size: 13px;
    min-width: 36px;
  }

  .signatures {
    flex-direction: column;
    gap: 12px;
  }

  /* --- Tooltips on mobile --- */
  .info-icon .tooltip {
    min-width: 200px;
    max-width: calc(100vw - 40px);
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
  }

  /* --- Prevent horizontal overflow --- */
  .panel {
    overflow-x: hidden;
    max-width: 100%;
  }
}

/* ===== Print Rules ===== */
@media print {
  body {
    zoom: 1 !important;
    background: #fff;
    max-width: none;
    margin: 0;
    padding: 0;
    height: auto;
    overflow: visible;
  }

  .app-container {
    height: auto;
  }

  .panel.active {
    overflow: visible;
    flex: none;
  }

  .sticky-header {
    position: static !important;
    box-shadow: none !important;
    border-bottom: none !important;
  }

  h1,
  .tabs,
  .header-controls,
  #panelEmployer,
  #settingsModalOverlay,
  #pdfHost {
    display: none !important;
  }

  #panelEmployee {
    display: block !important;
  }

  #panelEmployee .grid {
    display: block;
  }

  #panelEmployee .card:not(#employeePayslip) {
    display: none !important;
  }

  #employeePayslip {
    max-width: none;
    margin: 0;
    border: none;
  }

  .card {
    border: none;
    border-radius: 0;
    padding: 0;
  }

  .partyBox,
  .slipTable,
  .balanceBox,
  .sickBox {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ============================================
   LANGUAGE VISIBILITY (ALL MODES)
   ============================================ */

/* Hebrew mode - hide English */
body[data-lang="he"] .lang-en,
body[data-lang="he"] .lang-sep {
  display: none !important;
}

/* English mode - hide Hebrew */
body[data-lang="en"] .lang-he,
body[data-lang="en"] .lang-sep {
  display: none !important;
}

/* English mode - LTR direction */
body[data-lang="en"] {
  direction: ltr;
  text-align: left;
}

body[data-lang="en"] table,
body[data-lang="en"] th,
body[data-lang="en"] td,
body[data-lang="en"] label,
body[data-lang="en"] h2,
body[data-lang="en"] h3,
body[data-lang="en"] h4,
body[data-lang="en"] .card,
body[data-lang="en"] .noteBox {
  direction: ltr;
  text-align: left;
}

/* Tabs default to RTL (Hebrew/Dual), LTR only in English mode */
.tabs {
  direction: rtl;
}

body[data-lang="en"] .tabs {
  direction: ltr;
}

/* ===== Admin Rate Update Banner ===== */
.admin-rate-banner {
  background: var(--warning-bg);
  color: var(--warning);
  border-bottom: 1px solid var(--warning-border);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* ===== Admin Lock Icon on Settings Fields ===== */
.admin-lock-icon {
  cursor: help;
  font-size: 14px;
  margin-inline-start: 6px;
  opacity: 0.6;
}

/* ===== Pending Employee Events Panel ===== */
.pending-events-panel {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  margin: 12px 16px;
  overflow: hidden;
}

.pending-events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pending-events-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--warning);
}

.pending-events-badge {
  background: var(--warning);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: var(--radius-full);
  padding: 0 6px;
}

.pending-events-body {
  padding: 0 16px 12px;
}

.pending-event-card {
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.pending-event-info {
  flex: 1;
  min-width: 0;
}

.pending-event-type {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.pending-event-date {
  font-size: 12px;
  color: var(--muted);
}

.pending-event-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.pending-event-actions button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn-approve {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.btn-approve:hover { background: var(--success-border); }

.btn-reject {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.btn-reject:hover { background: var(--danger-border); }

/* Tab badge for pending count */
.tab-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: var(--radius-full);
  padding: 0 5px;
  margin-inline-start: 6px;
  display: inline-block;
  vertical-align: middle;
}

/* ================================================================
   ACCESSIBILITY (IS 5568 / WCAG 2.1 AA)
   Non-visual: always active. Visual: gated under html.a11y-mode.
   ================================================================ */

/* --- Screen-reader only utility (always active) --- */
.a11y-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 (always in DOM, visible only in a11y-mode on focus) --- */
.a11y-skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 100000;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
  opacity: 0;
  pointer-events: none;
  transition: none;
}
html.a11y-mode .a11y-skip-link:focus {
  top: 0;
  opacity: 1;
  pointer-events: auto;
}

/* --- Accessibility toggle button --- */
.a11y-toggle-btn {
  font-size: 18px !important;
  line-height: 1;
}

/* --- TOGGLE-GATED: Enhanced focus outlines --- */
html.a11y-mode input:focus-visible,
html.a11y-mode select:focus-visible,
html.a11y-mode textarea:focus-visible,
html.a11y-mode button:focus-visible,
html.a11y-mode a:focus-visible,
html.a11y-mode [tabindex]:focus-visible {
  outline: 3px solid var(--accent) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

/* --- TOGGLE-GATED: Minimum font sizes --- */
html.a11y-mode .tiny,
html.a11y-mode .field-default,
html.a11y-mode .default-value,
html.a11y-mode .constraint-badge {
  font-size: max(0.75rem, 13px);
}

/* --- TOGGLE-GATED: Reduced motion --- */
html.a11y-mode *,
html.a11y-mode *::before,
html.a11y-mode *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* --- TOGGLE-GATED: High contrast enhancements --- */
html.a11y-mode input,
html.a11y-mode select,
html.a11y-mode textarea {
  border-color: var(--ink-secondary) !important;
}

html.a11y-mode button {
  border-color: var(--ink-secondary);
}

/* --- OS High Contrast mode (always applies, no toggle needed) --- */
@media (forced-colors: active) {
  .tab.active {
    border-bottom: 3px solid LinkText;
  }
  .btn.primary {
    border: 2px solid ButtonText;
  }
  .noteBox {
    border: 2px solid CanvasText;
  }
  .save-notification {
    border: 1px solid CanvasText;
  }
}
