/* =========================================================================
   Tradex International CRM — standalone app
   Off-white canvas · black body copy · Tradex blue · brass gold
   ====================================================================== */

:root {
	--tx-canvas:  #F6F4EF;
	--tx-paper:   #FFFDF9;
	--tx-line:    #E2DCD0;
	--tx-ink:     #14181D;
	--tx-ink-2:   #5C6470;
	--tx-blue:    #14539E;
	--tx-blue-dk: #0E3C74;
	--tx-blue-lt: #E7EFF9;
	--tx-gold:    #A9822C;
	--tx-gold-lt: #F6EEDA;
	--tx-red:     #A32B22;
	--tx-green:   #1F6B45;
	--tx-radius:  10px;
	--tx-shadow:  0 1px 2px rgba(20,24,29,.05), 0 8px 24px -12px rgba(20,24,29,.18);
	--tx-font:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--tx-canvas);
	color: var(--tx-ink);
	font-family: var(--tx-font);
	font-size: 14px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; }
a { color: var(--tx-blue); }

/* ---------- Shell ---------- */
.tx-shell { display: flex; min-height: 100vh; }

.tx-side {
	width: 250px;
	flex: 0 0 250px;
	background: #fff;
	border-right: 1px solid var(--tx-line);
	display: flex;
	flex-direction: column;
	padding: 22px 16px;
	position: sticky;
	top: 0;
	height: 100vh;
}
.tx-side__brand {
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: var(--tx-ink);
	padding-bottom: 20px;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--tx-line);
}
.tx-side__brand img { width: 46px; height: 46px; object-fit: contain; }
.tx-side__brand span { font-size: 17px; font-weight: 400; letter-spacing: .04em; color: var(--tx-gold); }
.tx-side__brand strong { color: var(--tx-blue); font-weight: 800; }

.tx-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.tx-nav__item {
	display: block;
	padding: 10px 13px;
	border-radius: 8px;
	color: var(--tx-ink);
	text-decoration: none;
	font-weight: 600;
	font-size: 13.5px;
	border-left: 3px solid transparent;
}
.tx-nav__item:hover { background: var(--tx-blue-lt); }
.tx-nav__item.is-active {
	background: var(--tx-blue);
	color: #fff;
	border-left-color: var(--tx-gold);
}

.tx-side__user {
	border-top: 1px solid var(--tx-line);
	padding-top: 16px;
	font-size: 13px;
}
.tx-side__name { display: block; font-weight: 700; }
.tx-side__role { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-gold); }
.tx-side__out { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--tx-red); text-decoration: none; }
.tx-side__out:hover { text-decoration: underline; }

.tx-main { flex: 1; min-width: 0; padding: 24px 28px 32px; }

/* ---------- Top bar ---------- */
.tx-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	flex-wrap: wrap;
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-top: 3px solid var(--tx-blue);
	border-radius: var(--tx-radius);
	padding: 16px 22px;
	box-shadow: var(--tx-shadow);
	margin-bottom: 20px;
}
.tx-topbar h1 { font-size: 23px; font-weight: 700; letter-spacing: -.01em; }
.tx-topbar p { margin: 2px 0 0; color: var(--tx-ink-2); font-size: 13px; }
.tx-topbar__side { display: flex; align-items: center; gap: 16px; }
.tx-topbar__phone { color: var(--tx-gold); font-weight: 700; text-decoration: none; font-size: 13px; }

