/* app.css — screen layout + the sheet itself (the sheet rules apply to print too). */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: #1d2129;
  background: #e9ebee;
}

.app { display: flex; height: 100vh; }

/* ---------------- Input panel ---------------- */
.panel {
  width: 560px; min-width: 460px; flex: 0 0 auto;
  overflow-y: auto; background: #f7f8fa; border-right: 1px solid #d5d9df;
  padding: 0 16px 40px;
}
.panel-head {
  position: sticky; top: 0; z-index: 5; background: #f7f8fa;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 8px; border-bottom: 1px solid #e1e4e8;
}
.panel-head h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.actions { display: flex; gap: 8px; }
.save-status { font-size: 12px; color: #6a7280; margin: 4px 0 8px; min-height: 16px; }

.card {
  background: #fff; border: 1px solid #dde1e6; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .6px; color: #4a5260; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { margin-bottom: 6px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
label small { font-weight: 400; color: #6a7280; }
.req { color: #c0392b; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1.3fr .8fr 1fr; gap: 0 12px; }

input[type=text], input[type=number], select {
  font: inherit; font-weight: 400; font-size: 14px;
  padding: 6px 8px; border: 1px solid #c3c8cf; border-radius: 5px; background: #fff; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid #2f6fdf; outline-offset: 0; border-color: #2f6fdf; }
input.bad { border-color: #c0392b; background: #fdf0ee; }
input:disabled { background: #eef0f2; color: #9aa1aa; }

.hint { font-size: 12px; color: #6a7280; margin: 0 0 8px; line-height: 1.45; }
.err { font-size: 12px; color: #c0392b; font-weight: 400; min-height: 0; margin: 0; }
kbd { font: 11px Consolas, monospace; border: 1px solid #c3c8cf; border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; background: #fafbfc; }

.btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 6px; border: 1px solid #c3c8cf; background: #fff; color: #1d2129;
}
.btn:hover { background: #f0f2f5; }
.btn.primary { background: #1f5fcf; border-color: #1f5fcf; color: #fff; }
.btn.primary:hover { background: #1a52b3; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* Day rows */
.days-head, .drow {
  display: grid; grid-template-columns: 34px 96px 1fr 1fr 62px 62px; gap: 6px; align-items: center;
}
.days-head { font-size: 11px; font-weight: 700; color: #6a7280; text-transform: uppercase; padding: 0 4px 4px; }
.drow { padding: 3px 4px; border-radius: 4px; font-size: 13px; }
.drow:nth-child(even) { background: #fafbfc; }
.drow .rn { font-weight: 700; text-align: right; }
.drow .rd { color: #4a5260; font-size: 12px; }
.drow.wk .rd { color: #b35c00; font-weight: 600; }
.drow.off { opacity: .45; }
.drow.off .rd { font-style: italic; }
.drow.hol { background: #eef5ff; }
.drow input[type=text] { padding: 4px 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.drow .dn {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 4px 0; border-radius: 4px; border: 1px solid #c3c8cf; background: #fff;
}
.drow .dn.night { background: #263247; color: #fff; border-color: #263247; }
.drow .dn:disabled { opacity: .5; cursor: default; }
.drow .holcell { display: flex; justify-content: center; }
.drow .holcell input { width: 17px; height: 17px; margin: 0; }
.cut-divider {
  margin: 4px 0; border-top: 3px solid #1d2129; position: relative; height: 0;
}
.cut-divider span {
  position: absolute; right: 0; top: -9px; background: #fff; padding: 0 6px;
  font-size: 11px; font-weight: 700; color: #1d2129;
}

.total-line {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid #e1e4e8; padding-top: 10px; font-size: 13px; color: #4a5260;
}
.total-line strong { font-size: 20px; color: #1d2129; font-variant-numeric: tabular-nums; }
.total-line strong.neg { color: #c0392b; }
.ot-summary { font-size: 13px; color: #4a5260; margin-top: 6px; }

/* ---------------- Preview ---------------- */
.preview { flex: 1 1 auto; overflow: auto; padding: 20px; }
.page {
  width: 210mm; height: 297mm; padding: 8mm; margin: 0 auto;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

/* ================= THE SHEET (screen + print) ================= */
.sheet {
  width: 194mm; height: 279mm; overflow: hidden;
  font-family: Arial, "Segoe UI", Tahoma, sans-serif; font-size: 10pt; color: #000;
  line-height: 1.15;
}
.sheet [lang=ar] { font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
.sheet .lbl { white-space: nowrap; }
.sheet .fill {
  flex: 1 1 auto; border-bottom: 0.3mm dotted #000; min-height: 5mm;
  padding: 0 2mm; font-weight: 700; font-size: 11pt; white-space: nowrap; overflow: hidden;
}

/* Header ~28mm */
.s-header {
  height: 28mm; display: grid;
  grid-template-columns: 30mm 1fr; grid-template-rows: 17mm 5mm 6mm; column-gap: 4mm;
}
.s-logo { grid-row: 1; grid-column: 1; height: 17mm; width: auto; max-width: 30mm; object-fit: contain; }
.s-titles { grid-row: 1; grid-column: 2; text-align: right; align-self: center; }
.s-ar { font-size: 22pt; line-height: 1.05; }
.s-en { font-size: 17pt; font-weight: 700; letter-spacing: .6mm; }
.s-address { grid-row: 2; grid-column: 1 / 3; font-size: 9pt; align-self: center; }
.s-month { grid-row: 3; grid-column: 1 / 3; display: flex; justify-content: flex-end; align-items: flex-end; gap: 2mm; }
.s-month .lbl { font-weight: 700; }
.s-month .fill { flex: 0 0 82mm; text-align: center; }
.s-month small { font-size: 9pt; font-weight: 400; }

/* Employee info ~17mm */
.s-info { height: 17mm; margin-top: 2mm; display: flex; flex-direction: column; justify-content: space-between; }
.s-line { display: flex; align-items: flex-end; gap: 2mm; height: 5.3mm; }

/* Day table ~150mm */
.s-days { height: 150mm; margin-top: 3mm; }
.s-halves { display: flex; gap: 0; }
.s-table {
  width: 50%; border-collapse: collapse; table-layout: fixed;
  border: 0.4mm solid #000;
}
.s-table + .s-table { border-left-width: 0.8mm; }
.s-table th, .s-table td {
  border: 0.25mm solid #000; padding: 0; text-align: center; vertical-align: middle;
}
.s-table th { height: 11mm; font-size: 9.5pt; font-weight: 400; line-height: 1.05; }
.s-table td { height: 7.8mm; font-size: 11pt; font-weight: 700; font-variant-numeric: tabular-nums; }
.s-table td.c-date { font-size: 10pt; font-weight: 400; }
.s-table col.c-date { width: 11mm; }
.s-table col.c-ordy { width: 24mm; }
.s-table col.c-day, .s-table col.c-night { width: 18.5mm; }
.s-table th.diag { position: relative; }
.s-table th.diag svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.s-table th.diag .t-trips { position: absolute; left: 1.2mm; top: .8mm; }
.s-table th.diag .t-ordy { position: absolute; right: 1.2mm; bottom: .8mm; text-align: right; }
.s-table td.x { padding: 0; position: relative; }
.s-table td.x svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.s-table tr.cut td { border-bottom: 0.9mm solid #000; }
.s-table tr.tot td { font-size: 11pt; }
.s-table tr.tot td.c-date { font-size: 9pt; font-weight: 700; }
.s-grand {
  height: 6mm; display: flex; justify-content: flex-end; align-items: center; gap: 2mm;
  font-size: 10pt; padding-right: 2mm;
}
.s-grand b { font-size: 12pt; min-width: 22mm; text-align: center; border-bottom: 0.3mm solid #000; }

/* Bottom ~74mm */
.s-bottom { height: 74mm; margin-top: 3mm; display: flex; gap: 6mm; }
.s-salary { flex: 0 0 94mm; }
.s-money { width: 100%; border-collapse: collapse; table-layout: fixed; border: 0.4mm solid #000; }
.s-money td { border: 0.25mm solid #000; height: 9.6mm; padding: 0 2mm; vertical-align: middle; }
.s-money td.m-lbl { width: 50mm; font-size: 10pt; }
.s-money td.m-lbl { display: table-cell; }
.s-money td.m-lbl span:first-child { display: inline-block; width: 26mm; }
.s-money td.m-bd { width: 26mm; text-align: right; font-size: 12pt; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.s-money td.m-fils { text-align: center; font-size: 12pt; font-weight: 700; font-variant-numeric: tabular-nums; }
.s-money .parts { display: block; font-size: 9pt; font-weight: 400; margin-bottom: .6mm; white-space: nowrap; }
.s-money tr.m-total td { border-top-width: 0.5mm; }
.s-money tr.m-recv td { height: 24mm; vertical-align: bottom; padding-bottom: 3mm; font-size: 10pt; }
.s-money .neg { color: #c0392b; }

.s-sign { flex: 1 1 auto; display: flex; flex-direction: column; }
.s-duty { display: flex; align-items: flex-end; gap: 2mm; height: 8mm; margin-bottom: 6mm; }
.s-duty .fill { white-space: normal; font-size: 10pt; }
.s-sig { margin-bottom: 4mm; }
.sig-lbl { display: flex; justify-content: space-between; font-size: 9.5pt; }
.sig-line { height: 10mm; border-bottom: 0.3mm dotted #000; }
