:root {
	--c-bg: #f5f6fa;
	--c-surface: #ffffff;
	--c-border: #e6e7ec;
	--c-text: #14161f;
	--c-text-secondary: #6b6f7d;
	--c-text-muted: #9a9dab;
	--c-primary: #4338ca;
	--c-primary-hover: #372dae;
	--c-primary-soft: #eef0ff;
	--c-danger: #d6303e;
	--c-danger-soft: #fdecee;
	--c-success: #05966e;
	--c-success-soft: #e8f8f1;
	--c-radius-lg: 16px;
	--c-radius: 12px;
	--c-radius-sm: 8px;
	--c-shadow: 0 1px 2px rgba(20, 22, 31, 0.06), 0 1px 1px rgba(20, 22, 31, 0.04);
	--c-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html.dark {
	--c-bg: #0f1117;
	--c-surface: #171a21;
	--c-border: #2a2e39;
	--c-text: #e7e9ee;
	--c-text-secondary: #a7abb8;
	--c-text-muted: #7b8090;
	--c-primary: #8b83f5;
	--c-primary-hover: #a29bf8;
	--c-primary-soft: #23223b;
	--c-danger: #f2637a;
	--c-danger-soft: #3a2027;
	--c-success: #34d3a0;
	--c-success-soft: #10281f;
	--c-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
body {
	margin: 0;
	font-family: var(--c-font);
	background: var(--c-bg);
	color: var(--c-text);
	font-size: 15px;
	line-height: 1.55;
}
h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.topbar {
	background: var(--c-surface); border-bottom: 1px solid var(--c-border);
	padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar nav a { margin-left: 18px; font-size: 14px; font-weight: 600; color: var(--c-text-secondary); }
.topbar nav a.active, .topbar nav a:hover { color: var(--c-primary); text-decoration: none; }
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	border-radius: var(--c-radius-sm); border: 1px solid transparent; padding: 9px 16px;
	font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); text-decoration: none; }
.btn-secondary { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); }
.btn-secondary:hover { border-color: #c7c9d4; text-decoration: none; }
.btn-danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Cards / tables ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--c-radius); box-shadow: var(--c-shadow); padding: 20px; }
table.list { width: 100%; border-collapse: collapse; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--c-radius); overflow: hidden; }
table.list th {
	text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
	color: var(--c-text-muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--c-border); background: var(--c-bg);
}
table.list td { padding: 12px 16px; border-bottom: 1px solid var(--c-border); font-size: 14px; }
table.list tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; color: var(--c-text-muted); padding: 40px 0; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text-secondary); margin-bottom: 6px; }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="number"], .field input[type="date"], .field input[type="file"],
.field select, .field textarea {
	width: 100%; padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--c-radius-sm);
	background: var(--c-surface); font-size: 14px; font-family: inherit; color: var(--c-text);
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus {
	outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.field .hint { font-size: 12px; color: var(--c-text-muted); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--c-danger); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- Line item / custom field repeaters ---------- */
table.repeater { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.repeater th { text-align: left; font-size: 12px; color: var(--c-text-muted); padding: 0 8px 6px; font-weight: 600; }
table.repeater td { padding: 4px 8px 4px 0; vertical-align: top; }
table.repeater input, table.repeater select { width: 100%; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--c-radius-sm); font-size: 13.5px; }
table.repeater .remove-row { background: none; border: none; color: var(--c-danger); cursor: pointer; font-size: 18px; line-height: 1; padding: 8px; }
.repeater-totals { text-align: right; font-size: 14px; margin-bottom: 20px; }
.repeater-totals strong { font-size: 16px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--c-radius-sm); margin-bottom: 18px; font-size: 14px; }
.alert-success { background: var(--c-success-soft); color: var(--c-success); }
.alert-error { background: var(--c-danger-soft); color: var(--c-danger); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--c-bg); color: var(--c-text-secondary); }
.badge-proforma_invoice { background: #fdf3e0; color: #b6710a; }
.badge-invoice { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-receipt { background: var(--c-success-soft); color: var(--c-success); }
.badge-quotation { background: #eef4fd; color: #1d6fc9; }
.badge-sales_order { background: #efeafd; color: #6b3fd4; }
.badge-credit_note { background: #fdeaea; color: #c0392b; }
.badge-retainer_invoice { background: #e6f5f0; color: #1c7a5e; }

/* ---------- Type tabs on the documents list ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs a {
	padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
	color: var(--c-text-secondary); background: var(--c-surface); border: 1px solid var(--c-border);
}
.tabs a.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); text-decoration: none; }
.tabs a:hover { text-decoration: none; border-color: var(--c-primary); }

.new-document-menu { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
	.form-grid { grid-template-columns: 1fr; }
	.container { padding: 20px 16px 48px; }
}