/* ---------- Buttons ---------- */
.tx-btn {
	display: inline-block;
	padding: 9px 16px;
	border-radius: 8px;
	border: 1px solid transparent;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	font-family: inherit;
	transition: background .15s ease;
}
.tx-btn:focus-visible { outline: 2px solid var(--tx-gold); outline-offset: 2px; }
.tx-btn--blue { background: var(--tx-blue); color: #fff; }
.tx-btn--blue:hover { background: var(--tx-blue-dk); }
.tx-btn--gold { background: var(--tx-gold); color: #fff; }
.tx-btn--gold:hover { background: #8E6C21; }
.tx-btn--ghost { background: transparent; color: var(--tx-blue); border-color: var(--tx-line); }
.tx-btn--ghost:hover { background: var(--tx-blue-lt); }
.tx-btn--block { display: block; width: 100%; text-align: center; padding: 12px; font-size: 14px; }

/* ---------- Notices ---------- */
.tx-notice {
	border-radius: 8px;
	padding: 11px 16px;
	margin-bottom: 18px;
	font-weight: 600;
	border-left: 4px solid;
}
.tx-notice--success { background: #EAF3EC; border-color: var(--tx-green); color: var(--tx-green); }
.tx-notice--error   { background: #F8EBE9; border-color: var(--tx-red); color: var(--tx-red); }
.tx-notice--gold    { background: var(--tx-gold-lt); border-color: var(--tx-gold); color: #6E5417; }

/* ---------- Cards ---------- */
.tx-card {
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-radius: var(--tx-radius);
	padding: 20px 22px;
	box-shadow: var(--tx-shadow);
	margin-bottom: 20px;
}
.tx-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .tx-split { grid-template-columns: 1fr; } }
.tx-scroll { overflow-x: auto; }

/* ---------- Stats ---------- */
.tx-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.tx-stats--2 { grid-template-columns: repeat(2, 1fr); max-width: 640px; }
@media (max-width: 1100px) { .tx-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px)  { .tx-stats, .tx-stats--2 { grid-template-columns: 1fr; } }

.tx-stat {
	display: block;
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-left: 4px solid var(--tx-blue);
	border-radius: var(--tx-radius);
	padding: 16px 18px;
	text-decoration: none;
	color: var(--tx-ink);
	box-shadow: var(--tx-shadow);
}
.tx-stat:hover { border-left-color: var(--tx-gold); }
.tx-stat--gold { border-left-color: var(--tx-gold); }
.tx-stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-ink-2); }
.tx-stat strong { display: block; font-size: 25px; font-weight: 700; color: var(--tx-blue); margin: 4px 0 2px; }
.tx-stat--gold strong { color: var(--tx-gold); }
.tx-stat em { font-style: normal; font-size: 12px; color: var(--tx-ink-2); }

/* ---------- Filters ---------- */
.tx-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-radius: var(--tx-radius);
	padding: 12px 16px;
	margin-bottom: 18px;
}
.tx-filters input[type="search"] { flex: 1 1 280px; }
.tx-filters select { width: auto; min-width: 170px; }
.tx-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tx-ink-2); }
.tx-check input { width: auto; min-height: 0; }

/* ---------- Fields ---------- */
input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="search"], input[type="password"], select, textarea {
	width: 100%;
	background: #fff;
	border: 1px solid var(--tx-line);
	border-radius: 8px;
	padding: 9px 11px;
	color: var(--tx-ink);
	font-size: 13px;
	font-family: inherit;
	min-height: 38px;
}
textarea { min-height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus {
	border-color: var(--tx-blue);
	box-shadow: 0 0 0 3px var(--tx-blue-lt);
	outline: none;
}
input:disabled { background: #F1EEE7; color: var(--tx-ink-2); }
input[type="range"] { accent-color: var(--tx-blue); min-height: 0; padding: 0; border: 0; background: none; }

.tx-form label {
	display: block;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: var(--tx-ink-2);
	margin-bottom: 14px;
}
.tx-form label input,
.tx-form label select,
.tx-form label textarea {
	margin-top: 5px;
	font-weight: 400;
	text-transform: none;
	letter-spacing: 0;
}
.tx-req { color: var(--tx-red); }

.tx-form__legend {
	margin: 4px 0 16px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--tx-line);
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .1em;
	color: var(--tx-gold);
}
.tx-form .tx-form__legend:not(:first-child) { margin-top: 24px; }

.tx-grid { display: grid; gap: 0 18px; }
.tx-grid--3 { grid-template-columns: repeat(3, 1fr); }
.tx-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .tx-grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1000px) { .tx-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .tx-grid--3, .tx-grid--4 { grid-template-columns: 1fr; } }

