:root{
  --green:#69bd42;
  --teal:#55bda2;
  --teal-dark:#2c6d5e;
  --blue:#3f72c7;
  --red:#fb0808;
  --grid:#898989;
  --text:#111;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:#000;color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif}
.app{max-width:430px;margin:0 auto;background:#fff;min-height:100vh;padding-bottom:92px;position:relative;overflow:hidden}
.topbar{background:var(--teal);color:white;position:sticky;top:0;z-index:5;padding-top:env(safe-area-inset-top);box-shadow:0 1px 0 rgba(0,0,0,.2)}
.iosline{height:32px;padding:8px 26px 0;font-weight:700;font-size:18px;letter-spacing:.5px}
.iosline .right{float:right;font-size:15px}
.titleRow{display:flex;align-items:center;justify-content:space-between;padding:14px 20px 10px}
h1{font-size:23px;margin:0;font-weight:700}
.dateNav{display:flex;background:var(--teal-dark);border-radius:24px;overflow:hidden;align-items:center}
.dateNav button{background:transparent;color:white;border:0;font-size:42px;line-height:1;padding:0 18px;height:42px}
.dateNav button:nth-child(2){font-size:22px;border-left:1px solid rgba(255,255,255,.18);border-right:1px solid rgba(255,255,255,.18)}
.dateRow{display:grid;grid-template-columns:1fr auto auto;gap:14px;align-items:center;padding:8px 0 12px;font-size:28px}
.dateText{font:inherit;color:white;background:transparent;border:0;text-align:left;padding:0}
#datePicker{position:absolute;left:-9999px;opacity:0}
.dateRow span{font-size:28px}
.dateRow strong{font-size:28px;padding-right:50px}
main{min-height:calc(100vh - 160px)}
.screen{display:none}
.screen.active{display:block}
.alerts{padding:8px 0 0;background:#fff}
.alert{margin:8px 10px;padding:10px 12px;border-radius:10px;font-size:14px;font-weight:700}
.alert.ok{background:#e9f9ed;color:#166424}
.alert.warn{background:#fff3cd;color:#6c4e00}
.alert.bad{background:#ffe4e4;color:#8a0000}
.legend{display:flex;gap:9px;flex-wrap:wrap;padding:8px 10px;font-size:12px;align-items:center}
.sw{display:inline-block;width:14px;height:14px;border:1px solid #777;vertical-align:-2px;margin-right:3px}
.sw.work{background:var(--green)} .sw.rest{background:var(--blue)} .sw.bad{background:var(--red)}
.gridHint{margin:6px 10px 8px;font-size:13px;line-height:1.35;color:#333;background:#eef7ff;border:1px solid #cfe8ff;padding:8px 10px;border-radius:10px}
.diaryGrid{width:100%;background:#fff;overflow:hidden}
.block{display:grid;grid-template-columns:44px repeat(24,1fr);border-top:1px solid var(--grid)}
.hourLabel{height:18px;line-height:18px;font-size:21px;background:#fff;border-right:2px solid var(--grid);border-bottom:1px solid var(--grid);padding-left:1px;white-space:nowrap}
.hourLabel.blank{grid-column:1/2;border-right:1px solid var(--grid)}
.rowLabel{grid-column:1/2;height:72px;display:flex;align-items:center;font-size:18px;background:#fff;border-bottom:1px solid var(--grid);border-right:1px solid var(--grid)}
.slot{height:72px;border-right:1px solid var(--grid);border-bottom:1px solid var(--grid);background:#fff;touch-action:auto;-webkit-tap-highlight-color:transparent}
.slot.rest{background:var(--blue)}
.slot.work{background:var(--green)}
.slot.bad{background:var(--red)}
.slot.empty{background:#fff}
.slot.thick{border-right:3px solid var(--grid)}
.slot.dragPreview{outline:3px solid #111;outline-offset:-3px}
.diaryGrid.painting,.diaryGrid.painting *{touch-action:none;user-select:none;-webkit-user-select:none}
.totals{display:grid;grid-template-columns:1fr 1fr;background:var(--teal);color:white;font-size:21px;padding:5px 0}
.totals>div{white-space:nowrap}
.card{margin:12px 10px;background:#fff;border-radius:16px;padding:14px;box-shadow:0 1px 12px rgba(0,0,0,.15);border:1px solid #eee}
.card h2{font-size:20px;margin:0 0 12px}
.formGrid{display:grid;grid-template-columns:1fr 1fr;gap:9px}
label{display:flex;flex-direction:column;font-size:13px;font-weight:700;gap:5px;margin:8px 0}
input,select{font-size:16px;padding:10px;border-radius:10px;border:1px solid #bbb;background:#fff;color:#111;width:100%}
.checkLabel{flex-direction:row;align-items:center;font-weight:500;gap:8px}
.checkLabel input{width:auto}
.actions{display:flex;gap:9px;margin-top:12px}
.actions.vertical{flex-direction:column}
button{font-family:inherit}
.primary,.secondary,.danger{border:0;border-radius:12px;padding:12px 13px;font-size:16px;font-weight:800}
.primary{background:var(--teal-dark);color:white}
.secondary{background:#eee;color:#111}
.danger{background:#d53636;color:white}
.full{width:100%;margin-top:8px}
.hint{font-size:13px;color:#555;line-height:1.35}
.ruleCards{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.rule{border-radius:12px;padding:10px;border:1px solid #ddd;background:#f8f8f8}
.rule h3{margin:0 0 6px;font-size:14px}
.rule .bar{height:9px;background:#ddd;border-radius:99px;overflow:hidden}
.rule .fill{height:100%;background:var(--teal-dark);width:0%}
.rule.bad{background:#ffe4e4;border-color:#f3b4b4}
.rule.bad .fill{background:var(--red)}
.rule p{margin:6px 0 0;font-size:12px}
.nextBreak{margin-top:10px;padding:10px;border-radius:12px;background:#eef7ff;font-weight:700;font-size:14px}
.graphMeta{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-bottom:10px}
.graphMeta div{padding:10px;border:1px solid #ddd;border-radius:12px;background:#f9fafb}
.graphMeta strong{display:block;font-size:14px}
.graphMeta span{display:block;color:#666;font-size:12px;margin-top:4px}
.graphWrap{overflow:auto;background:#fafafa;border:1px solid #ddd;border-radius:12px;padding:10px}
#graphSvgHolder{min-width:760px}
.graphTable{width:100%;border-collapse:collapse;font-size:13px}
.graphTable th,.graphTable td{border:1px solid #ccc;padding:8px;text-align:left}
.graphTable th{background:#f1f1f1}
.tabbar{position:fixed;left:50%;bottom:12px;transform:translateX(-50%);max-width:390px;width:90%;height:74px;border-radius:40px;background:#0d0d0d;display:grid;grid-template-columns:repeat(6,1fr);gap:0;padding:6px;z-index:10;border:1px solid #333;box-shadow:0 4px 20px rgba(0,0,0,.4)}
.tabbar button{background:transparent;color:#eee;border:0;border-radius:34px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:22px;font-weight:700}
.tabbar button span{font-size:12px;margin-top:4px}
.tabbar button.active{background:#333;color:#25a5ff}
ol{padding-left:20px}
@media (max-width:360px){
  .dateRow{font-size:23px}.dateRow span,.dateRow strong{font-size:23px}.dateRow strong{padding-right:20px}
  .rowLabel{font-size:16px;width:40px}.block{grid-template-columns:40px repeat(24,1fr)}
  .slot,.rowLabel{height:64px}.hourLabel{font-size:18px}
  .totals{font-size:17px}
}

.dashboardCard{text-align:center}
.bigStatus{font-size:28px;font-weight:900;margin:10px 0}
#todayAdvice p{margin:8px 0;padding:8px 10px;background:#f5f5f5;border-radius:10px}


/* Paper sheet graph update */
.fullWidth{grid-column:1 / -1}
textarea{font-size:16px;padding:10px;border-radius:10px;border:1px solid #bbb;background:#fff;color:#111;width:100%;font-family:inherit}
.graphDetailsForm{align-items:start}
.changeTable{width:100%;border-collapse:collapse;font-size:13px}
.changeTable th,.changeTable td{border:1px solid #ccc;padding:6px;text-align:left;vertical-align:top}
.changeTable th{background:#f1f1f1}
.changeTable input,.changeTable textarea{font-size:14px;padding:8px}
.readonlyCell{background:#f7f7f7;font-weight:700}
#paperSheetPreview{min-width:1080px}
.paperSheet{background:#fff;color:#111;border:2px solid #444;border-radius:18px;padding:14px;font-family:Arial,Helvetica,sans-serif}
.psTitle{font-size:20px;font-weight:700;text-align:center;letter-spacing:.5px;margin-bottom:8px}
.psHeaderLine{display:grid;grid-template-columns:1fr auto auto auto;gap:14px;align-items:center;margin-bottom:6px}
.psHeaderLine .smallLbl{font-size:11px;color:#444}
.psHeaderLine .bigText{font-size:18px;font-weight:700}
.psHeaderLine .redText{font-size:18px;font-weight:700;color:#d82626}
.psSectionTitle{background:#5f5f5f;color:#fff;text-align:center;font-weight:700;padding:4px 8px;margin:8px 0 6px;font-size:12px;letter-spacing:.4px}
.psTopGrid{display:grid;grid-template-columns:2fr 1fr 1fr 1fr;gap:8px;align-items:start}
.psField{border:1px solid #333;min-height:38px;padding:4px 6px;background:#fff}
.psField .lbl{font-size:11px;color:#333;margin-bottom:2px}
.psField .val{font-size:16px;font-weight:700;color:#1439d6}
.psField .val.black{color:#111}
.psDayRow,.psStateRow{display:flex;gap:4px;flex-wrap:wrap}
.psMiniBox{border:1px solid #333;min-width:28px;padding:6px 6px;text-align:center;font-size:12px;background:#fff}
.psMiniBox.active{background:#eaf0ff;color:#1439d6;font-weight:700}
.psCheckList{display:grid;grid-template-columns:repeat(2,auto);gap:6px 10px;align-content:start}
.psCheck{display:flex;align-items:center;gap:6px;font-size:11px}
.psCheckBox{width:12px;height:12px;border:1px solid #333;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:700}
.psCommentsArea{border:1px solid #333;min-height:72px;padding:8px;font-size:12px;white-space:pre-wrap}
.psActivityArea{display:grid;grid-template-columns:38px 1fr;gap:0;margin-top:8px}
.psSideTitle{writing-mode:vertical-rl;transform:rotate(180deg);background:#5f5f5f;color:#fff;font-weight:700;text-align:center;letter-spacing:.4px;padding:10px 0;font-size:12px}
.psActivityMain{border:1px solid #333;border-left:0}
.psRowsTable{width:100%;border-collapse:collapse}
.psRowsTable th,.psRowsTable td{border:1px solid #333;padding:4px 6px;font-size:11px;vertical-align:top}
.psRowsTable th{background:#fafafa}
.psRowsTable td.vert{color:#1439d6;font-weight:700}
.psRowsTable .optional{color:#555;font-size:10px}
.psTotalsRow{display:flex;justify-content:flex-end;gap:28px;margin:6px 4px 0;font-size:12px;font-weight:700}
.psTwoUpWrap{display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:8px}
.psSignatureBox{border:1px solid #333;min-height:55px;padding:4px 6px}
.psFooterGrid{display:grid;grid-template-columns:1.2fr 2fr;gap:12px;margin-top:8px}
.psFine{font-size:10px;color:#333;line-height:1.3}
.psGraphBox{border-top:1px solid #333;padding-top:4px}
.psHide{display:none}


/* Statistics screen */
.statsHero h2{margin-bottom:4px}
.statsControl{display:grid;grid-template-columns:1fr;gap:8px;margin-top:8px}
.canDriveCard{border-radius:16px;padding:14px;margin-top:12px;border:1px solid #ddd;background:#f8fbff}
.canDriveCard.ok{background:#e9f9ed;border-color:#aadfb5}
.canDriveCard.warn{background:#fff3cd;border-color:#e5c45d}
.canDriveCard.bad{background:#ffe4e4;border-color:#f1aaaa}
.canDriveCard .big{font-size:25px;font-weight:900;margin:0 0 4px}
.canDriveCard .sub{font-size:14px;color:#444;margin:0}
.statsLimitCards{display:grid;grid-template-columns:1fr;gap:10px}
.statLimit{border:1px solid #ddd;border-radius:14px;padding:12px;background:#fafafa}
.statLimit.bad{background:#ffe4e4;border-color:#f1aaaa}
.statLimit h3{margin:0 0 6px;font-size:16px;display:flex;justify-content:space-between;gap:8px}
.statLimit .bar{height:10px;background:#ddd;border-radius:999px;overflow:hidden}
.statLimit .fill{height:100%;background:#2c6d5e;width:0%}
.statLimit.bad .fill{background:#d53636}
.statLimit p{margin:6px 0 0;font-size:13px;color:#444}
.statsRows{display:grid;gap:8px}
.statRow{display:grid;grid-template-columns:1fr auto;gap:12px;border-bottom:1px solid #eee;padding:8px 0;align-items:start}
.statRow strong{font-size:16px}
.statRow span{color:#777;font-size:16px;text-align:right}
.statRow small{display:block;color:#777;margin-top:4px;font-size:13px}
.lastDrivingBox{background:#111;color:#fff;border-radius:14px;padding:14px;font-size:19px;font-weight:900}
@media(max-width:390px){
  .tabbar button span{font-size:10px}
  .tabbar button{font-size:19px}
}

.bookSetupBox{margin-top:14px;border-top:1px solid #eee;padding-top:12px}
.bookSetupBox h3{font-size:17px;margin:0 0 8px}

.twoUpRuleNote{background:#fff3cd;border:1px solid #e3bd4f;border-radius:12px;padding:10px;margin:10px 0;font-size:13px;color:#5f4500;line-height:1.35}


/* Real work book PDF/SVG export */
.realBookSheet{border:0!important;border-radius:0!important;padding:0!important;background:#fff!important;box-shadow:none!important}
.realDiarySvg{display:block;background:white;width:100%;max-width:1120px;margin:0 auto}
@media print{
  @page{size:A4 landscape;margin:5mm}
  body{margin:0!important;background:white!important}
  .wrap{max-width:none!important;width:100%!important;margin:0!important}
  .realDiarySvg{width:100%!important;height:auto!important}
}

.smartTip{background:#eef7ff;border:1px solid #cfe8ff;border-radius:12px;padding:9px 10px;margin:8px 0;font-size:13px;line-height:1.35;color:#333}

.lockTip{background:#e9f9ed;border:1px solid #aadfb5;border-radius:12px;padding:9px 10px;margin:8px 0;font-size:13px;line-height:1.35;color:#174d22}

.pageOverrideForm.disabled{opacity:.55;pointer-events:none}
.pageOverrideForm input:disabled,.pageOverrideForm select:disabled{background:#f1f1f1;color:#777}

/* Diary error audit */
.auditSummary{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:10px 0}
.auditSummary .sumBox{border-radius:12px;padding:10px;text-align:center;background:#f5f5f5;border:1px solid #ddd}
.auditSummary .sumBox strong{display:block;font-size:20px}
.auditSummary .sumBox span{font-size:12px;color:#555}
.auditList{display:grid;gap:8px}
.auditItem{border:1px solid #ddd;border-radius:14px;padding:10px;background:#fff;text-align:left;width:100%}
.auditItem.error{background:#ffe4e4;border-color:#f1aaaa}
.auditItem.warn{background:#fff3cd;border-color:#e3c45d}
.auditItem.info{background:#eef7ff;border-color:#cfe8ff}
.auditItem strong{display:block;font-size:15px;margin-bottom:4px}
.auditItem span{display:block;font-size:13px;color:#555}
.auditItem small{display:block;font-size:12px;color:#777;margin-top:4px}
.auditFocusBox{outline:4px solid #ff8a00!important;box-shadow:0 0 0 4px rgba(255,138,0,.25)!important;background:#fff8e8!important}
.slot.auditFocus{outline:4px solid #ff8a00!important;outline-offset:-4px;box-shadow:inset 0 0 0 2px #111!important}
input.auditField,select.auditField,textarea.auditField{outline:4px solid #ff8a00!important;background:#fff8e8!important}

.auditFixPanel{display:none;margin:10px;border:2px solid #ff8a00;background:#fff8e8;border-radius:14px;padding:12px}
.auditFixPanel.active{display:block}
.auditFixPanel h3{margin:0 0 6px;font-size:17px}
.auditFixPanel p{margin:6px 0;font-size:14px;line-height:1.35}
.auditFixPanel .fixActions{display:flex;gap:8px;margin-top:10px}
.auditFixPanel button{border:0;border-radius:10px;padding:9px 10px;font-weight:800;background:#2c6d5e;color:#fff}
.auditFixPanel button.secondary{background:#eee;color:#111}
.auditItem .suggestion{margin-top:7px;background:rgba(255,255,255,.65);border-radius:10px;padding:7px;color:#333;font-size:12px}

.ruleHistoryBox{margin:12px 0;border-top:1px solid #eee;padding-top:12px}
.ruleHistoryBox h3{font-size:17px;margin:0 0 8px}
.historyList{margin-top:10px;display:grid;gap:8px}
.historyItem{border:1px solid #ddd;border-radius:12px;padding:9px;background:#fafafa;font-size:13px}
.historyItem strong{display:block;font-size:14px;margin-bottom:3px}
.modeBadge{display:inline-block;border-radius:999px;padding:3px 7px;background:#eef7ff;border:1px solid #cfe8ff;font-size:12px;margin:2px 4px 2px 0}

/* Compliance confidence and audit log */
.confidenceBox{border-radius:14px;padding:12px;border:1px solid #ddd;background:#f5f5f5}
.confidenceBox.safe{background:#e9f9ed;border-color:#aadfb5}
.confidenceBox.warning{background:#fff3cd;border-color:#e3c45d}
.confidenceBox.blocked{background:#ffe4e4;border-color:#f1aaaa}
.confidenceBox h3{margin:0 0 6px;font-size:18px}
.confidenceBox ul{margin:8px 0 0;padding-left:20px}
.confidenceBox li{margin:4px 0;font-size:13px}
.auditLogBox{margin-top:14px;border-top:1px solid #eee;padding-top:12px}
.auditLogBox h3{font-size:17px;margin:0 0 8px}
.auditLogList{display:grid;gap:7px;max-height:260px;overflow:auto;margin:8px 0}
.auditLogItem{border:1px solid #ddd;border-radius:10px;padding:8px;background:#fafafa;font-size:12px}
.auditLogItem strong{display:block;font-size:13px;margin-bottom:2px}
.restTypeSelect{min-width:135px}
.safeCalcNote{font-size:12px;color:#555;margin-top:6px;line-height:1.35}

.cancelledWatermark{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;font-size:72px;font-weight:900;color:rgba(210,0,0,.18);transform:rotate(-20deg);text-align:center;z-index:5}
.statusBanner{background:#ffe4e4;border:2px solid #d53636;border-radius:12px;padding:10px;margin:8px 0;font-weight:800;color:#7a0000}
.statusBanner.skipped{background:#fff3cd;border-color:#e3c45d;color:#604800}
.realBookSheet{position:relative}

input[data-uppercase-only="true"]{text-transform:uppercase}

.dataMigrationBadge{display:inline-block;border-radius:999px;background:#e9f9ed;border:1px solid #aadfb5;color:#174d22;font-size:12px;padding:3px 8px;margin-left:6px}

.auditActions{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap}
.auditActions button{border:0;border-radius:10px;padding:8px 10px;font-weight:800}
.auditOpenBtn{background:#2c6d5e;color:#fff}
.auditOptionalBtn{background:#eee;color:#111}
.dismissedAuditBox{background:#f5f5f5;border:1px dashed #bbb;border-radius:12px;padding:8px;margin-top:8px;font-size:12px;color:#555}

/* Layout/page-number/audit reliability update */
.realBookSheet{overflow:auto}
.realDiarySvg{max-width:1180px}
@media print{
  @page{size:A4 landscape;margin:4mm}
  .realDiarySvg{width:100%!important;max-height:190mm!important}
}
.slot.locked{opacity:.45;cursor:not-allowed}
.pageLockedOverlay{background:#ffe4e4;border:2px solid #d53636;border-radius:12px;padding:10px;margin:8px 0;font-weight:800;color:#7a0000}
.auditActions button{touch-action:manipulation}


/* Visual layout fix */
.formGrid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:14px 18px;
  align-items:end;
}
.formGrid label{min-width:0}
.formGrid input,.formGrid select,.formGrid textarea{
  width:100%;
  max-width:100%;
  min-width:0;
  box-sizing:border-box;
}
@media (max-width: 640px){
  .formGrid{grid-template-columns:1fr!important}
  .formGrid label{grid-column:auto!important}
}
.screen{padding-bottom:150px}
.toastMessage{
  position:fixed;
  left:50%;
  bottom:calc(92px + env(safe-area-inset-bottom));
  transform:translateX(-50%) translateY(20px);
  background:rgba(20,20,20,.92);
  color:#fff;
  padding:10px 18px;
  border-radius:999px;
  font-weight:800;
  font-size:15px;
  z-index:9999;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease, transform .2s ease;
  box-shadow:0 8px 24px rgba(0,0,0,.22);
}
.toastMessage.show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}
.realBookSheet{
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}
.realDiarySvg{
  display:block;
  width:100%;
  max-width:1180px;
  height:auto;
  margin:0 auto;
}
@media print{
  @page{size:A4 landscape;margin:4mm}
  html,body{background:#fff!important}
  .realDiarySvg{width:100%!important;height:auto!important;max-height:190mm!important}
}


.graphPdfBtn{margin:12px 0 22px}
.realBookSheet{
  background:#fff!important;
  border-radius:12px;
  padding:8px!important;
}
.realDiarySvg{
  width:100%;
  max-width:1180px;
  height:auto;
  display:block;
  margin:0 auto;
  background:#fff;
}
@media print{
  @page{size:A4 landscape;margin:3mm}
  .realBookSheet{padding:0!important;border-radius:0!important}
  .realDiarySvg{width:100%!important;height:auto!important;max-height:184mm!important}
}

.engineBadge{display:inline-block;border:1px solid #cfe8ff;background:#eef7ff;color:#17415f;border-radius:999px;padding:3px 8px;font-size:12px;font-weight:800;margin:4px 4px 4px 0}
.statLimit .anchorNote{font-size:12px;color:#666;margin-top:4px}

/* Compact app header update */
.topbar{
  padding-top:env(safe-area-inset-top);
  box-shadow:0 1px 0 rgba(0,0,0,.18);
}
.iosline{
  display:none!important;
}
.titleRow{
  padding:8px 14px 4px!important;
  min-height:42px;
  gap:10px;
}
.titleRow h1,
#screenTitle{
  font-size:21px!important;
  line-height:1.1!important;
  white-space:nowrap;
}
.dateNav{
  border-radius:20px!important;
  min-width:142px;
  height:36px;
  flex-shrink:0;
}
.dateNav button{
  height:36px!important;
  font-size:30px!important;
  padding:0 14px!important;
  display:flex;
  align-items:center;
  justify-content:center;
}
.dateNav button:nth-child(2){
  font-size:17px!important;
  width:44px;
  padding:0!important;
}
.dateRow{
  display:flex!important;
  grid-template-columns:none!important;
  align-items:center!important;
  gap:8px!important;
  padding:2px 14px 8px!important;
  font-size:18px!important;
  line-height:1.1!important;
  min-height:34px;
}
.dateText{
  font-size:20px!important;
  line-height:1.1!important;
  white-space:nowrap!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  flex:1 1 auto;
  min-width:0;
  padding:0!important;
}
.dateRow span{
  font-size:15px!important;
  opacity:.95;
  white-space:nowrap;
}
.dateRow strong{
  font-size:22px!important;
  padding-right:0!important;
  white-space:nowrap;
}
main{
  min-height:calc(100vh - 94px)!important;
}
@media (max-width:380px){
  .titleRow{padding-left:10px!important;padding-right:10px!important}
  .dateRow{padding-left:10px!important;padding-right:10px!important}
  .dateText{font-size:18px!important}
  .dateRow span{font-size:14px!important}
  .dateRow strong{font-size:20px!important}
  .dateNav{min-width:128px}
  .dateNav button{font-size:28px!important;padding:0 11px!important}
  .dateNav button:nth-child(2){width:40px;font-size:16px!important}
}

/* Location picker */
.locPickerWrap{display:flex;gap:6px;align-items:center}
.locPickerWrap input{flex:1;min-width:0}
.locBtn{
  border:1px solid #b7d7ff;
  background:#eef7ff;
  color:#064b87;
  border-radius:10px;
  min-width:42px;
  height:42px;
  font-size:18px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  touch-action:manipulation;
}
.locBtn:disabled{opacity:.55}
.locStatus{
  display:block;
  font-size:11px;
  color:#666;
  margin-top:3px;
}

/* Vehicle / driver registry */
.screenHeaderRow{display:flex;justify-content:space-between;gap:10px;align-items:center}
.miniBtnRow{display:flex;gap:8px;flex-wrap:wrap}
.registryList{display:grid;gap:8px}
.registryItem{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:13px 12px;
  border:1px solid #e2e2e2;
  border-radius:14px;
  background:#fff;
  text-align:left;
}
.registryItem strong{display:block;font-size:18px}
.registryItem small{display:block;color:#666;margin-top:3px;line-height:1.35}
.registryChevron{font-size:24px;color:#777}
.buttonRow{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.buttonRow button{flex:1;min-width:130px}
@media (prefers-color-scheme:dark){
  .registryItem{background:#151515;border-color:#333;color:#fff}
  .registryItem small{color:#aaa}
}

.autoSavedMeta{font-size:11px;color:#777;margin-top:4px}

/* Usability/performance correction update */
.topbar{
  position:sticky!important;
  top:0!important;
  z-index:1000!important;
  -webkit-transform:translateZ(0);
  transform:translateZ(0);
}
.dateNav{
  min-width:88px!important;
  width:88px!important;
  justify-content:space-between!important;
}
#todayBtn{
  display:none!important;
}
.dateNav button{
  flex:1 1 50%!important;
  min-width:44px!important;
}
.changeTable{
  table-layout:auto;
}
.changeTable th:nth-child(4),
.changeTable td:nth-child(4){
  min-width:260px!important;
  width:260px!important;
}
.locPickerWrap{
  display:flex!important;
  gap:8px!important;
  align-items:center!important;
  min-width:250px!important;
}
.locPickerWrap input{
  min-width:200px!important;
  height:44px!important;
  font-size:16px!important;
  padding:10px!important;
}
.locBtn{
  width:44px!important;
  min-width:44px!important;
  height:44px!important;
  flex:0 0 44px!important;
}
#graphScreen .graphWrap{
  max-height:64vh!important;
  overflow:auto!important;
}
#graphScreen #paperSheetPreview{
  min-width:820px!important;
  max-width:900px!important;
}
#graphScreen .realDiarySvg{
  max-width:900px!important;
}
@media (max-width:420px){
  #graphScreen #paperSheetPreview{
    min-width:820px!important;
  }
}
@media print{
  #graphScreen #paperSheetPreview{min-width:0!important;max-width:none!important}
  #graphScreen .realDiarySvg{max-width:none!important}
}

/* Fast mode smooth interactions */
#diaryGrid{touch-action:pan-y}
.slot{will-change:background-color}

/* Fast mode v2: fixed header and usable work/rest change table */
html,body{
  scroll-padding-top:96px;
}
.topbar{
  position:fixed!important;
  top:0!important;
  left:0!important;
  right:0!important;
  width:100%!important;
  z-index:9999!important;
  -webkit-transform:translateZ(0);
  transform:translateZ(0);
}
main{
  padding-top:96px!important;
}
#changeDetailsEditor{
  overflow-x:auto!important;
  -webkit-overflow-scrolling:touch;
  padding-bottom:8px;
}
#changeDetailsEditor table,
.changeTable{
  min-width:860px!important;
  table-layout:fixed!important;
}
.changeTable th,
.changeTable td{
  vertical-align:top;
}
.changeTable th:nth-child(1), .changeTable td:nth-child(1){width:82px!important}
.changeTable th:nth-child(2), .changeTable td:nth-child(2){width:92px!important}
.changeTable th:nth-child(3), .changeTable td:nth-child(3){width:112px!important}
.changeTable th:nth-child(4), .changeTable td:nth-child(4){
  width:230px!important;
  min-width:230px!important;
}
.changeTable th:nth-child(5), .changeTable td:nth-child(5){
  width:150px!important;
  min-width:150px!important;
}
.changeTable th:nth-child(6), .changeTable td:nth-child(6){
  width:180px!important;
  min-width:180px!important;
}
.locPickerWrap{
  min-width:220px!important;
}
.locPickerWrap input{
  min-width:166px!important;
  width:166px!important;
}
.restTypeSelect{
  width:140px!important;
  min-width:140px!important;
}
.locationToggleLine{
  margin:8px 0!important;
}
body.location-picker-off .locBtn{
  display:none!important;
}
body.location-picker-off .locPickerWrap input{
  width:210px!important;
  min-width:210px!important;
}
@media (max-width:420px){
  main{padding-top:92px!important}
  #changeDetailsEditor table,
  .changeTable{min-width:850px!important}
}

/* Work/Rest change details horizontal scroll fix */
#changeScrollHint{
  margin:8px 0 6px;
  font-size:13px;
  font-weight:700;
  color:#496157;
  background:#eef8f2;
  border:1px solid #cbe8d5;
  border-radius:10px;
  padding:8px 10px;
}
#changeDetailsEditor{
  display:block!important;
  width:100%!important;
  max-width:100%!important;
  overflow-x:auto!important;
  overflow-y:visible!important;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-x pan-y;
  overscroll-behavior-x:contain;
  border:1px solid #e1e7e3;
  border-radius:14px;
  padding:6px;
  background:rgba(255,255,255,.55);
}
#changeDetailsEditor::after{
  content:"";
  display:block;
  height:1px;
  width:980px;
}
#changeDetailsEditor table,
#changeDetailsEditor .changeTable,
.changeTable{
  min-width:980px!important;
  width:980px!important;
  max-width:none!important;
  table-layout:fixed!important;
  border-collapse:separate;
  border-spacing:0 6px;
}
.changeTable th,
.changeTable td{
  padding:5px!important;
  box-sizing:border-box!important;
  vertical-align:middle!important;
}
.changeTable th:nth-child(1), .changeTable td:nth-child(1){width:78px!important}
.changeTable th:nth-child(2), .changeTable td:nth-child(2){width:88px!important}
.changeTable th:nth-child(3), .changeTable td:nth-child(3){width:112px!important}
.changeTable th:nth-child(4), .changeTable td:nth-child(4){width:285px!important;min-width:285px!important}
.changeTable th:nth-child(5), .changeTable td:nth-child(5){width:155px!important;min-width:155px!important}
.changeTable th:nth-child(6), .changeTable td:nth-child(6){width:210px!important;min-width:210px!important}
.changeTable th:nth-child(7), .changeTable td:nth-child(7){width:52px!important}
.locPickerWrap{
  display:flex!important;
  gap:8px!important;
  align-items:center!important;
  min-width:270px!important;
  width:270px!important;
}
.locPickerWrap input{
  min-width:210px!important;
  width:210px!important;
  height:44px!important;
  font-size:16px!important;
}
.locBtn{
  width:44px!important;
  min-width:44px!important;
  height:44px!important;
  flex:0 0 44px!important;
}
body.location-picker-off .locPickerWrap{width:270px!important}
body.location-picker-off .locPickerWrap input{
  width:260px!important;
  min-width:260px!important;
}
.restTypeSelect,
.changeTable select{
  min-width:140px!important;
  width:140px!important;
}
.changeTable input,
.changeTable select{
  height:44px!important;
  font-size:15px!important;
}
.changeTable textarea{
  min-height:44px!important;
  font-size:15px!important;
}
@media (prefers-color-scheme:dark){
  #changeScrollHint{background:#102419;border-color:#284d35;color:#bde8ca}
  #changeDetailsEditor{background:rgba(0,0,0,.2);border-color:#333}
}

/* Breach highlight + sticky Work/Rest change columns update */
.slot.bad{
  background:var(--red)!important;
  color:#fff!important;
}
#changeDetailsEditor{
  position:relative;
}
.changeTable th:nth-child(1),
.changeTable td:nth-child(1){
  position:sticky!important;
  left:0!important;
  z-index:5!important;
  background:#fff!important;
  box-shadow:2px 0 3px rgba(0,0,0,.08);
}
.changeTable th:nth-child(2),
.changeTable td:nth-child(2){
  position:sticky!important;
  left:78px!important;
  z-index:5!important;
  background:#fff!important;
  box-shadow:2px 0 3px rgba(0,0,0,.08);
}
.changeTable thead th:nth-child(1),
.changeTable thead th:nth-child(2){
  z-index:7!important;
}
.changeTable td.readonlyCell{
  font-weight:800;
}
@media (prefers-color-scheme:dark){
  .changeTable th:nth-child(1),
  .changeTable td:nth-child(1),
  .changeTable th:nth-child(2),
  .changeTable td:nth-child(2){
    background:#151515!important;
  }
}

/* Change details table visibility/sticky-column fix */
#changeDetailsEditor{
  min-height:190px!important;
  overflow-x:auto!important;
  overflow-y:auto!important;
  -webkit-overflow-scrolling:touch!important;
  background:#fff!important;
  color:#111!important;
  contain:layout paint;
}
#changeDetailsEditor table,
#changeDetailsEditor .changeTable,
.changeTable{
  display:table!important;
  visibility:visible!important;
  opacity:1!important;
  border-collapse:separate!important;
  border-spacing:0 6px!important;
  background:#fff!important;
  color:#111!important;
}
.changeTable thead,
.changeTable tbody,
.changeTable tr{
  visibility:visible!important;
  opacity:1!important;
}
.changeTable th,
.changeTable td{
  background:#fff!important;
  color:#111!important;
  border-color:#d7d7d7!important;
}
.changeTable th:nth-child(1),
.changeTable td:nth-child(1),
.changeTable th:nth-child(2),
.changeTable td:nth-child(2){
  position:sticky!important;
  background:#f7f7f7!important;
  color:#111!important;
  z-index:20!important;
  opacity:1!important;
  visibility:visible!important;
  box-shadow:2px 0 4px rgba(0,0,0,.12)!important;
}
.changeTable th:nth-child(1),
.changeTable td:nth-child(1){
  left:0!important;
}
.changeTable th:nth-child(2),
.changeTable td:nth-child(2){
  left:78px!important;
}
.changeTable thead th:nth-child(1),
.changeTable thead th:nth-child(2){
  background:#ececec!important;
  color:#111!important;
  z-index:30!important;
}
.changeTable td:nth-child(1),
.changeTable td:nth-child(2){
  font-weight:800!important;
}
.changeTable input,
.changeTable select,
.changeTable textarea{
  background:#fff!important;
  color:#111!important;
  -webkit-text-fill-color:#111!important;
}
@media (prefers-color-scheme:dark){
  #changeDetailsEditor{
    background:#fff!important;
    color:#111!important;
  }
  .changeTable,
  .changeTable th,
  .changeTable td,
  .changeTable th:nth-child(1),
  .changeTable td:nth-child(1),
  .changeTable th:nth-child(2),
  .changeTable td:nth-child(2){
    background:#fff!important;
    color:#111!important;
  }
  .changeTable thead th:nth-child(1),
  .changeTable thead th:nth-child(2){
    background:#ececec!important;
    color:#111!important;
  }
  .changeTable input,
  .changeTable select,
  .changeTable textarea{
    background:#fff!important;
    color:#111!important;
    -webkit-text-fill-color:#111!important;
  }
}

/* Graph refresh controls */
.graphRefreshRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:8px 0 12px;
}
.graphRefreshRow button{
  flex:1;
  min-width:140px;
}

/* Precise breach highlight */
.slot.bad{
  background:var(--red)!important;
  color:#fff!important;
}


/* Compact Find button + modal search */
.dateNav{
  min-width:170px!important;
  width:auto!important;
  gap:4px!important;
}
.findBtn{
  height:36px!important;
  padding:0 9px!important;
  border:0!important;
  background:rgba(255,255,255,.18)!important;
  color:#fff!important;
  font-size:13px!important;
  font-weight:900!important;
  white-space:nowrap!important;
  border-left:1px solid rgba(255,255,255,.25)!important;
  border-right:1px solid rgba(255,255,255,.25)!important;
}
.dateNav button.findBtn{
  flex:0 0 auto!important;
  min-width:62px!important;
}
.modalOverlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  z-index:20000;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:calc(70px + env(safe-area-inset-top)) 14px 20px;
}
.modalOverlay[hidden]{
  display:none!important;
}
.findModalCard{
  width:min(460px,100%);
  background:#fff;
  color:#111;
  border-radius:18px;
  padding:16px;
  box-shadow:0 18px 50px rgba(0,0,0,.35);
}
.modalHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.modalHeader h2{
  margin:0;
}
.modalClose{
  width:40px;
  height:40px;
  border-radius:50%;
  border:0;
  background:#eee;
  color:#111;
  font-size:26px;
  line-height:1;
  font-weight:900;
}
.findModalGrid{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  align-items:end;
  margin-top:12px;
}
.findModalGrid button{
  min-height:44px;
  white-space:nowrap;
}
#jumpStatus{
  min-height:18px;
  font-weight:800;
}
@media (max-width:520px){
  .dateNav{min-width:158px!important}
  .findBtn{font-size:12px!important;min-width:54px!important;padding:0 7px!important}
  .findModalGrid{grid-template-columns:1fr}
  .findModalGrid button{width:100%}
}
@media (prefers-color-scheme:dark){
  .findModalCard{
    background:#fff!important;
    color:#111!important;
  }
  .findModalCard input{
    background:#fff!important;
    color:#111!important;
    -webkit-text-fill-color:#111!important;
  }
}

/* Find modal v2 header/layout fix */
.titleRow{
  display:grid!important;
  grid-template-columns:auto 1fr auto!important;
  align-items:center!important;
  gap:8px!important;
  position:relative!important;
}
.titleRow h1,
#screenTitle{
  grid-column:2!important;
  text-align:center!important;
  justify-self:center!important;
  margin:0!important;
}
.dateNav{
  grid-column:3!important;
  justify-self:end!important;
  min-width:96px!important;
  width:auto!important;
}
.findBtn{
  grid-column:1!important;
  justify-self:start!important;
  height:34px!important;
  min-width:auto!important;
  padding:0 8px!important;
  border:0!important;
  border-radius:12px!important;
  background:rgba(255,255,255,.14)!important;
  color:#fff!important;
  font-size:15px!important;
  font-weight:500!important;
  line-height:1!important;
  white-space:nowrap!important;
}
.dateNav .findBtn{
  display:none!important;
}
.modalOverlay.show{
  display:flex!important;
}
.modalClose{
  cursor:pointer;
}
@media (max-width:420px){
  .titleRow{
    grid-template-columns:auto 1fr auto!important;
    gap:6px!important;
  }
  .findBtn{
    font-size:14px!important;
    padding:0 7px!important;
  }
  .titleRow h1,
  #screenTitle{
    font-size:19px!important;
  }
}

/* Find modal v3 action fix */
.modalOverlay[hidden]{
  display:none!important;
}
.modalOverlay.show{
  display:flex!important;
}
.findModalCard,
.findModalCard *{
  pointer-events:auto!important;
}
.modalClose,
#jumpDateBtn,
#jumpPageBtn,
#openFindModalBtn{
  cursor:pointer!important;
  touch-action:manipulation!important;
}

/* Diary Book History */
.diaryBookHistoryBox{
  margin-top:16px;
  padding:12px;
  border:1px solid #cfe7da;
  border-radius:16px;
  background:#f5fbf7;
}
.bookHistoryList{display:grid;gap:8px;margin:10px 0}
.bookHistoryItem{border:1px solid #d8e7de;border-radius:14px;padding:10px;background:#fff}
.bookHistoryItem strong{display:block;font-size:16px}
.bookHistoryItem small{display:block;color:#666;margin-top:3px;line-height:1.35}
.bookStatus{display:inline-block;padding:2px 8px;border-radius:999px;font-size:12px;font-weight:800;margin-left:6px;background:#e8f5ee;color:#116234}
.bookStatus.closed{background:#f1f1f1;color:#555}
.bookActionBox{margin-top:10px;border:1px solid #d8e7de;border-radius:14px;padding:10px;background:#fff}
.bookActionBox summary{cursor:pointer;font-weight:900}
@media (prefers-color-scheme:dark){
  .diaryBookHistoryBox{background:#0e1b12;border-color:#244c31}
  .bookHistoryItem,.bookActionBox{background:#151515;border-color:#333}
  .bookHistoryItem small{color:#aaa}
}

.bookHistoryItem b{
  font-weight:900;
}
.bookHistoryItem strong{
  margin-bottom:5px;
}

/* Calculation history + refresh button update */
.calculationHistoryBox{
  margin:14px 0;
  padding:12px;
  border:1px solid #d7e8df;
  border-radius:16px;
  background:#f7fcf9;
}
.refreshBtn{
  grid-column:1!important;
  justify-self:start!important;
  margin-left:70px!important;
  height:34px!important;
  width:38px!important;
  min-width:38px!important;
  padding:0!important;
  border:0!important;
  border-radius:12px!important;
  background:rgba(255,255,255,.14)!important;
  color:#fff!important;
  font-size:17px!important;
  font-weight:500!important;
  line-height:1!important;
  touch-action:manipulation!important;
}
.findBtn + .refreshBtn{
  margin-left:72px!important;
}
@media (max-width:420px){
  .refreshBtn{
    margin-left:62px!important;
    width:34px!important;
    min-width:34px!important;
    font-size:16px!important;
  }
}
@media (prefers-color-scheme:dark){
  .calculationHistoryBox{
    background:#0e1b12;
    border-color:#244c31;
  }
}

/* Header tight alignment fix: Refresh directly after Find */
.titleRow{
  display:grid!important;
  grid-template-columns:auto auto 1fr auto!important;
  align-items:center!important;
  column-gap:3px!important;
  padding:8px 14px 4px!important;
  min-height:44px!important;
}
.findBtn{
  grid-column:1!important;
  justify-self:start!important;
  align-self:center!important;
  margin:0!important;
  height:34px!important;
  min-width:66px!important;
  padding:0 9px!important;
  border-radius:14px!important;
  font-size:15px!important;
  font-weight:500!important;
  line-height:34px!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
}
.refreshBtn{
  grid-column:2!important;
  justify-self:start!important;
  align-self:center!important;
  margin:0 0 0 2px!important;
  width:36px!important;
  min-width:36px!important;
  height:34px!important;
  padding:0!important;
  border-radius:14px!important;
  font-size:17px!important;
  font-weight:500!important;
  line-height:34px!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
}
.findBtn + .refreshBtn{
  margin-left:2px!important;
}
.titleRow h1,
#screenTitle{
  grid-column:3!important;
  justify-self:center!important;
  align-self:center!important;
  text-align:center!important;
  margin:0!important;
  padding:0!important;
  font-size:21px!important;
  line-height:34px!important;
  white-space:nowrap!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  transform:none!important;
}
.dateNav{
  grid-column:4!important;
  justify-self:end!important;
  align-self:center!important;
  width:100px!important;
  min-width:100px!important;
  height:38px!important;
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
  gap:0!important;
  border-radius:20px!important;
  overflow:hidden!important;
}
.dateNav button{
  height:38px!important;
  min-width:50px!important;
  flex:1 1 50%!important;
  padding:0!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  font-size:30px!important;
  line-height:1!important;
}
.dateRow{
  padding-top:2px!important;
}
@media (max-width:420px){
  .titleRow{
    grid-template-columns:auto auto minmax(72px,1fr) auto!important;
    column-gap:2px!important;
    padding-left:10px!important;
    padding-right:10px!important;
  }
  .findBtn{
    min-width:58px!important;
    height:32px!important;
    padding:0 7px!important;
    font-size:14px!important;
    line-height:32px!important;
  }
  .refreshBtn{
    width:32px!important;
    min-width:32px!important;
    height:32px!important;
    margin-left:1px!important;
    font-size:16px!important;
    line-height:32px!important;
  }
  .findBtn + .refreshBtn{
    margin-left:1px!important;
  }
  .titleRow h1,
  #screenTitle{
    font-size:19px!important;
    line-height:32px!important;
    transform:none!important;
  }
  .dateNav{
    width:88px!important;
    min-width:88px!important;
    height:36px!important;
  }
  .dateNav button{
    min-width:44px!important;
    height:36px!important;
    font-size:28px!important;
  }
}
@media (max-width:360px){
  .findBtn{
    min-width:52px!important;
    font-size:13px!important;
    padding:0 5px!important;
  }
  .refreshBtn{
    width:30px!important;
    min-width:30px!important;
  }
  .titleRow h1,
  #screenTitle{
    font-size:18px!important;
  }
  .dateNav{
    width:82px!important;
    min-width:82px!important;
  }
  .dateNav button{
    min-width:41px!important;
  }
}

/* N/D details-not-required column + stable refresh table layout */
#changeDetailsEditor table,
#changeDetailsEditor .changeTable,
.changeTable{
  min-width:980px!important;
  width:980px!important;
  table-layout:fixed!important;
}
.changeTable th:nth-child(1), .changeTable td:nth-child(1){width:44px!important;min-width:44px!important}
.changeTable th:nth-child(2), .changeTable td:nth-child(2){width:64px!important;min-width:64px!important}
.changeTable th:nth-child(3), .changeTable td:nth-child(3){width:70px!important;min-width:70px!important}
.changeTable th:nth-child(4), .changeTable td:nth-child(4){width:112px!important;min-width:112px!important}
.changeTable th:nth-child(5), .changeTable td:nth-child(5){width:285px!important;min-width:285px!important}
.changeTable th:nth-child(6), .changeTable td:nth-child(6){width:155px!important;min-width:155px!important}
.changeTable th:nth-child(7), .changeTable td:nth-child(7){width:210px!important;min-width:210px!important}
.changeTable th:nth-child(1),
.changeTable td:nth-child(1){
  position:sticky!important;
  left:0!important;
  z-index:28!important;
  background:#f7f7f7!important;
  color:#111!important;
  box-shadow:2px 0 3px rgba(0,0,0,.08)!important;
}
.changeTable th:nth-child(2),
.changeTable td:nth-child(2){
  position:sticky!important;
  left:44px!important;
  z-index:27!important;
  background:#f7f7f7!important;
  color:#111!important;
  box-shadow:2px 0 3px rgba(0,0,0,.08)!important;
}
.changeTable th:nth-child(3),
.changeTable td:nth-child(3){
  position:sticky!important;
  left:108px!important;
  z-index:26!important;
  background:#f7f7f7!important;
  color:#111!important;
  box-shadow:2px 0 3px rgba(0,0,0,.08)!important;
}
.changeTable thead th:nth-child(1),
.changeTable thead th:nth-child(2),
.changeTable thead th:nth-child(3){
  z-index:35!important;
  background:#ececec!important;
}
.ndCell{
  text-align:center!important;
  padding:4px!important;
}
.ndCheck{
  width:19px!important;
  height:19px!important;
  accent-color:#1f6f43;
}
.activityCell,.timeCell{
  font-weight:900!important;
  font-size:13px!important;
}
.detailsLockedRow input[disabled],
.detailsLockedRow button[disabled]{
  opacity:.55!important;
  background:#f0f0f0!important;
  color:#777!important;
  -webkit-text-fill-color:#777!important;
}
.detailsLockedRow .locBtn{
  display:none!important;
}
.detailsLockedRow .locPickerWrap input{
  width:260px!important;
  min-width:260px!important;
}
@media (prefers-color-scheme:dark){
  .changeTable th:nth-child(1),
  .changeTable td:nth-child(1),
  .changeTable th:nth-child(2),
  .changeTable td:nth-child(2),
  .changeTable th:nth-child(3),
  .changeTable td:nth-child(3){
    background:#fff!important;
    color:#111!important;
  }
  .changeTable thead th:nth-child(1),
  .changeTable thead th:nth-child(2),
  .changeTable thead th:nth-child(3){
    background:#ececec!important;
    color:#111!important;
  }
}

/* Smart N/D short-break settings and continuation rows */
.shortBreakBox{margin:14px 0;padding:12px;border:1px solid #d7e8df;border-radius:16px;background:#f7fcf9}
.continuationBadge{display:inline-block;padding:6px 8px;border-radius:10px;background:#eef3ff;color:#274379;font-weight:900;font-size:12px;white-space:nowrap}
.shortBreakBadge{display:inline-block;margin-top:3px;font-size:11px;color:#516b5f;font-weight:800}
.auditActions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.auditActions button{min-height:34px;padding:6px 10px;border-radius:10px}
@media (prefers-color-scheme:dark){.shortBreakBox{background:#0e1b12;border-color:#244c31}.continuationBadge{background:#17233f;color:#c6d4ff}.shortBreakBadge{color:#aec8bc}}

/* Fatigue short-window repair */
.slot.bad{
  background:var(--red)!important;
  color:#fff!important;
  border-color:#8b0000!important;
}

/* Fatigue engine verification */
.slot.bad{
  background:var(--red)!important;
  color:#fff!important;
  border-color:#8b0000!important;
}

/* Required rest red block focus */
.slot.bad{
  background:var(--red)!important;
  color:#fff!important;
  border-color:#8b0000!important;
}

/* NHVR engine rebuild stats screen */
.statsMiniTableWrap{
  overflow-x:auto;
  margin-top:10px;
  border:1px solid #e0e0e0;
  border-radius:12px;
}
.statsMiniTable{
  width:100%;
  min-width:620px;
  border-collapse:collapse;
  font-size:13px;
}
.statsMiniTable th,
.statsMiniTable td{
  border-bottom:1px solid #eee;
  padding:7px 8px;
  text-align:left;
}
.statsMiniTable th{
  background:#f3f7f4;
  font-weight:900;
}
.canDriveCard.bad{
  border-color:#d22!important;
}
.canDriveCard.warn{
  border-color:#f0a000!important;
}
.statLimit.bad .fill{
  width:100%!important;
}
@media (prefers-color-scheme:dark){
  .statsMiniTableWrap{border-color:#333}
  .statsMiniTable th{background:#1d2b22}
  .statsMiniTable th,.statsMiniTable td{border-color:#333}
}

/* Change details blank-table repair */
#changeDetailsEditor{
  min-height:0!important;
  height:auto!important;
  max-height:none!important;
  overflow-x:auto!important;
  overflow-y:visible!important;
  display:block!important;
  visibility:visible!important;
  opacity:1!important;
  background:#fff!important;
}
#changeDetailsEditor:empty::before{
  content:"No work/rest change rows to show yet.";
  display:block;
  padding:16px;
  color:#555;
  font-weight:800;
}
.changeEmptyMessage{
  padding:16px;
  color:#555;
  font-weight:800;
  background:#fff;
  border-radius:14px;
}
.changeTable{
  display:table!important;
}
.changeTable tbody{
  display:table-row-group!important;
}
.changeTable tr{
  display:table-row!important;
}
.changeTable td,
.changeTable th{
  display:table-cell!important;
}

/* Smart major rest settings */
.smartMajorRestBox{
  margin:14px 0;
  padding:12px;
  border:1px solid #d7e8df;
  border-radius:16px;
  background:#f7fcf9;
}
@media (prefers-color-scheme:dark){
  .smartMajorRestBox{
    background:#0e1b12;
    border-color:#244c31;
  }
}

/* Stats 14-day accumulated hours table */
.stats14DayTable{
  margin:10px 0 14px;
  background:#fff;
  border:1px solid #e0e0e0;
  border-radius:14px;
  overflow:hidden;
}
.stats14Header{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  font-size:13px;
  background:#f4faf6;
  border-bottom:1px solid #e0e0e0;
}
.stats14Header span{
  color:#555;
  font-weight:700;
}
.stats14Scroll{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.stats14Table{
  border-collapse:collapse;
  width:100%;
  min-width:720px;
  font-size:12px;
  line-height:1.15;
}
.stats14Table th,
.stats14Table td{
  padding:6px 7px;
  border-bottom:1px solid #eee;
  text-align:right;
  white-space:nowrap;
}
.stats14Table th{
  background:#fafafa;
  font-weight:900;
}
.stats14Table .stick{
  position:sticky;
  left:0;
  text-align:left;
  background:#fff;
  z-index:2;
  box-shadow:1px 0 0 #eee;
}
.stats14Table th.stick{
  background:#fafafa;
  z-index:3;
}
.stats14Table .warnCell{
  color:#b00020;
  font-weight:900;
}
.stats14Note{
  padding:7px 10px 9px;
  font-size:11.5px;
  color:#555;
  background:#fcfcfc;
}
.stats14Empty{
  padding:10px;
  color:#555;
  font-weight:700;
}
@media (max-width: 520px){
  .stats14Table{
    min-width:690px;
    font-size:11.5px;
  }
  .stats14Table th,
  .stats14Table td{
    padding:5px 6px;
  }
}
@media (prefers-color-scheme:dark){
  .stats14DayTable{background:#111;border-color:#333}
  .stats14Header{background:#142016;border-color:#333}
  .stats14Header span,.stats14Note{color:#c8c8c8}
  .stats14Table th{background:#171717}
  .stats14Table .stick{background:#111;box-shadow:1px 0 0 #333}
  .stats14Table th.stick{background:#171717}
  .stats14Table th,.stats14Table td{border-color:#333}
  .stats14Note{background:#111}
}

/* App update backup flow */
.appUpdateBox{
  margin:12px 0;
  padding:12px;
  border:1px solid #d7e8df;
  border-radius:16px;
  background:#f7fcf9;
}
.appUpdateBox h3{
  margin-top:0;
}
.updateButtonRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.updateButtonRow button{
  flex:1 1 150px;
}
.appUpdatePanel{
  margin-top:10px;
  padding:10px;
  border:1px dashed #9bb9aa;
  border-radius:14px;
  background:#fff;
}
.appUpdatePanel h4{
  margin:0 0 6px;
}
#appUpdateReadyPanel{
  margin:10px 0;
  padding:10px;
  border-radius:12px;
  background:#eefaf2;
}
@media (prefers-color-scheme:dark){
  .appUpdateBox{
    background:#0e1b12;
    border-color:#244c31;
  }
  .appUpdatePanel{
    background:#111;
    border-color:#35543e;
  }
  #appUpdateReadyPanel{
    background:#142016;
  }
}

/* Home Screen PWA header-safe layout fix */
:root{
  --pwaHeaderBottom: 150px;
}
body.homeScreenPwa .topbar{
  top:0;
}
body.homeScreenPwa .alerts.hasAlerts{
  position:sticky;
  top:calc(var(--pwaHeaderBottom) + 4px);
  z-index:6;
  background:#fff;
  padding-top:6px;
  margin-top:0;
}
body.homeScreenPwa .auditFocusBox,
body.homeScreenPwa #diaryGrid,
body.homeScreenPwa #auditFixPanel,
body.homeScreenPwa #changeDetailsEditor,
body.homeScreenPwa .card{
  scroll-margin-top:calc(var(--pwaHeaderBottom) + 12px);
}
.legacyStatsHidden{
  display:none!important;
}
@media (prefers-color-scheme:dark){
  body.homeScreenPwa .alerts.hasAlerts{
    background:#111;
  }
}

/* Home Screen PWA content push-down fix */
:root{
  --pwaContentPushDown: 26px;
}
body.homeScreenPwa main{
  padding-top:var(--pwaContentPushDown);
}
body.homeScreenPwa #diaryScreen.screen.active,
body.homeScreenPwa #drivingScreen.screen.active,
body.homeScreenPwa #statsScreen.screen.active,
body.homeScreenPwa #graphScreen.screen.active,
body.homeScreenPwa #vehiclesScreen.screen.active,
body.homeScreenPwa #settingsScreen.screen.active{
  padding-top:0;
}
body.homeScreenPwa #alerts{
  margin-top:0;
}
body.homeScreenPwa .alerts .alert:first-child{
  margin-top:0;
}
body.homeScreenPwa .auditFocusBox,
body.homeScreenPwa #diaryGrid,
body.homeScreenPwa #auditFixPanel,
body.homeScreenPwa #changeDetailsEditor,
body.homeScreenPwa .card{
  scroll-margin-top:calc(var(--pwaHeaderBottom, 150px) + var(--pwaContentPushDown) + 16px);
}

/* Landscape compact mode */
@media (orientation: landscape) and (max-height: 520px){
  body.landscapeCompact{
    --landscapeTopGap: 6px;
    --landscapeNavHeight: 66px;
  }

  body.landscapeCompact .topbar{
    padding-top:calc(env(safe-area-inset-top, 0px) + 4px)!important;
    padding-bottom:6px!important;
    min-height:auto!important;
  }

  body.landscapeCompact .headerRow,
  body.landscapeCompact .topRow,
  body.landscapeCompact .navRow{
    min-height:36px!important;
  }

  body.landscapeCompact .title,
  body.landscapeCompact .screenTitle,
  body.landscapeCompact #screenTitle{
    font-size:22px!important;
    line-height:1.05!important;
  }

  body.landscapeCompact .dateLine,
  body.landscapeCompact #dateLabel,
  body.landscapeCompact #currentDateLabel{
    font-size:18px!important;
    line-height:1.1!important;
  }

  body.landscapeCompact .schemeLabel,
  body.landscapeCompact #schemeLabel{
    font-size:18px!important;
    line-height:1.1!important;
  }

  body.landscapeCompact .findBtn,
  body.landscapeCompact #findBtn,
  body.landscapeCompact .refreshBtn,
  body.landscapeCompact #refreshBtn{
    transform:scale(.88);
    transform-origin:left center;
  }

  body.landscapeCompact .prevNext,
  body.landscapeCompact .dateNav,
  body.landscapeCompact .navButtons{
    transform:scale(.9);
    transform-origin:right center;
  }

  body.landscapeCompact main{
    padding-bottom:calc(var(--landscapeNavHeight) + env(safe-area-inset-bottom, 0px) + 8px)!important;
  }

  body.landscapeCompact .bottomNav,
  body.landscapeCompact .bottom-nav,
  body.landscapeCompact #bottomNav,
  body.landscapeCompact nav.bottom{
    min-height:var(--landscapeNavHeight)!important;
    height:var(--landscapeNavHeight)!important;
    padding:6px 12px calc(env(safe-area-inset-bottom, 0px) + 5px)!important;
    border-radius:28px!important;
  }

  body.landscapeCompact .bottomNav button,
  body.landscapeCompact .bottom-nav button,
  body.landscapeCompact #bottomNav button,
  body.landscapeCompact nav.bottom button{
    font-size:11px!important;
    padding:3px 6px!important;
    min-height:48px!important;
  }

  body.landscapeCompact .bottomNav .icon,
  body.landscapeCompact .bottom-nav .icon,
  body.landscapeCompact #bottomNav .icon,
  body.landscapeCompact nav.bottom .icon{
    font-size:20px!important;
    line-height:1!important;
  }

  body.landscapeCompact .hint,
  body.landscapeCompact .instruction,
  body.landscapeCompact .helpBox{
    font-size:13px!important;
    padding-top:6px!important;
    padding-bottom:6px!important;
  }

  body.landscapeCompact .card{
    margin-top:8px!important;
    margin-bottom:8px!important;
    padding-top:10px!important;
    padding-bottom:10px!important;
  }

  body.landscapeCompact .stats14Table{
    font-size:11px!important;
  }

  body.landscapeCompact .stats14Table th,
  body.landscapeCompact .stats14Table td{
    padding:4px 5px!important;
  }
}

/* Clean final engine test system */
.engineTestBox{
  margin:12px 0;
  padding:12px;
  border:1px solid #d7e8df;
  border-radius:16px;
  background:#f7fcf9;
}
.engineTestBox h3{
  margin-top:0;
}
.engineTestReport{
  margin-top:8px;
}
.engineTestSummary{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:12px;
  font-size:13px;
  margin-bottom:8px;
}
.engineTestSummary.pass{
  background:#eaf8ee;
  color:#0f5b2b;
}
.engineTestSummary.fail{
  background:#fff0f0;
  color:#9d1c1c;
}
.engineTestScroll{
  max-height:280px;
  overflow:auto;
  border:1px solid #e5e5e5;
  border-radius:12px;
  background:#fff;
}
.engineTestScroll table{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
  font-size:12px;
}
.engineTestScroll th,
.engineTestScroll td{
  padding:6px 7px;
  border-bottom:1px solid #eee;
  text-align:left;
  vertical-align:top;
}
.engineTestScroll th{
  position:sticky;
  top:0;
  background:#fafafa;
  z-index:1;
}
.engineTestScroll tr.pass td:first-child{
  color:#0f6a32;
  font-weight:900;
}
.engineTestScroll tr.fail td:first-child{
  color:#b00020;
  font-weight:900;
}
@media (prefers-color-scheme:dark){
  .engineTestBox{
    background:#0e1b12;
    border-color:#244c31;
  }
  .engineTestSummary.pass{
    background:#142016;
    color:#9be6a8;
  }
  .engineTestSummary.fail{
    background:#2a1111;
    color:#ffb3b3;
  }
  .engineTestScroll{
    background:#111;
    border-color:#333;
  }
  .engineTestScroll th{
    background:#171717;
  }
  .engineTestScroll th,
  .engineTestScroll td{
    border-color:#333;
  }
}

/* Rest-default / stats readability fix */
@media (prefers-color-scheme:dark){
  .stats14DayTable,
  .stats14Header strong,
  .stats14Table,
  .stats14Table th,
  .stats14Table td{
    color:#f2f2f2;
  }
  .stats14Table .stick{
    color:#f2f2f2;
  }
  .stats14Empty{
    color:#c8c8c8;
  }
}


/* Fast due-break planner update */
.duePlannerIntro,.duePlannerNote{font-size:13px;color:#555;background:#f7f9fb;border:1px solid #e6edf3;border-radius:12px;padding:9px 10px;margin:2px 0 6px}
.duePlannerRow{border:1px solid #eee;border-radius:12px;padding:10px 11px;background:#fff;border-bottom:1px solid #eee}
.duePlannerRow span{font-weight:800;color:#333;max-width:58%;line-height:1.25}
.duePlannerRow small{font-weight:500;text-align:right;line-height:1.25}
.duePlannerRow.dueOk{border-left:5px solid #37a169;background:#f0fff4}
.duePlannerRow.dueWarn{border-left:5px solid #d69e2e;background:#fffaf0}
.duePlannerRow.dueBad{border-left:5px solid #e53e3e;background:#fff5f5}
@media (prefers-color-scheme: dark){
  .duePlannerIntro,.duePlannerNote{background:#101820;border-color:#263746;color:#cbd5e1}
  .duePlannerRow{background:#111;border-color:#333}
  .duePlannerRow span{color:#f2f2f2}
  .duePlannerRow small{color:#c8c8c8}
  .duePlannerRow.dueOk{background:#0f1b13}
  .duePlannerRow.dueWarn{background:#241b09}
  .duePlannerRow.dueBad{background:#250f0f}
}

/* Final stable performance/support styles */
.locationPickerOff .locBtn{display:none!important}
.bookHistoryActions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
button.tiny{font-size:12px!important;padding:7px 10px!important;min-height:34px!important;border-radius:10px!important}
.startupWarn{margin:10px 12px!important}
