:root {
    --bg: #f3f5f8;
    --card: #fff;
    --ink: #1c2430;
    --muted: #6b7686;
    --line: #d9dee6;
    --brand: #14507a;
    --brand-d: #0d3a59;
    --accent: #e8f1f8;
    --ok: #1b7f4b;
    --warn: #a86a00;
    --err: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h2, h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }

/* sidebar layout */
.side { position: fixed; top: 0; left: 0; bottom: 0; width: 250px; background: #0f3a57; color: #dbe7f1; display: flex; flex-direction: column; z-index: 40; overflow-y: auto; }
.sbrand { display: block; padding: 18px 16px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; line-height: 1.3; border-bottom: 1px solid rgba(255,255,255,.12); }
.snav { flex: 1; padding: 10px 8px; }
.side a { text-decoration: none; }
.ni, .gh { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin: 2px 0; color: #dbe7f1; background: none; border: 0; border-radius: 8px; font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.ni:hover, .gh:hover { background: rgba(255,255,255,.09); color: #fff; }
.ni.on { background: #1b6a9c; color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #7fd0ff; }
.ic { width: 22px; text-align: center; flex: 0 0 22px; font-size: 15px; }
.gl { flex: 1; font-weight: 600; letter-spacing: .2px; }
.chev { font-size: 12px; transition: transform .15s; opacity: .8; }
.ng.open > .gh .chev { transform: rotate(90deg); }
.ng.open > .gh { color: #fff; }
.gi { display: none; margin: 2px 0 6px 18px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.18); }
.ng.open > .gi { display: block; }
.gi .ni { padding: 8px 10px; font-size: 14px; }
.suser { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.suser .uname { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn { background: none; border: 0; color: #9fd0f0; cursor: pointer; text-decoration: underline; font: inherit; padding: 0; }
.content { margin-left: 250px; min-height: 100vh; }
.mtop, .shade { display: none; }
@media (max-width: 900px) {
    .side { transform: translateX(-100%); transition: transform .2s; width: 270px; box-shadow: 4px 0 18px rgba(0,0,0,.3); }
    .side.open { transform: none; }
    .content { margin-left: 0; }
    .mtop { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: #0f3a57; color: #fff; padding: 8px 12px; }
    .burger { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px; font-size: 22px; line-height: 1; padding: 6px 12px; cursor: pointer; }
    .mname { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .shade.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
}
@media print { .content { margin-left: 0; } }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.card.narrow { max-width: 620px; }
.card.inactive { opacity: .6; }
.bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar h2 { margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select { display: block; margin-top: 3px; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
form.inline label { margin-bottom: 0; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
    font: inherit; color: var(--ink); background: #fff; border: 1px solid #b9c2cf; border-radius: 6px; padding: 7px 9px; width: 100%; max-width: 100%;
}
form.inline input, form.inline select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fb2d6; border-color: var(--brand); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px; }
legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
label.check { display: block; color: var(--ink); font-size: 14px; margin: 4px 0; }
label.check input { display: inline; width: auto; margin: 0 6px 0 0; }

.btn { display: inline-block; font: inherit; cursor: pointer; text-decoration: none; background: #fff; color: var(--brand); border: 1px solid var(--brand); border-radius: 7px; padding: 8px 14px; }
.btn:hover { background: var(--accent); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.big { padding: 11px 26px; font-size: 16px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { background: #e7f6ee; border-color: #9fd6b8; color: #14583a; }
.flash.warn { background: #fff4de; border-color: #efce86; color: #7a4d00; }
.flash.err { background: #fdeceb; border-color: #efaaa6; color: #8a1b14; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip { display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font-size: 13px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.has:not(.on) { border-color: var(--ok); box-shadow: inset 0 -3px 0 var(--ok); }
.chip.alt { border-style: dashed; color: var(--brand); }

/* dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.stat .big { font-size: 30px; font-weight: 700; margin: 4px 0 8px; }
.stat .big small { font-size: 14px; font-weight: 400; color: var(--muted); }
.progress { background: #e3e8ef; border-radius: 99px; height: 10px; overflow: hidden; margin-bottom: 4px; }
.progress span { display: block; height: 100%; background: var(--ok); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* tables */
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
table.grid thead th { background: #eef2f7; font-size: 13px; text-align: center; white-space: nowrap; }
table.entry td, table.entry th.ln { text-align: center; }
table.entry th.ln { background: #f7f9fb; font-size: 15px; }
table.entry input.num { width: 82px; text-align: center; }
table.entry input.art { width: 130px; }
table.entry .hl { background: #f2f8ee; }
table.entry thead th.hl { background: #dfeed5; }
table.entry input.out { font-weight: 700; border-color: #7fae5e; }
table.entry input.carried { font-style: italic; color: #5a6a7e; }
table.entry tfoot th, table.entry tfoot td { background: #eef2f7; font-weight: 700; padding: 8px; text-align: center; }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 14px 0 6px; display: flex; gap: 10px; flex-wrap: wrap; }

/* report paper */
.paper { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 18px; margin-bottom: 16px; overflow-x: auto; }
.rephead { text-align: center; margin-bottom: 10px; }
.rephead .co { font-size: 20px; font-weight: 700; }
.rephead .addr { font-size: 12px; color: #444; }
.rephead .title { font-weight: 700; margin-top: 4px; position: relative; }
.rephead .date { position: absolute; right: 0; top: 0; font-weight: 600; }
.repsec { margin-bottom: 14px; break-inside: avoid; }
.repsec h3 { font-size: 14px; background: #eef2f7; padding: 4px 8px; border: 1px solid #333; border-bottom: 0; margin: 0; }
table.rep { font-size: 12px; }
table.rep th, table.rep td { border: 1px solid #333; padding: 4px 5px; text-align: center; }
table.rep thead th { background: #f4f6f9; }
table.rep td.l { text-align: left; }
table.rep tfoot th, table.rep tfoot td { font-weight: 700; background: #f4f6f9; }
.sign { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 46px; font-size: 12px; text-align: center; }
.sign div { border-top: 1px solid #333; padding-top: 4px; }
.wa textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; margin-top: 10px; }

/* login */
.loginpage main { display: flex; justify-content: center; padding-top: 8vh; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }

@media (max-width: 640px) {
    main { padding: 10px; }
    .stat .big { font-size: 26px; }
    .rephead .date { position: static; display: block; }
}

/* print */
@page { size: A4 landscape; margin: 10mm; }
@media print {
    body { background: #fff; font-size: 12px; }
    .no-print { display: none !important; }
    main { max-width: none; padding: 0; }
    .paper { border: 0; padding: 0; margin: 0; overflow: visible; }
    .repsec { break-inside: avoid; }
    table.rep { font-size: 11px; }
    .sign { margin-top: 40px; }
}

/* whatsapp image */
.wa-img { margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.wa-img canvas { display: block; height: auto; }
.wa details { margin-top: 6px; }

/* monthly report */
table.mon { font-size: 13px; }
table.mon th, table.mon td { border: 1px solid #333; padding: 4px 6px; text-align: center; }
table.mon thead th { background: #e9eef4; }
table.mon th.c { background: #dbeaf6; } table.mon th.s { background: #e3efcf; } table.mon th.f { background: #f3e9d2; }
table.mon td.l { text-align: left; font-size: 12px; }
table.mon tr.off td, table.mon tr.off th { background: #ffd84d; font-weight: 700; }
table.mon tfoot td, table.mon tfoot th { background: #ffd84d; font-weight: 700; }
table.mon input { width: 100%; padding: 3px 5px; font-size: 13px; }
table.mon input.q { width: 80px; }
.monhead { text-align: center; margin-bottom: 10px; }
.monhead .co { font-size: 20px; font-weight: 700; }
.monhead .addr { font-size: 12px; }
.monhead .title { font-weight: 700; margin-top: 3px; }
.sign.four { grid-template-columns: repeat(4, 1fr); }
@page monthly { size: A4 portrait; margin: 8mm; }
@media print { .paper.mon { page: monthly; } table.mon { font-size: 10.5px; } table.mon th, table.mon td { padding: 2px 4px; } table.mon * { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* day-end production report (matches the paper form) */
.paper.dayend { font-family: Arial, Helvetica, sans-serif; padding: 14px 18px 18px; }
.dehead { text-align: center; color: #1a1a8c; margin-bottom: 4px; }
.dehead .co { font-weight: 700; font-size: 19px; }
.dehead .addr { font-size: 11px; }
.dehead .title { font-weight: 700; font-size: 13px; margin-top: 3px; }
.dedate { text-align: right; font-size: 12px; font-weight: 700; color: #1a1a8c; margin-bottom: 2px; }
.scrollx { overflow-x: auto; }
table.de { width: 100%; border-collapse: collapse; font-size: 13px; }
table.de th, table.de td { border: 1px solid #3a3aa0; padding: 3px 6px; text-align: center; color: #111; }
table.de thead th { color: #1a1a8c; font-weight: 700; background: #fff; }
table.de th.ln { color: #1a1a8c; font-weight: 600; width: 58px; }
table.de td.tl { color: #1a1a8c; font-weight: 600; }
table.de td.tv { font-weight: 700; }
table.de td.cm { color: #333; }
table.de tr.gt th, table.de tr.gt td { color: #1a1a8c; font-weight: 700; }
table.de td.rem { vertical-align: top; text-align: left; width: 33%; min-width: 190px; padding: 8px 10px; font-size: 13.5px; line-height: 1.5; }
table.de td.rem h4 { margin: 10px 0 2px; font-size: 14px; text-decoration: underline; }
table.de td.rem h4:first-child { margin-top: 0; }
table.de td.rem div { white-space: nowrap; }
table.de td.rem .grp { font-weight: 700; margin-top: 8px; }
table.de td.rem .note { white-space: pre-wrap; margin-top: 12px; border-top: 1px dashed #999; padding-top: 6px; }
table.de input { width: 100%; min-width: 56px; padding: 3px 5px; font-size: 13px; border-radius: 3px; }
table.de input.auto { background: #eef6ee; font-weight: 700; }
table.de input.bad { background: #fdeceb; border-color: #b3261e; }
table.de .carried { font-style: italic; color: #5a6a7e; }
table.de textarea { font-size: 13px; }
.defoot { display: flex; justify-content: space-between; gap: 12px; margin-top: 34px; color: #1a1a8c; font-size: 12px; }
.defoot > div { flex: 1; text-align: center; }
.defoot .nm { display: block; min-height: 18px; color: #111; font-weight: 600; font-size: 13px; }
.defoot input { text-align: center; margin-bottom: 3px; }
@page dayend { size: A4 portrait; margin: 8mm; }
@media print {
    .paper.dayend { page: dayend; padding: 0; }
    table.de { font-size: 11.5px; }
    table.de th, table.de td { padding: 2px 4px; }
    table.de td.rem { font-size: 12px; }
    table.de *, .dehead * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* day-end report: match the paper form (navy lines, tall Remarks column) */
.paper.dayend { padding: 14px 18px; }
.paper.dayend .rephead { position: relative; margin-bottom: 4px; }
.paper.dayend .rephead .co { color: #1a1a8c; font-size: 20px; }
.paper.dayend .rephead .addr { color: #1a1a8c; font-size: 11px; }
.paper.dayend .rephead .title { color: #1a1a8c; font-size: 13px; }
.paper.dayend .rephead .dline { text-align: right; font-size: 12px; color: #1a1a8c; margin-top: 2px; }
.paper.dayend .rephead .dline strong { color: #000; }
table.de { table-layout: fixed; border-collapse: collapse; border: 1px solid #2a2a96; }
table.de th, table.de td { border: 1px solid #2a2a96; padding: 3px 4px; height: 24px; color: #000; }
table.de thead th { background: #fff; color: #1a1a8c; font-size: 12px; }
table.de th.ln { background: #fff; color: #1a1a8c; font-size: 12px; }
table.de tr.tl td { background: #fff; color: #1a1a8c; font-weight: 600; }
table.de tr.tl td.ltot { color: #000; }
table.de tr.gt th { background: #fff; color: #1a1a8c; font-size: 12px; }
table.de tr.gt td { color: #000; font-weight: 600; }
table.de td.remark { vertical-align: top; text-align: left; padding: 8px 10px; font-size: 13px; }
table.de td.remark h4 { margin: 10px 0 3px; font-size: 14px; text-decoration: underline; }
table.de td.remark h4:first-child { margin-top: 0; }
table.de td.remark h4 small { font-weight: 400; text-decoration: none; }
table.de td.remark div { white-space: nowrap; }
table.de td.remark .grp { font-weight: 700; margin-top: 6px; }
table.de td.remark .note { white-space: pre-wrap; margin-top: 10px; border-top: 1px dashed #999; padding-top: 6px; }
table.de .chk { font-size: 11px; font-weight: 600; margin-left: 6px; white-space: normal; }
.signs { display: flex; justify-content: space-between; margin-top: 26px; font-size: 11px; color: #1a1a8c; }
.signs div { text-align: center; min-width: 30%; }
.signs b { display: block; min-height: 18px; color: #000; font-size: 13px; }
.signs input { text-align: center; margin-bottom: 2px; }
@media print {
    .paper.dayend { padding: 0; }
    table.de th, table.de td { height: 21px; padding: 1px 3px; }
    table.de thead { display: table-row-group; }
    table.de { break-inside: avoid; }
    table.de { font-size: 11px; }
    table.de td.remark { font-size: 12px; }
}
@media (max-width: 800px) { .paper.dayend { overflow-x: auto; } table.de { min-width: 720px; } }
table.de td.remark .remtext { white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
table.de td.remark textarea.remarea { width: 100%; min-height: 420px; height: 100%; font-size: 13px; line-height: 1.5; border: 1px dashed #99a; resize: vertical; }

/* lunch hour */
.chip.lunch { background: #fff4de; border: 1px dashed #d8a63a; color: #7a4d00; cursor: default; }
table.entry th.lunchh, table.entry td.lunchc { background: #fff4de; color: #7a4d00; font-size: 12px; text-align: center; }
table.rep th.lunch, table.rep td.lunch { background: #fff0cc; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* records (maintenance / store / qc / accounts) */
.nowrap { white-space: nowrap; }
.paper.rrep table.rep td.l { text-align: left; }
@page rrep { size: A4 landscape; margin: 8mm; }
@media print { .paper.rrep { page: rrep; } .paper.rrep table.rep { font-size: 11px; } }
.cards.small { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.stat.mini .big { font-size: 26px; }
label input[type=time] { width: 100%; }

/* generator log */
.genstock { display: flex; justify-content: space-between; align-items: center; font-size: 17px; border-left: 5px solid #1b7f4b; }
.genstock strong { font-size: 26px; }
.genstock.neg { border-left-color: #b3261e; } .genstock.neg strong { color: #b3261e; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.stopbox { border: 1px solid #9fd6b8; background: #f2fbf6; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.runtag { color: #1b7f4b; }
.costhint { margin: -4px 0 10px; font-size: 13px; }
table.genlog { font-size: 13.5px; }
table.genlog td, table.genlog th { text-align: center; }
table.genlog td.l { text-align: left; }
table.genlog tr.runrow td { background: #f2fbf6; }
table.genlog td.costc { color: #b3261e; font-weight: 600; }
table.genlog td.negc strong { color: #b3261e; }
table.genlog tfoot th, table.genlog tfoot td { background: #eef2f7; font-weight: 700; }
.paper.genrep .genco { color: #d3201a; font-size: 24px; }
.paper.genrep table.rep { margin-bottom: 12px; }
.paper.genrep td.redn { color: #d3201a; font-weight: 600; }
table.rep.persum { width: auto; min-width: 420px; margin-top: 14px; }
.paper.genrep .signs { margin-top: 40px; }

/* multi-company (SaaS) */
.login.welcome { text-align: center; max-width: 420px; }
.login.welcome .btn.big { display: block; margin: 12px 0; }
.login.reg { max-width: 520px; }
.small { font-size: 13px; }
.hp { position: absolute; left: -5000px; height: 0; overflow: hidden; }
.codebox { font-size: 26px; font-weight: 700; letter-spacing: 1px; background: #eef6f1; border: 2px dashed #1b7f4b; border-radius: 10px; padding: 12px; margin: 10px 0; }
.btn.danger { color: #b3261e; border-color: #b3261e; }
.btn.danger:hover { background: #fdecea; }
.badge { display: inline-block; background: #d3201a; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.status { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; vertical-align: middle; margin-left: 6px; }
.st-pending { background: #fff4de; color: #7a4d00; }
.st-approved { background: #e3f4ea; color: #14633a; }
.st-suspended { background: #fdecea; color: #b3261e; }
.st-rejected { background: #eceff3; color: #555; }
.card.co-pending { border-left: 5px solid #d8a63a; }
.card.co-approved { border-left: 5px solid #1b7f4b; }
.card.co-suspended { border-left: 5px solid #b3261e; }
details.users { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
details.users summary { cursor: pointer; color: var(--brand); }
.urow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.urow span:first-child { flex: 1 1 220px; }
.urow input[type=text] { max-width: 170px; }