.tx-form__actions {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--tx-line);
}
.tx-inline-form { margin: 0; }

/* ---------- Tables ---------- */
.tx-table { width: 100%; border-collapse: collapse; }
.tx-table th {
	text-align: left;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--tx-ink-2);
	padding: 0 12px 10px;
	border-bottom: 1px solid var(--tx-line);
	font-weight: 700;
	white-space: nowrap;
}
.tx-table td {
	padding: 13px 12px;
	border-bottom: 1px solid var(--tx-line);
	vertical-align: middle;
}
.tx-table tbody tr:last-child td { border-bottom: 0; }
.tx-table tbody tr:hover { background: #FBF8F2; }
.tx-table a { text-decoration: none; }
.tx-table a:hover { text-decoration: underline; }
.tx-right { text-align: right; }
.tx-center { text-align: center; }
.tx-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--tx-gold); font-weight: 700; }
.tx-sub { display: block; font-size: 12px; color: var(--tx-ink-2); font-weight: 400; }
.tx-stars { display: block; font-size: 12px; color: var(--tx-gold); letter-spacing: 1px; }
.tx-overdue, .tx-overdue .tx-sub { color: var(--tx-red); font-weight: 600; }

.tx-actions { white-space: nowrap; }
.tx-link { font-size: 12px; font-weight: 700; color: var(--tx-blue); text-decoration: none; margin-left: 12px; }
.tx-link:first-child { margin-left: 0; }
.tx-link:hover { text-decoration: underline; }
.tx-link--strong { color: var(--tx-gold); }
.tx-link--danger { color: var(--tx-red); }
.tx-status-select { min-width: 150px; }

.tx-subrow td { padding-top: 0; border-bottom: 1px solid var(--tx-line); }
.tx-subrow:hover { background: transparent; }
.tx-reset { display: flex; gap: 8px; }
.tx-reset input { max-width: 320px; }

/* ---------- Badges ---------- */
.tx-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	background: #EDE9E0;
	color: var(--tx-ink-2);
	white-space: nowrap;
}
.tx-badge--active, .tx-badge--completed, .tx-badge--converted, .tx-badge--paid {
	background: #E4F0E9; color: var(--tx-green);
}
.tx-badge--in_progress, .tx-badge--contacted, .tx-badge--interested, .tx-badge--review, .tx-badge--partial {
	background: var(--tx-blue-lt); color: var(--tx-blue);
}
.tx-badge--pending, .tx-badge--new, .tx-badge--follow_up, .tx-badge--quoted, .tx-badge--unpaid, .tx-badge--medium {
	background: var(--tx-gold-lt); color: #6E5417;
}
.tx-badge--high, .tx-badge--urgent, .tx-badge--blacklist, .tx-badge--cancelled,
.tx-badge--lost, .tx-badge--not_interested, .tx-badge--overdue {
	background: #F6E7E5; color: var(--tx-red);
}

/* ---------- Progress ---------- */
.tx-progress { width: 110px; height: 7px; background: #E8E3D9; border-radius: 999px; overflow: hidden; }
.tx-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--tx-blue), var(--tx-gold)); }

/* ---------- Timeline / details ---------- */
.tx-timeline { margin: 0; padding: 0; list-style: none; }
.tx-timeline li { border-left: 2px solid var(--tx-line); padding: 0 0 18px 16px; position: relative; }
.tx-timeline li:before {
	content: "";
	position: absolute;
	left: -6px; top: 6px;
	width: 10px; height: 10px;
	border-radius: 50%;
	background: var(--tx-gold);
}
.tx-timeline li:last-child { padding-bottom: 0; }
.tx-timeline__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tx-timeline p { margin: 6px 0 0; }

