*{box-sizing:border-box}
body{margin:0;background:#f3f4f6;font-family:Arial,"Noto Sans Khmer",sans-serif;color:#111}
.app{max-width:1200px;margin:auto;padding:20px}
header h1{margin:0 0 6px} header p{margin:0 0 18px;color:#667085}
.toolbar{background:#fff;border:1px solid #ddd;border-radius:14px;padding:12px;display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:16px}
button,.upload-btn,select{border:0;border-radius:9px;padding:10px 14px;background:#111827;color:#fff;font-weight:700;cursor:pointer}
button:disabled{opacity:.4;cursor:not-allowed}.light,select{background:#fff;color:#111;border:1px solid #ccc}
.upload-btn input{display:none}
.paste-zone{flex:1;min-width:280px;border:2px dashed #98a2b3;border-radius:10px;padding:8px 12px;text-align:center;outline:none}
.paste-zone small{display:block;color:#667085;margin-top:3px}
.layout{display:grid;grid-template-columns:1.05fr .95fr;gap:16px;align-items:start}
.panel{background:#fff;border:1px solid #e5e7eb;border-radius:14px;padding:14px}
.preview-box{height:360px;border:1px dashed #bbb;border-radius:10px;display:flex;align-items:center;justify-content:center;overflow:hidden;background:#fafafa}
.preview-box img{display:none;max-width:100%;max-height:100%;object-fit:contain}
.progress{display:flex;gap:8px;align-items:center;margin-top:10px}.hidden{display:none!important}
.track{height:8px;background:#eee;border-radius:99px;overflow:hidden;flex:1}.track div{height:100%;width:0;background:#111827}
.select-row{display:flex;gap:10px;align-items:center;margin:14px 0}
.field-group{border-top:1px solid #eee;padding:10px 0}.field-group label{font-weight:700;font-size:13px;display:block;margin-bottom:6px}
.num-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px}.num-grid.one{grid-template-columns:1fr}.num-grid.three{grid-template-columns:repeat(3,1fr)}
.num-input{width:100%;padding:8px;border:1px solid #ccc;border-radius:7px;font-size:18px;font-weight:700;text-align:center}
.full{width:100%;margin-top:10px}.result-head{display:flex;justify-content:space-between;align-items:center}

.ticket{width:270px;margin:0 auto;border:2px solid #222;background:#fff;font-family:"Times New Roman","Khmer OS Battambang",serif}
.top-khmer{text-align:center;color:#b50000;font-size:17px;font-weight:800;border-bottom:1px solid #555;padding:3px 2px}
.date-line{display:grid;grid-template-columns:72px 1fr;border-bottom:1px solid #555}
.date-label{color:#007dbb;font-family:Arial,sans-serif;font-weight:800;font-size:16px;padding:3px 6px}
.date-value{color:#007dbb;font-family:Arial,sans-serif;font-weight:800;font-size:17px;text-align:center;padding:3px}
.time-line{text-align:center;color:#d10000;font-family:Arial,sans-serif;font-size:14px;font-weight:800;border-bottom:1px solid #555;padding:2px}
.r{display:grid;grid-template-columns:62px 1fr;border-bottom:1px solid #555;min-height:38px}
.left{border-right:1px solid #555;display:flex;justify-content:center;align-items:center;font-size:15px;font-weight:700}
.right{display:flex;justify-content:center;align-items:center;font-size:25px;font-weight:800;line-height:.9;padding:1px 5px}
.stacked{flex-direction:column}.big{font-size:31px;line-height:.82}.row-a{min-height:64px}.big-blue{font-family:Arial,sans-serif;color:#018ac6;font-size:47px;font-weight:900}
.tall7{min-height:150px}.tall7 .right{font-size:24px;line-height:.88}
.mini-row{display:grid;grid-template-columns:61px 1fr;border-bottom:1px solid #555;min-height:28px}
.mini-row:last-child{border-bottom:0}.mini-label{border-right:1px solid #555;text-align:center;font-family:Arial,sans-serif;font-weight:900;font-size:25px;line-height:27px}
.blue{color:#018ac6}.mini-value{text-align:center;font-size:28px;font-weight:900;line-height:27px;letter-spacing:1px}
.note{font-size:12px;color:#667085;text-align:center}

@media(max-width:850px){.layout{grid-template-columns:1fr}.ticket{width:270px}}

.mode-select{min-width:180px}
.night-fields{border-top:1px solid #eee;margin-top:12px;padding-top:12px}
.night-fields h3{margin:0 0 10px}
.night-fields label{display:block;font-size:13px;font-weight:800;margin:8px 0 5px}
.night-input-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.night-a-box{
  display:grid;
  grid-template-columns:62px 1fr;
  border-bottom:1px solid #555;
  min-height:92px;
}
.night-a-label{
  border-right:1px solid #555;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:Arial,sans-serif;
  color:#018ac6;
  font-size:50px;
  font-weight:900;
}
.night-a-values{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  grid-template-rows:auto auto;
  align-items:center;
  padding:8px 10px;
  row-gap:7px;
  font-weight:900;
  font-variant-numeric:tabular-nums;
}
.night-a-row{
  display:contents;
}
.night-a-row3 span{
  font-size:27px;
  text-align:center;
  line-height:1;
}
.night-a-row3 span:nth-child(1){grid-column:1;grid-row:1}
.night-a-row3 span:nth-child(2){grid-column:2;grid-row:1}
.night-a-row3 span:nth-child(3){grid-column:3;grid-row:1}
.night-a-row4 span{
  font-size:25px;
  text-align:center;
  line-height:1;
}
.night-a-row4 span:nth-child(1){grid-column:1;grid-row:2}
.night-a-row4 span:nth-child(2){grid-column:2;grid-row:2}
.night-a-row4 span:nth-child(3){grid-column:3;grid-row:2}
.night-a-row4 span:nth-child(4){grid-column:4;grid-row:2}
.night-a-row span{
  display:block;
  min-width:0;
  white-space:nowrap;
}

.night-grid-3{grid-template-columns:repeat(3,1fr)}
.night-grid-4{grid-template-columns:repeat(4,1fr)}
.night-list-inputs{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;max-height:360px;overflow:auto}
.night-list-input-row{display:grid;grid-template-columns:32px 1fr;gap:5px;align-items:center}
.night-list-input-row span{text-align:center;font-weight:800}

.night-output{border-bottom:1px solid #555}
.night-a-table{display:grid;grid-template-columns:42px 1fr;border-bottom:1px solid #555}
.night-a-letter{border-right:1px solid #555;color:#018ac6;font-family:Arial,sans-serif;font-size:46px;font-weight:900;display:flex;align-items:center;justify-content:center}
.night-a-pairs>div{display:grid;grid-template-columns:62px 1fr;min-height:28px;align-items:center;text-align:center;font-size:24px;line-height:1}
.night-a-pairs b{font-weight:900}
.night-number-list{width:100%}
.night-list-row{display:grid;grid-template-columns:32px 1fr;min-height:24px;border-bottom:1px solid #aaa}
.night-list-index{display:flex;align-items:center;justify-content:center;border-right:1px solid #777;font-size:15px}
.night-list-value{display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:900;line-height:1}

.night-hint{font-size:12px;color:#667085}
.night-exact-card{
  width:245px;
  margin:0 auto;
  background:#fff;
  border:1px solid #333;
  font-family:"Times New Roman","Noto Sans Khmer",serif;
}
.night-title{
  height:31px;display:flex;align-items:center;justify-content:center;
  color:#b00000;font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-size:16px;font-weight:900;border-bottom:1px solid #444;
}
.night-datebar{
  height:32px;display:grid;grid-template-columns:1fr 1fr;
  align-items:center;text-align:center;border-bottom:1px solid #444;
  font-family:Arial,sans-serif;font-size:16px;font-weight:900;
}
.night-datebar span:first-child{color:#d00000;border-right:1px solid #aaa}
.night-datebar span:last-child{color:#087fb7}
.night-exact-a{
  display:grid;grid-template-columns:42px 1fr;
  border-bottom:1px solid #333;
}
.night-exact-letter{
  border-right:1px solid #333;display:flex;align-items:center;justify-content:center;
  color:#0788c4;font-family:Arial,sans-serif;font-size:39px;font-weight:900;
}
.night-exact-a-values>div{
  display:grid;grid-template-columns:1fr 1.45fr;
  min-height:31px;align-items:center;text-align:center;
  font-size:27px;font-weight:900;line-height:1;
}
.night-exact-bcd{
  display:grid;grid-template-columns:42px 64px 1fr;
  min-height:31px;border-bottom:1px solid #333;
  align-items:center;text-align:center;font-size:27px;font-weight:900;line-height:1;
}
.night-exact-bcd>div:first-child{
  color:#0788c4;font-family:Arial,sans-serif;border-right:1px solid #333;
}
.night-exact-bcd>div:nth-child(2){border-right:1px solid #333}
.night-exact-list-row{
  display:grid;grid-template-columns:42px 64px 1fr;
  min-height:24px;border-bottom:1px solid #aaa;
  align-items:center;text-align:center;line-height:1;
}
.night-exact-list-row:last-child{border-bottom:0}
.night-exact-list-row .idx{border-right:1px solid #aaa;font-size:15px}
.night-exact-list-row .blank{border-right:1px solid #aaa;height:100%}
.night-exact-list-row .val{font-size:22px;font-weight:900}

/* ===== V14 exact Night output layout ===== */
.night-exact-card{
  width:245px !important;
  margin:0 auto;
  background:#fff;
  border:1px solid #333;
  font-family:"Times New Roman","Noto Sans Khmer",serif;
}
.night-title{
  height:31px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#b00000;
  font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-size:16px;
  font-weight:900;
  border-bottom:1px solid #444;
}
.night-datebar{
  height:32px;
  display:grid;
  grid-template-columns:1fr 1fr;
  align-items:center;
  text-align:center;
  border-bottom:1px solid #444;
  font-family:Arial,sans-serif;
  font-size:16px;
  font-weight:900;
}
.night-datebar span:first-child{
  color:#d00000;
  border-right:1px solid #aaa;
}
.night-datebar span:last-child{
  color:#087fb7;
}
.night-grid-row{
  display:grid;
  grid-template-columns:42px 62px 1fr;
  align-items:center;
  min-height:30px;
  border-bottom:1px solid #666;
  text-align:center;
}
.night-col-label{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border-right:1px solid #777;
  font-family:Arial,sans-serif;
}
.night-col-mid{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border-right:1px solid #777;
  font-size:26px;
  font-weight:900;
  line-height:1;
}
.night-col-right{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:26px;
  font-weight:900;
  line-height:1;
}
.night-a-row{
  min-height:31px;
}
.night-big-a{
  color:#0788c4;
  font-size:40px;
  font-weight:900;
}
.night-bcd-label{
  color:#0788c4;
  font-size:27px;
  font-weight:900;
}
.night-bcd-row{
  min-height:30px;
}
.night-exact-list{
  width:100%;
}
.night-exact-list-row{
  display:grid;
  grid-template-columns:42px 62px 1fr;
  min-height:24px;
  align-items:center;
  text-align:center;
  border-bottom:1px solid #aaa;
  line-height:1;
}
.night-exact-list-row:last-child{
  border-bottom:0;
}
.night-exact-list-row .idx{
  grid-column:2;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border-left:1px solid #777;
  border-right:1px solid #777;
  font-size:15px;
}
.night-exact-list-row .blank{
  display:none;
}
.night-exact-list-row .val{
  grid-column:3;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  font-weight:900;
}

.sat-info{
  margin:8px 0 10px;
  padding:8px 10px;
  border:1px solid #d0d5dd;
  border-radius:8px;
  background:#f9fafb;
  font-size:12px;
  color:#475467;
}

#scheduleInfo{
  display:block;
  margin:8px 0 10px;
  font-weight:700;
}

.compact-abcdh-card{
  width:245px;margin:0 auto;background:#fff;border:1px solid #333;
  font-family:"Times New Roman",serif;
}
.compact-title{
  text-align:center;font-weight:900;font-size:18px;padding:7px;
  border-bottom:1px solid #333;color:#a00000;
}
.compact-row{
  display:grid;grid-template-columns:52px 1fr;min-height:42px;
  border-bottom:1px solid #555;align-items:center;text-align:center;
  font-size:28px;font-weight:900;
}
.compact-row:last-child{border-bottom:0}
.compact-row>div:first-child{
  height:100%;display:flex;align-items:center;justify-content:center;
  border-right:1px solid #555;color:#0788c4;font-family:Arial,sans-serif;
}

.compact-title{
  white-space:nowrap;
  font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-size:15px !important;
  padding:7px 4px !important;
}

/* ===== V23 logo + selected-time title on every result ===== */
.result-brand-header{
  min-height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:3px 5px;
  border-bottom:1px solid #444;
  background:#fff;
  box-sizing:border-box;
}
.result-logo{
  width:38px;
  height:38px;
  object-fit:contain;
  flex:0 0 auto;
}
.result-brand-header .ticket-title,
.result-brand-header .night-title,
.result-brand-header .compact-title{
  border:0 !important;
  padding:0 !important;
  min-height:0 !important;
  height:auto !important;
  display:block !important;
  color:#b00000;
  font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-size:13px !important;
  font-weight:900;
  line-height:1.25;
  text-align:center;
  white-space:nowrap;
}
.compact-brand-header{
  border-bottom:1px solid #333;
}

/* ===== V24: same logo/header on every result time ===== */
.day-brand-header,
.night-brand-header,
.compact-brand-header{
  min-height:46px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:6px !important;
  padding:4px 6px !important;
  background:#fff !important;
  border-bottom:1px solid #444 !important;
}
.day-brand-header .result-logo,
.night-brand-header .result-logo,
.compact-brand-header .result-logo{
  width:38px !important;
  height:38px !important;
  object-fit:contain !important;
  flex:0 0 38px !important;
}
.day-brand-header .top-khmer,
.night-brand-header .night-title,
.compact-brand-header .compact-title{
  border:0 !important;
  padding:0 !important;
  margin:0 !important;
  height:auto !important;
  min-height:0 !important;
  display:block !important;
  background:transparent !important;
  color:#b00000 !important;
  font-family:"Noto Sans Khmer",Arial,sans-serif !important;
  font-size:13px !important;
  font-weight:900 !important;
  line-height:1.25 !important;
  text-align:center !important;
  text-decoration:none !important;
  white-space:nowrap !important;
}
#dayTimeLine{
  text-align:center;
  color:#d10000;
  font-family:Arial,sans-serif;
  font-size:14px;
  font-weight:800;
  border-bottom:1px solid #555;
  padding:3px;
}

/* ===== V25 DATE row on every result format ===== */
.all-time-date-row{
  min-height:28px;
  display:grid;
  grid-template-columns:1fr 1.35fr;
  align-items:center;
  border-bottom:1px solid #555;
  background:#fff;
  font-family:Arial,sans-serif;
  font-size:16px;
  font-weight:900;
}
.all-time-date-row span:first-child{
  padding-left:7px;
  color:#087fb7;
  text-align:left;
}
.all-time-date-row span:last-child{
  color:#087fb7;
  text-align:center;
}

/* ===== V26 Cambodia date + unified header ===== */
.date-control{
  display:flex;
  align-items:center;
  gap:7px;
  flex-wrap:wrap;
}
.date-control label{
  font-weight:800;
  font-size:13px;
}
.date-control input[type="date"]{
  border:1px solid #d0d5dd;
  border-radius:9px;
  padding:9px 10px;
  font-weight:700;
  background:#fff;
}
.dynamic-result-date{
  cursor:text;
  outline:none;
}
.dynamic-result-date:focus{
  background:#fff8d8;
}

/* ===== V27: 4:30 DATE exactly matches compact-time DATE ===== */
.ticket .date-row,
.ticket .date-line,
.ticket .datebar,
.ticket .date-bar{
  min-height:28px !important;
  align-items:center !important;
  font-family:Arial,sans-serif !important;
  font-size:16px !important;
  font-weight:900 !important;
  line-height:1 !important;
}

.ticket .date-row *,
.ticket .date-line *,
.ticket .datebar *,
.ticket .date-bar *{
  font-family:Arial,sans-serif !important;
  font-size:16px !important;
  font-weight:900 !important;
  line-height:1 !important;
}

.ticket .dynamic-result-date,
.ticket .full-day-date-value,
.ticket #dateText,
.ticket #dateVal{
  color:#087fb7 !important;
  font-family:Arial,sans-serif !important;
  font-size:16px !important;
  font-weight:900 !important;
  line-height:1 !important;
  text-align:center !important;
}

/* DATE label also matches the 1:30 compact format */
.ticket .date-row > :first-child,
.ticket .date-line > :first-child,
.ticket .datebar > :first-child,
.ticket .date-bar > :first-child{
  color:#087fb7 !important;
  font-family:Arial,sans-serif !important;
  font-size:16px !important;
  font-weight:900 !important;
}

/* ===== V28: remove logos from every result ===== */
.result-logo{display:none !important}
.result-brand-header{
  min-height:32px !important;
  padding:4px 6px !important;
  gap:0 !important;
}
.result-brand-header .ticket-title,
.result-brand-header .night-title,
.result-brand-header .compact-title,
.result-brand-header .top-khmer{
  font-size:14px !important;
}

/* ===== Evening 6:50 / 7:30 / 8:30 style like reference picture ===== */
.evening-card{
  width:210px;
  margin:0 auto;
  background:#fff;
  border:1px solid #333;
  font-family:"Times New Roman","Noto Sans Khmer",serif;
}
.evening-title{
  color:#b00000;
  text-align:center;
  font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-weight:900;
  font-size:15px;
  min-height:28px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-bottom:1px solid #444;
}
.evening-date-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  min-height:28px;
  align-items:center;
  text-align:center;
  border-bottom:1px solid #444;
  font-family:Arial,sans-serif;
  font-weight:900;
  font-size:15px;
}
.evening-date-row span:first-child{
  color:#d00000;
  border-right:1px solid #aaa;
}
.evening-date-row span:last-child{
  color:#087fb7;
}
.evening-a-block{
  display:grid;
  grid-template-columns:40px 1fr;
  border-bottom:1px solid #444;
}
.evening-letter{
  color:#0788c4;
  font-family:Arial,sans-serif;
  font-size:42px;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  border-right:1px solid #444;
}
.evening-a-values > div{
  display:grid;
  grid-template-columns:58px 1fr;
  min-height:28px;
  align-items:center;
  text-align:center;
  font-size:25px;
  font-weight:900;
  line-height:1;
}
.evening-bcd{
  display:grid;
  grid-template-columns:40px 58px 1fr;
  min-height:29px;
  align-items:center;
  text-align:center;
  border-bottom:1px solid #444;
  font-size:25px;
  font-weight:900;
  line-height:1;
}
.evening-bcd:last-child{border-bottom:0}
.evening-bcd>div:first-child{
  color:#0788c4;
  font-family:Arial,sans-serif;
  border-right:1px solid #444;
}
.evening-bcd>div:nth-child(2){
  border-right:1px solid #444;
}

.abcdh-editor{margin:12px 0;padding:12px;border:1px solid #d0d5dd;border-radius:10px;background:#fff}
.editor-title{font-weight:800;margin-bottom:10px}
.editor-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.editor-grid label{font-size:12px;font-weight:700}
.editor-grid input{display:block;width:100%;box-sizing:border-box;margin-top:4px;padding:9px;border:1px solid #bbb;border-radius:7px;font-size:18px;font-weight:800}
#applyABCDH{margin-top:10px;width:100%;padding:10px;font-weight:800}
@media(max-width:520px){.editor-grid{grid-template-columns:1fr}}

.abcdh-formula-note{
  font-size:11px;
  text-align:center;
  padding:5px 4px;
  border-bottom:1px solid #ddd;
  color:#475467;
  font-family:Arial,sans-serif;
}

/* ===== V33 clean ABCDH result ===== */
#compactABCDHCard .abcdh-formula-note{display:none !important}
#compactABCDHCard{
  overflow:hidden;
}

.manual-result-preview{margin:12px auto;max-width:310px}
.manual-result-preview table{width:100%;border-collapse:collapse;background:#fff}
.manual-result-preview th,.manual-result-preview td{border:1px solid #333;padding:7px;text-align:center}
.manual-result-preview th{font-size:22px;color:#0784bd;width:55px}
.manual-result-preview td{font-size:22px;font-weight:800}

.editor-subtitle{font-weight:800;font-size:12px;margin:8px 0 4px}
.editor-grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.editor-grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.single-field{display:block;margin-top:10px;font-size:12px;font-weight:700}
.single-field input{display:block;width:100%;box-sizing:border-box;margin-top:4px;padding:9px;border:1px solid #bbb;border-radius:7px;font-size:18px;font-weight:800}

/* ===== V40: ONLY 4:30 is changed; all other times remain V36 ===== */
#only430Card{
  width:245px;
  margin:0 auto;
}
#only430Card .compact-title{
  text-align:center;
  color:#b00000;
  font-family:"Noto Sans Khmer",Arial,sans-serif;
  font-weight:900;
  font-size:14px;
  padding:7px 4px;
  border-bottom:1px solid #333;
}
#only430Card .compact-row{
  display:grid;
  grid-template-columns:52px 1fr;
  min-height:42px;
  border-bottom:1px solid #555;
  align-items:center;
  text-align:center;
  font-size:28px;
  font-weight:900;
}
#only430Card .compact-row:last-child{border-bottom:0}
#only430Card .compact-row>div:first-child{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border-right:1px solid #555;
  color:#0788c4;
  font-family:Arial,sans-serif;
}


/* 1:30 PM exact full result card */
.time130-card{width:330px;margin:0 auto;background:#fff;border:2px solid #111;font-family:"Times New Roman",serif;color:#111}
.time130-kh{text-align:center;color:#8d0000;font-family:"Noto Sans Khmer",Arial,sans-serif;font-size:19px;font-weight:900;padding:5px 2px 2px;text-decoration:underline}
.time130-name{text-align:center;font-size:31px;font-weight:900;line-height:1.05;border-top:1px solid #111;padding-top:3px}
.time130-date{text-align:center;font-size:25px;font-weight:900;border-bottom:2px solid #111;padding:1px 2px 4px;white-space:nowrap}
.t130-row{display:grid;grid-template-columns:105px 1fr;border-bottom:2px solid #111;min-height:58px}
.t130-label{border-right:2px solid #111;display:flex;align-items:center;justify-content:center;text-align:center;font-size:27px;font-weight:900;line-height:.9;gap:8px}
.t130-label small{font-size:17px;font-weight:700}
.t130-val{display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:42px;font-weight:900;line-height:.92}
.t130-big{font-size:56px;line-height:.9}
.t130-g6{min-height:145px}.t130-g4{min-height:315px}
.t130-mini{display:grid;grid-template-columns:105px 1fr;min-height:58px;border-bottom:1px dotted #444;align-items:center;text-align:center}
.t130-mini:last-child{border-bottom:0}.t130-mini b{height:100%;display:flex;align-items:center;justify-content:center;border-right:2px solid #111;font-size:42px}.t130-mini span{font-size:43px;font-weight:900;white-space:pre}

/* 1:30 PM: DATE header matches the 4:30 PM style */
.time130-date-row{
  grid-template-columns:105px 1fr;
  min-height:32px;
  border-bottom:2px solid #111;
  font-family:Arial,sans-serif;
  font-size:17px;
  font-weight:900;
}
.time130-date-row span:first-child{padding-left:8px;color:#007dbb;text-align:left;}
.time130-date-row span:last-child{color:#007dbb;text-align:center;}


/* 1:30 PM: Giải 8 + Giải 7 are both A, so show one A block like 4:30 */
.t130-a-row{min-height:116px;}
.t130-a-label{color:#0788c4;font-family:Arial,sans-serif;font-size:48px;font-weight:900;}
.t130-a-values{font-size:50px;line-height:1.02;gap:4px;}


/* ===== 1:30 PM easy editor ===== */
.t130-editor-title{
  margin:12px 0 4px;
  padding:9px 10px;
  border-radius:8px;
  background:#f3f4f6;
  font-weight:900;
  font-size:14px;
}
.t130-editor-group{
  display:grid;
  grid-template-columns:54px 1fr;
  gap:10px;
  align-items:start;
  padding:10px 0;
}
.t130-editor-group>label{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  margin:0;
  font-family:Arial,sans-serif;
  font-size:22px !important;
  font-weight:900 !important;
  color:#0788c4;
}
.t130-editor-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:7px;
}
.t130-editor-grid.one{grid-template-columns:1fr}
.t130-editor-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}
.t130-editor-group:nth-of-type(5) .t130-editor-grid{
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.t130-editor-note{
  margin:8px 0 12px;
  padding:8px 10px;
  background:#f9fafb;
  border:1px solid #e5e7eb;
  border-radius:8px;
  font-size:12px;
  color:#475467;
}
.time130-card .t130-g4{min-height:350px}

/* V45: daytime full-result A label uses the same style as DB */
.t130-a-label{
  color:#111;
  font-family:"Times New Roman",serif;
  font-size:42px;
  font-weight:900;
}


/* ===== Shared daytime result: A same color as DB ===== */
.time130-card .time130-a-label {
  color: #0788c4 !important;
}


/* Daytime A label — same blue as 4:30 A */
.time130-card .time130-a-label,
.time130-card .time130-a,
.time130-card .t130-a,
.time130-card .t130-a-label {
  color: #0788c4 !important;
}


/* A / DB / C / D / F / I — same blue color */
.time130-card .time130-a-label,
.time130-card .t130-mini b {
  color: #0788c4 !important;
}

/* Daytime full result: show all 11 values in section 4 */
.time130-card .t130-g4 {
  min-height: 440px !important;
}

/* Shared daytime result: enough height for all 11 section-4 values */
.time130-card .t130-g4 { min-height: 440px !important; }

/* Daytime result: section 4 has 9 values; final two values are section 3 */
.time130-card .t130-g4 { min-height: 360px !important; }
.time130-card .time130-g3 { min-height: 86px; }
.time130-card .time130-g3 .time130-label {
  display:flex; align-items:center; justify-content:center;
  font-weight:700;
}

/* ===== Row 3: same box/layout behavior as row 5 ===== */
.time130-card .time130-g3 {
  min-height: 0 !important;
  display: grid !important;
  grid-template-columns: 88px 1fr !important;
}
.time130-card .time130-g3 .time130-label {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 76px !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  position: static !important;
}
.time130-card .time130-g3 .time130-values {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 76px !important;
  height: auto !important;
  padding: 4px 8px !important;
}
.time130-card .time130-g3 .time130-values > div {
  width: 100%;
  text-align: center;
}


/* ===== CLEAN FIX: Group 3 is a normal standalone row, exactly like Group 5 ===== */
.time130-card .t130-row.t130-g3{
  display:grid !important;
  grid-template-columns:88px 1fr !important;
  min-height:64px !important;
  border-bottom:1px solid #333 !important;
}
.time130-card .t130-row.t130-g3 .t130-label{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  border-right:1px solid #333 !important;
  min-height:64px !important;
  padding:0 !important;
  margin:0 !important;
  position:static !important;
  font-size:22px !important;
  font-weight:700 !important;
  color:#111 !important;
}
.time130-card .t130-row.t130-g3 .t130-val{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  min-height:64px !important;
  padding:3px 8px !important;
  margin:0 !important;
  border:0 !important;
}
.time130-card .t130-row.t130-g3 .t130-val > div{
  display:block !important;
  width:100% !important;
  text-align:center !important;
  line-height:1.05 !important;
}


/* ===== FINAL FIX: row 3 aligns exactly with row 5 / DB ===== */
.time130-card .t130-row.t130-g3{
  display:grid !important;
  grid-template-columns:105px 1fr !important;
  min-height:76px !important;
  border-bottom:2px solid #111 !important;
}

.time130-card .t130-row.t130-g3 .t130-label{
  border-right:2px solid #111 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  min-height:76px !important;
  margin:0 !important;
  padding:0 !important;
  position:static !important;
  font-size:27px !important;
  font-weight:900 !important;
  line-height:.9 !important;
  color:#111 !important;
}

.time130-card .t130-row.t130-g3 .t130-val{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  min-height:76px !important;
  margin:0 !important;
  padding:4px 8px !important;
  border:0 !important;
  font-size:42px !important;
  font-weight:900 !important;
  line-height:.92 !important;
}

.time130-card .t130-row.t130-g3 .t130-val > div{
  width:100% !important;
  text-align:center !important;
  margin:0 !important;
  padding:0 !important;
}


/* =========================================================
   PRO UPGRADE UI
   ========================================================= */
.pro-toolbar{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:10px 12px;
  margin:-6px 0 16px;
}
.pro-actions{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
}
.pro-actions button{padding:8px 11px}
.zoom-text{min-width:48px;text-align:center;font-weight:800;font-size:13px}

.batch-queue{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid #eee;
}
.batch-item{
  border:1px solid #d0d5dd;
  border-radius:9px;
  padding:7px 9px;
  background:#f9fafb;
  cursor:pointer;
  font-size:12px;
  font-weight:700;
}
.batch-item.active{
  border-color:#111827;
  background:#eef2ff;
}

.quality-notice{
  margin-top:10px;
  padding:9px 11px;
  border:1px solid #f59e0b;
  border-radius:9px;
  background:#fffbeb;
  font-size:13px;
  font-weight:700;
}
.num-input.ocr-check{
  outline:2px solid #f59e0b;
  background:#fffbeb;
}

.debug-panel{
  margin-top:10px;
  border:1px solid #d0d5dd;
  border-radius:10px;
  background:#0b1020;
  color:#dbeafe;
  overflow:hidden;
}
.debug-panel summary{
  cursor:pointer;
  padding:10px 12px;
  font-weight:800;
  background:#111827;
}
.debug-panel pre{
  margin:0;
  padding:12px;
  overflow:auto;
  max-height:420px;
  font:12px/1.5 Consolas,monospace;
  white-space:pre-wrap;
}

.pro-modal{
  position:fixed;
  inset:0;
  z-index:9999;
  background:rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.pro-modal-card{
  width:min(820px,96vw);
  max-height:86vh;
  overflow:auto;
  border-radius:14px;
  background:#fff;
  padding:14px;
  box-shadow:0 24px 70px rgba(0,0,0,.28);
}
.pro-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border-bottom:1px solid #eee;
  padding-bottom:10px;
  margin-bottom:10px;
}
.pro-modal-head h3{margin:0}
.history-item{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  padding:11px 4px;
  border-bottom:1px solid #eee;
}
.history-meta{font-weight:800}
.history-sub{font-size:12px;color:#667085;margin-top:3px}
.history-buttons{display:flex;gap:5px;align-items:center}
.history-buttons button{padding:7px 9px}

.result-zoomable{
  transform-origin:top center;
  transition:transform .15s ease;
}

@media(max-width:850px){
  .app{padding:10px}
  .toolbar{position:sticky;top:0;z-index:40;border-radius:0 0 12px 12px}
  .pro-toolbar{position:sticky;top:112px;z-index:35;border-radius:10px}
  .pro-actions{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  .pro-actions button{font-size:11px;padding:8px 4px}
  .zoom-text{display:flex;align-items:center;justify-content:center}
  .panel{padding:10px}
  .preview-box{height:290px}
  .num-input{font-size:20px;min-height:44px}
  .t130-editor-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

@media(max-width:520px){
  .pro-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .mode-select{min-width:135px;flex:1}
  .paste-zone{min-width:100%}
  .date-control{width:100%}
  .date-control input{max-width:160px}
}

/* Better printing / screenshots */
@media print{
  body{background:#fff}
  header,.toolbar,.pro-toolbar,.panel:first-child,.result-head{display:none!important}
  .layout{display:block}
  .panel{border:0;padding:0}
}


/* ===== 1:30 PM: source-matching row structure ===== */
.time130-card .t130-g4-source{
  display:grid;
  grid-template-columns:105px 1fr;
  border-bottom:2px solid #111;
}
.time130-card .t130-g4-source .t130-g4-label{
  border-right:2px solid #111;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:27px;
  font-weight:900;
  color:#111;
}
.time130-card .t130-g4-groups{
  display:flex;
  flex-direction:column;
  min-width:0;
}
.time130-card .t130-g4-subrow{
  min-height:54px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-bottom:1px solid #777;
  font-size:42px;
  font-weight:900;
  line-height:.95;
  text-align:center;
  padding:3px 8px;
}
.time130-card .t130-g4-subrow:last-of-type{
  border-bottom:0;
}
.time130-card .t130-g4-subrow > div{
  width:100%;
  text-align:center;
}

/* At 1:30 PM, we keep one left label "4" spanning all source sub-rows. */

/* V65: 1:30 PM numbers inside each source row must stack vertically. */
.time130-card .t130-g4-subrow{
  flex-direction:column;
  gap:0;
  height:auto;
  min-height:54px;
  padding:5px 8px;
}
.time130-card .t130-g4-subrow-3,
.time130-card .t130-g4-subrow-2{
  justify-content:center;
}
.time130-card .t130-g4-subrow > div{
  display:block;
  width:100%;
  line-height:1.02;
  white-space:nowrap;
}


/* ===== FINAL 1:30 ORIGINAL SOURCE LAYOUT ===== */
.time130-card #t130g4Source{
  display:grid !important;
  grid-template-columns:105px 1fr !important;
  border-bottom:2px solid #111 !important;
}
.time130-card #t130g4Source .t130-g4-label{
  border-right:2px solid #111 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:27px !important;
  font-weight:900 !important;
  color:#111 !important;
}
.time130-card #t130g4Source .t130-g4-groups{
  display:block !important;
  padding:0 !important;
  margin:0 !important;
}
.time130-card #t130g4Source .t130-g4-subrow{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  border-bottom:1px solid #777 !important;
  padding:3px 8px !important;
  margin:0 !important;
  min-height:0 !important;
  font-size:42px !important;
  font-weight:900 !important;
  line-height:.92 !important;
  text-align:center !important;
}
.time130-card #t130g4Source .t130-g4-subrow:last-of-type{
  border-bottom:0 !important;
}
.time130-card #t130g4Source .t130-g4-subrow > div{
  display:block !important;
  width:100% !important;
  text-align:center !important;
  margin:0 !important;
  padding:0 !important;
}
.time130-card #t130g4Source .t130-unused-slot{
  display:none !important;
}


/* ===== V66 CLEAN 1:30 PM RESULT ===== */
.time130-card #t130g4Source{
  overflow:hidden !important;
}
.time130-card #t130g4Source .t130-g4-groups{
  min-width:0 !important;
}
.time130-card #t130g4Source .t130-g4-subrow{
  box-sizing:border-box !important;
}


/* ===== V68 1:30 PM FINAL ROW 7 ===== */
.time130-card #t130g4Source .t130-g4-groups > .t130-g4-subrow:first-child{
  border-bottom:1px solid #777 !important;
}


/* ===== Shared daytime 7-group: restore missing 9th row ===== */
.time130-card #t130g49{
  width:100%;
  text-align:center;
  margin:0;
  padding:0;
  font-size:42px;
  font-weight:900;
  line-height:.92;
}


/* ===== PRO V2 upgrades ===== */
.pro-modal-wide{max-width:820px!important}
.history-tools{display:flex;gap:10px;align-items:center;margin:10px 0 14px}
.history-tools input{flex:1;min-width:0;padding:10px 12px;border:1px solid #d0d5dd;border-radius:10px;font-size:15px}
#historyCount{font-size:13px;font-weight:800;color:#667085;white-space:nowrap}
.import-label{display:inline-flex!important;align-items:center;justify-content:center;cursor:pointer;padding:10px 14px;border-radius:9px;font-weight:700}
.import-label input{display:none}
.history-item{gap:12px}
.history-buttons{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.history-buttons button{padding:7px 10px}
.settings-card{max-width:640px!important}
.settings-grid{display:grid;gap:10px;margin-top:12px}
.setting-row{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:12px;border:1px solid #e5e7eb;border-radius:12px;background:#fafafa;cursor:pointer}
.setting-row span{display:flex;flex-direction:column;gap:3px}
.setting-row small{color:#667085;line-height:1.35}
.setting-row input[type="checkbox"]{width:22px;height:22px;flex:0 0 auto}
.settings-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}
.ocr-result-check{outline:2px solid #ef4444!important;outline-offset:-2px;background:#fff1f2!important}
.ocr-result-ok{outline:none}
#qualityNotice.pro-warning{display:block!important;background:#fff4e5;border:1px solid #f59e0b;color:#92400e;padding:10px 12px;border-radius:10px}
.auto-working{animation:proPulse 1s ease-in-out infinite alternate}
@keyframes proPulse{from{opacity:.55}to{opacity:1}}

@media(max-width:650px){
  .app{padding:8px}
  header h1{font-size:20px}
  .toolbar,.pro-actions{gap:6px}
  button,.upload-btn,select{padding:9px 10px;font-size:13px}
  .paste-zone{min-width:100%;order:10}
  .mode-select{min-width:calc(50% - 5px);flex:1}
  .date-control{width:100%}
  .date-control input[type="date"]{flex:1;min-width:140px}
  .panel{padding:8px;border-radius:10px}
  .preview-box{height:260px}
  .result-head h2{font-size:17px}
  .pro-modal{padding:8px}
  .pro-modal-card{max-height:92vh;overflow:auto}
  .pro-modal-head{align-items:flex-start;gap:8px}
  .pro-modal-head>div{display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end}
  .history-tools{flex-direction:column;align-items:stretch}
  .history-item{grid-template-columns:1fr!important}
  .history-buttons{justify-content:flex-start}
  .setting-row{align-items:flex-start}
}


/* ===== PRO V3 ===== */
.compare-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.compare-grid section{min-width:0;border:1px solid #e5e7eb;border-radius:12px;padding:10px;background:#fafafa}
.compare-grid h4{margin:0 0 8px}
.compare-grid pre{white-space:pre-wrap;word-break:break-word;max-height:360px;overflow:auto;margin:0;font-size:12px}
.confidence-summary{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:8px 0 12px;padding:10px;border:1px solid #e5e7eb;border-radius:10px}
.confidence-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:7px;margin-top:10px}
.confidence-chip{padding:8px;border:1px solid #e5e7eb;border-radius:9px;background:#fff;font-size:12px}
.confidence-chip.low{border-color:#ef4444;background:#fff1f2}
.confidence-chip.medium{border-color:#f59e0b;background:#fff7ed}
.confidence-chip.good{border-color:#22c55e;background:#f0fdf4}

.dashboard-card{max-width:980px!important}
.dashboard-tools{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:10px 0}
.dashboard-tools label{display:flex;gap:7px;align-items:center;font-weight:800}
.dashboard-tools input{padding:9px;border:1px solid #d0d5dd;border-radius:9px}
.dashboard-stats{padding:9px 11px;border-radius:9px;background:#f3f4f6;font-weight:800;margin-bottom:10px}
.dashboard-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}
.dashboard-item{border:1px solid #e5e7eb;border-radius:12px;padding:10px;background:#fff}
.dashboard-item h4{margin:0 0 7px}
.dashboard-item pre{white-space:pre-wrap;max-height:240px;overflow:auto;margin:0;font-size:12px}
.dashboard-item-actions{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}

.duplicate-card{max-width:480px!important}
#historyDateFilter{padding:10px;border:1px solid #d0d5dd;border-radius:10px}

body.pro-dark{background:#0f172a;color:#e5e7eb}
body.pro-dark .toolbar,
body.pro-dark .panel,
body.pro-dark .pro-toolbar,
body.pro-dark .pro-modal-card,
body.pro-dark .compare-grid section,
body.pro-dark .dashboard-item,
body.pro-dark .confidence-chip,
body.pro-dark .setting-row{background:#111827;color:#e5e7eb;border-color:#334155}
body.pro-dark .light,
body.pro-dark select,
body.pro-dark input,
body.pro-dark .paste-zone{background:#1f2937;color:#f9fafb;border-color:#475569}
body.pro-dark .note,
body.pro-dark small,
body.pro-dark header p,
body.pro-dark #historyCount{color:#cbd5e1}
body.pro-dark .dashboard-stats{background:#1e293b}
body.pro-dark .ticket,
body.pro-dark .night-exact-card,
body.pro-dark .compact-abcdh-card,
body.pro-dark .compact-abcd-card,
body.pro-dark #time130Card{background:#fff;color:#111}

@media(max-width:700px){
  .compare-grid{grid-template-columns:1fr}
  .dashboard-card{width:100%}
}
