/* Comfx Lite - colours from comfx.net */
:root {
	--navy: #071015;
	--navy-2: #101b22;
	--navy-3: #1f2e37;
	--red: #c8102e;
	--red-hover: #a50d26;
	--bg: #f4f6f7;
	--card: #ffffff;
	--text: #1c2329;
	--muted: #66717a;
	--line: #e3e7ea;
	--green: #15803d;
	--green-bg: #e7f6ec;
	--amber: #a16207;
	--amber-bg: #fdf3dc;
	--blue: #1d4ed8;
	--blue-bg: #e6edfd;
	--grey-bg: #eef0f2;
	--red-bg: #fde8eb;
	--radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	font: 15px/1.5 Inter, "Segoe UI", system-ui, sans-serif;
	color: var(--text);
	background: var(--bg);
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
	background: var(--navy);
	color: #c9d2d7;
	padding: 18px 12px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; }
.side .brand img { height: 26px; }
.side .brand span { font-size: 12px; font-weight: 600; color: #9ba9b1; border: 1px solid var(--navy-3); border-radius: 4px; padding: 1px 6px; }
.side .brand span.dev { color: #1a1300; background: #f5b301; border-color: #f5b301; }
.side a {
	color: #c9d2d7;
	padding: 9px 12px;
	border-radius: var(--radius);
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 500;
}
.side a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.side a.active { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f7f88; padding: 16px 12px 4px; }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--navy-3); font-size: 13px; }
.side .me button { margin-top: 6px; }
.menu-btn { display: none; }