.tx-dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0 0 18px; }
.tx-dl dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--tx-ink-2); font-weight: 700; }
.tx-dl dd { margin: 0; }

.tx-callbtn {
	display: block;
	text-align: center;
	background: var(--tx-blue);
	color: #fff;
	font-weight: 700;
	padding: 13px;
	border-radius: 8px;
	text-decoration: none;
	margin-bottom: 18px;
}
.tx-callbtn:hover { background: var(--tx-blue-dk); }

/* ---------- Empty ---------- */
.tx-empty { text-align: center; padding: 44px 20px; }
.tx-empty h3 { margin-bottom: 6px; font-size: 17px; }
.tx-empty p { margin: 0 0 16px; color: var(--tx-ink-2); }
.tx-empty--small { padding: 22px 10px; }
.tx-empty--small p { margin: 0; }

.tx-quick__row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Invoice builder ---------- */
.tx-items td { padding: 8px; }
.tx-items input { margin-top: 0; }
.tx-items .tx-amount { font-weight: 700; color: var(--tx-blue); }
.tx-rowdel {
	background: transparent;
	border: 1px solid var(--tx-line);
	border-radius: 6px;
	width: 30px; height: 30px;
	color: var(--tx-red);
	font-size: 16px;
	cursor: pointer;
	line-height: 1;
}
.tx-rowdel:hover { background: #F6E7E5; }

.tx-invoice-summary {
	display: grid;
	grid-template-columns: 1fr 300px;
	gap: 24px;
	align-items: start;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--tx-line);
}
@media (max-width: 900px) { .tx-invoice-summary { grid-template-columns: 1fr; } }
.tx-totals { background: var(--tx-gold-lt); border-radius: var(--tx-radius); padding: 16px 18px; }
.tx-totals div { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.tx-totals__grand {
	border-top: 1px solid #E0CFA4;
	margin-top: 6px;
	padding-top: 10px;
	font-size: 16px;
	font-weight: 700;
	color: var(--tx-blue);
}

/* ---------- Footer ---------- */
.tx-footer {
	display: grid;
	grid-template-columns: 2fr 1fr 1.4fr 1.2fr;
	gap: 20px;
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-bottom: 3px solid var(--tx-gold);
	border-radius: var(--tx-radius);
	padding: 20px 22px;
	box-shadow: var(--tx-shadow);
}
@media (max-width: 900px) { .tx-footer { grid-template-columns: 1fr 1fr; } }
.tx-footer h4 { margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--tx-gold); }
.tx-footer a { color: var(--tx-blue); text-decoration: none; font-size: 13px; }
.tx-footer a:hover { text-decoration: underline; }
.tx-footer__mark { display: flex; align-items: center; gap: 10px; justify-content: flex-end; color: var(--tx-ink-2); font-size: 12px; }
.tx-footer__mark img { width: 38px; height: 38px; object-fit: contain; }

/* ---------- Login / setup ---------- */
.tx-auth {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: 30px 20px;
	background:
		radial-gradient(circle at 15% 15%, rgba(20,83,158,.07), transparent 45%),
		radial-gradient(circle at 85% 85%, rgba(169,130,44,.09), transparent 45%),
		var(--tx-canvas);
}
.tx-auth__card {
	width: 100%;
	max-width: 400px;
	background: var(--tx-paper);
	border: 1px solid var(--tx-line);
	border-top: 4px solid var(--tx-blue);
	border-radius: 14px;
	padding: 34px 32px;
	box-shadow: var(--tx-shadow);
	text-align: center;
}
.tx-auth__card--wide { max-width: 520px; text-align: left; }
.tx-auth__logo { width: 92px; height: 92px; object-fit: contain; margin-bottom: 10px; }
.tx-auth__card h1 { font-size: 22px; letter-spacing: .04em; text-transform: uppercase; color: var(--tx-blue); }
.tx-auth__lead { color: var(--tx-ink-2); font-size: 13px; margin: 6px 0 22px; }
.tx-auth__card .tx-form { text-align: left; }
.tx-auth__foot {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--tx-line);
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 12px;
}
.tx-auth__foot a { color: var(--tx-ink-2); text-decoration: none; }
.tx-auth__foot a:hover { color: var(--tx-gold); }

