/* Synergeio — desktop-program look (Windows 10 forms): windows, menu bars, group boxes,
   tab control, property grids and data grids. System fonts only, no framework. */

:root {
	--desk: #2f5d87;
	--face: #f0f0f0;
	--white: #ffffff;
	--ink: #000000;
	--ink-2: #444;
	--muted: #6d6d6d;
	--edge: #a0a0a0;
	--edge-2: #d9d9d9;
	--edge-3: #dcdcdc;
	--grid: #c8c8c8;
	--accent: #0078d7;
	--accent-hover: #e5f1fb;
	--accent-edge: #cce4f7;
	--sel: #0078d7;
	--cur-hdr: #d4a017;
	--cur: #ffd700;
	--due: #008000;
	--over: #c00000;
	--font: "Segoe UI", Tahoma, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.sg { margin: 0; background: var(--desk); color: var(--ink); font: 13px/1.35 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 1px dotted #000; outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Desktop & windows ---------- */
.desktop { min-height: 100vh; padding: 14px; }
.desktop-center { display: grid; place-items: center; }

.win {
	background: var(--face);
	border: 1px solid #1883d7;
	box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
	max-width: 1180px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
}
.win-title {
	display: flex; align-items: center; gap: 8px;
	background: var(--accent); color: #fff;
	height: 30px; padding: 0 0 0 8px; user-select: none;
}
.win-ico { display: inline-flex; background: #fff; border-radius: 2px; padding: 1px; }
.win-t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-x { height: 30px; width: 46px; border: 0; background: transparent; color: #fff; font-size: 16px; cursor: pointer; }
.win-x:hover { background: #e81123; }
.win-fs { height: 30px; width: 40px; border: 0; background: transparent; color: #fff; cursor: pointer; display: inline-grid; place-items: center; }
.win-fs .ic { display: inline-flex; }
.win-fs:hover { background: rgba(255, 255, 255, .18); }
.mwin .win-fs { display: none; }

.menubar { display: flex; flex-wrap: wrap; align-items: center; gap: 0; background: var(--white); padding: 2px 4px; border-bottom: 1px solid var(--edge-2); }
.mi {
	display: inline-flex; align-items: center; gap: 4px;
	border: 1px solid transparent; background: transparent; padding: 3px 7px; cursor: default; white-space: nowrap;
}
.mi:hover:not([disabled]), .mi[aria-expanded=true] { background: var(--accent-hover); border-color: var(--accent-edge); }
.mi[disabled] { color: #a0a0a0; }
.mi[disabled] svg { opacity: .45; }
.mi svg { flex: 0 0 auto; }
.mi.right, .mwrap.right { margin-left: auto; }
.mi.right + .mwrap.right { margin-left: 0; }
.mwrap { position: relative; display: inline-flex; }
.dd {
	position: absolute; left: 0; top: 100%; z-index: 40; min-width: 230px;
	background: var(--face); border: 1px solid #ccc; box-shadow: 2px 3px 8px rgba(0, 0, 0, .25); padding: 2px;
}
.mwrap.right .dd { left: auto; right: 0; }
.dd-i { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: none; padding: 4px 24px 4px 26px; cursor: default; white-space: nowrap; }
.dd-i:hover:not([disabled]), .dd-i:focus-visible { background: #91c9f7; border-color: #91c9f7; outline: none; }
.dd-i[disabled] { color: #a0a0a0; }
.dd .sep { height: 1px; background: #d7d7d7; margin: 3px 2px; }

.win-body { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.win-status {
	display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
	border-top: 1px solid var(--edge-2); background: var(--face); padding: 3px 10px; font-size: 12px; color: var(--ink-2); min-height: 24px;
}
.win-status .sp { flex: 1; }
.dirty-ind { color: var(--over); }

/* Modal windows */
dialog.mwin { padding: 0; border: 0; background: transparent; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: visible; }
dialog.mwin::backdrop { background: rgba(0, 0, 0, .25); }
dialog.mwin > .win { max-height: calc(100vh - 16px); }
dialog.mwin .win-body { overflow: auto; }

/* ---------- Group boxes ---------- */
.grp { border: 1px solid var(--edge-3); border-radius: 0; margin: 0; padding: 4px 8px 8px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.grp > legend { padding: 0 3px; margin-left: -2px; }
.grow { flex: 1; }

.selbar { display: flex; flex-wrap: wrap; gap: 6px 30px; align-items: center; padding: 6px 4px 4px; }
.selbar label { color: var(--ink-2); margin-right: 6px; }
.selbar .fieldline { display: flex; align-items: center; flex: 1 1 320px; min-width: 0; }
.selbar select { flex: 1; min-width: 0; font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.toolbar .sp { flex: 1; }

/* ---------- Controls ---------- */
.box, select.box, textarea.box {
	background: var(--white); border: 1px solid #7a7a7a; padding: 3px 5px; border-radius: 0; min-height: 24px;
}
.box:hover { border-color: #000; }
.box:focus { border-color: var(--accent); outline: none; }
select.box { padding: 2px 4px; }
textarea.box { resize: vertical; min-height: 70px; width: 100%; display: block; }
.lbl { color: var(--ink-2); display: block; margin: 4px 0 2px; }
.lblrow { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.lblrow .box { flex: 1; min-width: 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; }

.wbtn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	background: #e1e1e1; border: 1px solid #adadad; padding: 4px 14px; min-height: 26px; cursor: default; text-decoration: none; color: #000; white-space: nowrap;
}
.wbtn:hover:not([disabled]) { background: var(--accent-hover); border-color: var(--accent); }
.wbtn:active:not([disabled]) { background: #cce4f7; border-color: #005499; }
.wbtn.def { border: 1px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wbtn.wide { width: 100%; padding: 6px; }
.wbtn.ico { padding: 6px 8px; min-width: 40px; }
.wbtn[disabled] { color: #a0a0a0; background: #ccc; border-color: #bfbfbf; }
.wbtn[disabled] svg { opacity: .4; }

.msg-err { margin: 0; color: var(--over); }

/* ---------- Tab control ---------- */
.tabs { display: flex; flex-wrap: wrap; align-items: flex-end; padding-left: 2px; margin-bottom: -1px; position: relative; z-index: 1; }
.tab {
	background: var(--face); border: 1px solid var(--edge-2); border-bottom-color: var(--edge-2);
	padding: 3px 9px; margin-right: -1px; cursor: default;
}
.tab:hover { background: var(--accent-hover); }
.tab.on { background: var(--white); border-bottom-color: var(--white); padding: 5px 9px 4px; margin-top: -2px; }
.tabpanel { background: var(--white); border: 1px solid var(--edge-2); padding: 8px; }
.cols { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 10px; }
.cols > .grp { background: var(--white); }

/* ---------- Property grid (label | value) ---------- */
.pg { width: 100%; border-collapse: collapse; border: 1px solid var(--edge); background: var(--white); table-layout: fixed; }
.pg th, .pg td { border: 1px solid var(--grid); padding: 0; height: 22px; }
.pg th { background: var(--face); font-weight: 400; text-align: left; width: 46%; }
.pg th label, .pg th span { display: block; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg tr.b th, .pg tr.b td { font-weight: 700; }
.pg tr.ind th label, .pg tr.ind th span { text-align: right; padding-right: 8px; }
.pg tr.cur td { background: var(--cur); }
.pg .ro { display: block; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg tr.neg td .ro { color: var(--over); font-weight: 700; }

/* In-cell editors: borderless inputs filling the cell */
.cell {
	width: 100%; border: 0; background: transparent; padding: 2px 4px; height: 21px; min-width: 0; border-radius: 0;
}
.cell:focus { outline: none; }
.cell.r { text-align: right; }
.cell.bad { background: #ffd2d2 !important; color: var(--over); }
.cell.up { text-transform: uppercase; }
.cell::placeholder { color: #b5b5b5; }

/* ---------- Editable data grids ---------- */
.gwrap { position: relative; overflow: auto; border: 1px solid var(--edge); background: var(--white); }
.gwrap.tall { min-height: 360px; max-height: 470px; }
.gwrap.mid { max-height: 260px; }
.eg { width: 100%; border-collapse: collapse; table-layout: fixed; }
.eg th {
	position: sticky; top: 0; z-index: 2; background: var(--white); font-weight: 400; text-align: left;
	border: 1px solid var(--grid); border-top: 0; padding: 2px 6px; height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eg th.r, .eg td.r { text-align: right; }
.eg td { border: 1px solid var(--grid); padding: 0; height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eg td.hdr, .eg th.hdr { width: 22px; background: var(--face); padding: 0; cursor: default; }
.eg td.task { padding: 2px 6px; background: var(--white); }
.eg tr.cur td.hdr, .eg tr.cur td.task { background: var(--cur-hdr); }
.eg tr.cur td { background: var(--cur); }
.eg tr.sel td { background: var(--sel) !important; color: #fff; }
.eg tr.sel .cell { color: #fff; }
.eg td.hdr.st-due { background: var(--due); }
.eg td.hdr.st-overdue { background: var(--over); }
.gfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 6px; }
.gfoot .sp { flex: 1; }
.totals { display: grid; grid-template-columns: auto 110px auto; gap: 6px 6px; align-items: center; justify-items: end; }
.totals .box { width: 110px; text-align: right; }
.totals strong { padding-right: 6px; }

.eg select.cell { height: 21px; padding: 0 2px; background: transparent; border: 0; width: 100%; }
.eg td.calc { padding: 2px 6px; background: #f7f7f7; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.cols.cols-r { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
iframe.mailprev { width: 100%; height: min(68vh, 640px); border: 1px solid var(--edge); background: #fff; display: block; }
.pg tr.neg td .ro, .pg tr.neg td .ro span { color: var(--over); font-weight: 700; }

/* Combo cell: text input + dropdown button (scheduled tasks) */
.combo { display: flex; align-items: stretch; min-width: 0; }
.combo .cell { flex: 1; }
.combo-btn { flex: 0 0 18px; border: 0; border-left: 1px solid transparent; background: transparent; padding: 0; font-size: 11px; color: #555; cursor: default; }
.combo:hover .combo-btn, .combo:focus-within .combo-btn { border-left-color: var(--grid); background: var(--face); }
.combo-btn:hover { background: var(--accent-hover) !important; }
.eg tr.sel .combo-btn { color: #fff; }

/* Autocomplete list (like the combo in the desktop grid) */
.ac {
	position: absolute; z-index: 30; margin: 0; padding: 0; list-style: none;
	background: var(--white); border: 1px solid #646464; box-shadow: 2px 2px 6px rgba(0, 0, 0, .2);
	max-height: 250px; overflow-y: auto; min-width: 260px;
}
.ac li { padding: 2px 6px; cursor: default; white-space: nowrap; }
.ac li.on, .ac li:hover { background: var(--sel); color: #fff; }

/* ---------- Read-only list grids (main window, search, etc.) ---------- */
.lgwrap { overflow: auto; border: 1px solid var(--edge); background: var(--white); min-height: 120px; }
.lgwrap.tall { height: min(62vh, 560px); }
.lgwrap.mid { height: min(50vh, 420px); }
.lg { width: 100%; border-collapse: collapse; }
.lg th {
	position: sticky; top: 0; z-index: 1; background: var(--white); text-align: left; font-weight: 400;
	border: 1px solid var(--grid); border-top: 0; padding: 3px 6px; white-space: nowrap;
}
.lg td { border: 1px solid var(--grid); padding: 2px 6px; white-space: nowrap; height: 22px; }
.lg th.r, .lg td.r { text-align: right; }
.lg td.st { width: 22px; padding: 0; }
.lg td.st span { display: block; width: 100%; height: 21px; }
.lg tr { cursor: default; }
.lg tbody tr:hover td { background: var(--accent-hover); }
.lg tr.sel td, .lg tr.sel:hover td { background: var(--sel); color: #fff; }
.lg tr:focus { outline: 1px dotted #000; outline-offset: -2px; }
.lg .neg { color: var(--over); font-weight: 700; }
.lg tr.sel .neg { color: #fff; }
.empty { color: var(--muted); padding: 10px; }

.st-due { background: var(--due); }
.st-overdue { background: var(--over); }
.st-ok { background: transparent; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; }

.pager { display: flex; align-items: center; gap: 10px; }
.due-ind { border: 0; background: none; color: var(--due); cursor: pointer; padding: 0; text-decoration: underline; }
.due-ind::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--due); margin-right: 6px; vertical-align: -1px; }

/* Settings form */
.form2 { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.form2 label { color: var(--ink-2); }
.form2 .full { grid-column: 1 / -1; }
.form2 textarea.box { min-height: 110px; }

/* Message box */
.msgbox { display: flex; gap: 14px; align-items: flex-start; padding: 14px 10px 6px; max-width: 460px; white-space: pre-line; }
.msgbox .mb-ico { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.mb-ico.err { background: #e81123; }
.mb-ico.q { background: var(--accent); }
.mb-ico.i { background: var(--accent); }
.mb-btns { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 2px 2px; border-top: 1px solid var(--edge-2); }
.mb-btns .wbtn { min-width: 80px; }

#toasts { position: fixed; right: 14px; bottom: 14px; z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; }
.toast { background: #1f1f1f; color: #fff; padding: 9px 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); max-width: min(480px, calc(100vw - 28px)); }
.eg .cell::placeholder { color: transparent; }
.eg .cell:focus::placeholder { color: #b5b5b5; }

/* Login window */
.login-win { width: min(440px, 100%); }
.login-form { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.login-btns { display: flex; align-items: center; gap: 14px; }

/* ---------- Print (job sheet) ---------- */
#print-area { display: none; }
@media print {
	@page { size: A4; margin: 14mm; }
	body.sg { background: #fff; font-size: 10.5pt; }
	body.printing > :not(#print-area) { display: none !important; }
	body.printing #print-area { display: block; color: #000; }
	.pd-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
	.pd-shop { font-size: 14pt; font-weight: 700; }
	.pd-meta { text-align: right; }
	.pd-title { font-size: 13pt; font-weight: 700; }
	.pd-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
	#print-area h3 { font-size: 10pt; border-bottom: 1px solid #888; margin: 10px 0 4px; padding-bottom: 2px; }
	#print-area p { margin: 1px 0; }
	.pd-lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
	.pd-lines th, .pd-lines td { border: 1px solid #999; padding: 3px 6px; text-align: left; }
	.pd-lines .r { text-align: right; }
	.pd-total { display: flex; justify-content: space-between; border-top: 2px solid #000; margin-top: 10px; padding-top: 5px; font-size: 12pt; font-weight: 700; }
	.pd-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 46px; }
	.pd-sign div { border-top: 1px solid #000; padding-top: 3px; text-align: center; font-size: 9pt; }
	.pre { white-space: pre-wrap; }
}

/* ---------- Small screens: windows go full width, columns stack ---------- */
@media (max-width: 860px) {
	.desktop { padding: 0; }
	.win { border: 0; box-shadow: none; min-height: 100vh; }
	dialog.mwin .win { min-height: 0; }
	.cols, .cols.cols-r { grid-template-columns: 1fr; }
	.selbar { gap: 6px; }
	.tab { padding: 4px 8px; }
	.gwrap.tall { max-height: none; }
	.form2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