main { padding: 24px 32px 64px; max-width: 1180px; width: 100%; min-width: 0; /* wide tables scroll inside .table-wrap */ }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { font-size: 14px; display: inline-block; margin-bottom: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: inherit; display: block; }
.stat:hover { border-color: #c9d0d5; text-decoration: none; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat .sub.bad { color: var(--red); font-weight: 600; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.cols > .card { overflow-x: auto; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

/* ---------- buttons and inputs ---------- */
button, .btn {
	font: inherit;
	font-weight: 600;
	border-radius: var(--radius);
	border: 1px solid #cfd5da;
	background: #fff;
	color: var(--text);
	padding: 8px 14px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}
button:hover, .btn:hover { background: #f1f3f5; text-decoration: none; }
button.primary, .btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--red-hover); }
button.link { border: 0; background: none; color: var(--red); padding: 4px; font-weight: 500; }
button.danger { color: var(--red); }
button.big, .btn.big { padding: 12px 18px; font-size: 15px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.side button { background: transparent; color: #c9d2d7; border-color: var(--navy-3); padding: 4px 10px; font-size: 13px; }
.side button:hover { background: var(--navy-2); }

label { display: block; font-size: 13px; font-weight: 600; color: #3a454d; margin-bottom: 4px; }
input, select, textarea {
	font: inherit;
	width: 100%;
	border: 1px solid #cfd5da;
	border-radius: var(--radius);
	padding: 8px 10px;
	background: #fff;
	color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid rgba(200, 16, 46, .35); outline-offset: 1px; border-color: var(--red); }
input[type="checkbox"] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.search { max-width: 320px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8f9fa; }
tfoot td { font-weight: 700; border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.lines td { padding: 6px; }
.lines input { padding: 6px 8px; }
.lines .qty { width: 80px; }
.lines .price { width: 130px; }
.lines td.prod { min-width: 220px; }
.lines td.vat { text-align: center; }
.totals { margin-left: auto; width: 320px; margin-top: 10px; }
.totals td { border: 0; padding: 4px 10px; }
.totals .grand td { font-size: 18px; font-weight: 700; border-top: 2px solid var(--text); }

/* ---------- status pills, chips ---------- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.grey { background: var(--grey-bg); color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 500; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.next { background: var(--blue-bg); color: #173a8a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.next b { color: #0f2a6b; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 14px; }
.kv .k { color: var(--muted); }

/* ---------- dialog, toast, login ---------- */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(7, 16, 21, .35); }
dialog::backdrop { background: rgba(7, 16, 21, .55); }
dialog .dh { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dh h2 { margin: 0; }
dialog .db { padding: 18px 20px; max-height: 65vh; overflow-y: auto; }
dialog .df { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.error-box { background: var(--red-bg); color: #8f0b22; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: var(--radius); font-weight: 500; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); }
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 500px at 85% -10%, rgba(199, 0, 0, .22), transparent 60%), var(--navy); padding: 16px; }
.login form { background: #fff; border-top: 3px solid var(--red); border-radius: 8px; padding: 28px; width: min(380px, 100%); box-shadow: 0 24px 60px rgba(0, 0, 0, .45); }
.login img { height: 36px; display: block; margin: 0 auto 6px; }
.login p { text-align: center; margin: 0 0 20px; }

/* ---------- dashboard charts ---------- */
.chart-grid { display: grid; gap: 18px; }
.chart-grid.wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.chart-grid.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-grid > .card { margin-bottom: 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
svg.viz { width: 100%; height: auto; display: block; overflow: visible; }
.viz-axis { font-size: 11px; fill: #898781; font-variant-numeric: tabular-nums; }
.viz-center { font-size: 19px; font-weight: 700; fill: var(--text); }
.viz-band:hover { fill: rgba(7, 16, 21, .04); }
.viz-slice:hover { opacity: .85; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-wrap svg.donut { width: 168px; flex: none; }
.legend { display: grid; gap: 6px; font-size: 13px; flex: 1; min-width: 160px; }
.legend.inline { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; color: #3a454d; }
.legend-name { flex: 1; }
.legend-value { font-weight: 600; color: var(--text); }
.legend-pct { width: 36px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.swatch.none { background: none; border: 1px solid #c3c2b7; }
.barlist { display: grid; gap: 10px; }
.barlist-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.barlist-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { height: 12px; }
.barlist-fill { height: 100%; border-radius: 0 4px 4px 0; }
.barlist-value { font-weight: 600; }
.hero { font-size: 44px; font-weight: 700; line-height: 1.1; margin: 4px 0 12px; }
.meter { display: flex; gap: 2px; height: 12px; margin-bottom: 14px; }
.meter > div:first-child { border-radius: 4px 0 0 4px; }
.meter > div:last-child { border-radius: 0 4px 4px 0; }
.viz-tip {
	position: fixed; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .1s;
	background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(7, 16, 21, .16);
	padding: 8px 10px; font-size: 13px; min-width: 170px;
}
.viz-tip.show { opacity: 1; }
.viz-tip-title { font-weight: 700; margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; }
.viz-tip-row span:nth-child(2) { flex: 1; color: #3a454d; }
.viz-tip-row.strong { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

@media (max-width: 1100px) {
	.chart-grid.wide-left, .chart-grid.thirds { grid-template-columns: minmax(0, 1fr); }
}

.phone-only { display: none; }

@media (max-width: 860px) {
	.shell { grid-template-columns: 1fr; }
	.side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
	.side.open { transform: none; }
	.menu-btn { display: inline-flex; position: fixed; top: 10px; left: 10px; z-index: 30; }
	main { padding: 60px 16px 48px; }
	.cols { grid-template-columns: 1fr; }
	.totals { width: 100%; }
	.kv { grid-template-columns: 110px 1fr; }

	/* Lists: Date/Balance/Total move under the number and customer */
	.no-phone { display: none; }
	.phone-only { display: block; margin-top: 2px; }

	/* Item lines in the quotation/invoice/PO editor: one card per line */
	.lines thead { display: none; }
	.lines, .lines tbody { display: block; }
	.lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); position: relative; }
	.lines td { display: block; padding: 0; border: 0; }
	.lines td.prod { grid-column: 1 / -1; padding-right: 30px; }
	.lines td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
	.lines td.num { text-align: left; font-weight: 600; }
	.lines td.vat { text-align: left; }
	.lines td.vat input { width: 20px; height: 20px; }
	.lines td.remove { position: absolute; top: 12px; right: 0; }
	.lines .qty, .lines .price { width: 100%; }
}