/* ---------- Printable invoice ---------- */
.tx-print-body { padding: 24px; }
.tx-print-bar { max-width: 850px; margin: 0 auto 16px; display: flex; gap: 14px; align-items: center; }
.tx-print-bar button {
	background: var(--tx-blue);
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 11px 20px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
}
.tx-print-bar a { color: var(--tx-gold); font-weight: 700; text-decoration: none; font-size: 13px; }

.tx-invoice {
	max-width: 850px;
	margin: 0 auto;
	background: #fff;
	border: 1px solid var(--tx-line);
	border-top: 5px solid var(--tx-blue);
	border-radius: var(--tx-radius);
	padding: 36px 40px;
	box-shadow: var(--tx-shadow);
}
.tx-invoice__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.tx-invoice__head img { width: 96px; height: 96px; object-fit: contain; }
.tx-invoice__meta { text-align: right; }
.tx-invoice__meta h1 { font-size: 30px; letter-spacing: .16em; text-transform: uppercase; color: var(--tx-blue); }
.tx-invoice__number { margin: 2px 0 8px; font-family: ui-monospace, Menlo, monospace; color: var(--tx-gold); font-weight: 700; }
.tx-invoice__meta p { margin: 0; }

.tx-invoice__parties {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 20px;
	margin: 28px 0;
	padding: 18px 0;
	border-top: 1px solid var(--tx-line);
	border-bottom: 1px solid var(--tx-line);
}
.tx-invoice__parties h3, .tx-invoice__notes h3 {
	margin-bottom: 6px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .1em;
	color: var(--tx-gold);
}
.tx-invoice__parties p { margin: 0; line-height: 1.6; font-size: 13px; }

.tx-invoice__items { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.tx-invoice__items th {
	background: var(--tx-blue);
	color: #fff;
	text-align: left;
	padding: 10px 12px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: .08em;
}
.tx-invoice__items th.tx-right { text-align: right; }
.tx-invoice__items td { padding: 11px 12px; border-bottom: 1px solid var(--tx-line); font-size: 13px; }

.tx-invoice__totals { margin-left: auto; width: 300px; }
.tx-invoice__totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.tx-invoice__grand {
	border-top: 2px solid var(--tx-gold);
	margin-top: 6px;
	padding-top: 10px;
	font-size: 17px;
	color: var(--tx-blue);
	font-weight: 700;
}
.tx-invoice__notes { margin-top: 28px; }
.tx-invoice__foot {
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 34px;
	padding-top: 16px;
	border-top: 1px solid var(--tx-line);
	font-size: 12px;
	color: var(--tx-ink-2);
}
.tx-invoice__foot a { color: var(--tx-blue); text-decoration: none; }

@media print {
	.tx-print-bar { display: none; }
	body { background: #fff; }
	.tx-print-body { padding: 0; }
	.tx-invoice { border: 0; box-shadow: none; max-width: none; padding: 0; }
	.tx-invoice__items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
	.tx-shell { flex-direction: column; }
	.tx-side {
		width: 100%;
		flex: none;
		height: auto;
		position: static;
		border-right: 0;
		border-bottom: 1px solid var(--tx-line);
	}
	.tx-nav { flex-direction: row; flex-wrap: wrap; }
	.tx-nav__item { border-left: 0; border-bottom: 3px solid transparent; }
	.tx-nav__item.is-active { border-bottom-color: var(--tx-gold); }
	.tx-side__user { display: flex; align-items: center; gap: 10px; }
	.tx-side__out { margin-top: 0; margin-left: auto; }
	.tx-main { padding: 18px 16px 28px; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}
