.tvm-calc-app {
	--tvm-orange: #f0782c;
	--tvm-orange-light: #fde8d7;
	--tvm-green: #16a34a;
	--tvm-blue: #2563eb;
	--tvm-purple: #9333ea;
	--tvm-dark: #1f2328;
	--tvm-gray: #6b7280;
	--tvm-border: #e5e7eb;
	--tvm-bg: #f7f7f8;
	--tvm-card-bg: #ffffff;

	background: var(--tvm-bg);
	border-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--tvm-dark);
	box-sizing: border-box;
}
.tvm-calc-app *,
.tvm-calc-app *::before,
.tvm-calc-app *::after {
	box-sizing: border-box;
}

/* Header */
.tvm-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}
.tvm-header-left {
	display: flex;
	gap: 14px;
	align-items: flex-start;
}
.tvm-header-icon {
	background: var(--tvm-orange);
	color: #fff;
	width: 44px;
	height: 44px;
	min-width: 44px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.tvm-title {
	font-size: 22px;
	font-weight: 700;
	margin: 0 0 4px;
	line-height: 1.25;
}
.tvm-subtitle {
	font-size: 13.5px;
	color: var(--tvm-gray);
	margin: 0;
}

/* Buttons */
.tvm-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 600;
	padding: 10px 18px;
	border-radius: 8px;
	border: 1px solid transparent;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, opacity .15s ease;
	white-space: nowrap;
}
.tvm-btn-ghost {
	background: #fff;
	color: var(--tvm-dark);
	border-color: var(--tvm-border);
}
.tvm-btn-ghost:hover { background: #f3f4f6; }
.tvm-btn-primary {
	background: var(--tvm-orange);
	color: #fff;
	flex: 1;
}
.tvm-btn-primary:hover { background: #e06b1e; }
.tvm-btn-secondary {
	background: #f1f1f2;
	color: #9aa0a6;
}
.tvm-btn-outline {
	background: #fff;
	border-color: var(--tvm-border);
	color: var(--tvm-dark);
	width: 100%;
	justify-content: center;
}
.tvm-btn-outline:hover { background: #f3f4f6; }

/* Grid layout */
.tvm-grid {
	display: grid;
	grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}
@media (max-width: 900px) {
	.tvm-grid { grid-template-columns: minmax(0, 1fr); }
}

.tvm-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* Card */
.tvm-card {
	background: var(--tvm-card-bg);
	border: 1px solid var(--tvm-border);
	border-radius: 12px;
	padding: 22px;
	min-width: 0;
}
.tvm-card-title {
	font-size: 16px;
	font-weight: 700;
	margin: 0 0 16px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.tvm-help {
	width: 16px;
	height: 16px;
	font-size: 11px;
	border-radius: 50%;
	border: 1px solid var(--tvm-orange);
	color: var(--tvm-orange);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: help;
	font-weight: 700;
}

/* Result banner */
.tvm-result-banner {
	background: var(--tvm-orange-light);
	border-radius: 10px;
	padding: 18px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 18px;
}
.tvm-result-label {
	font-size: 15px;
	font-weight: 700;
	color: #4a4a4a;
}
.tvm-result-value {
	font-size: 26px;
	font-weight: 700;
	color: var(--tvm-orange);
}

.tvm-field-label {
	font-size: 13.5px;
	color: var(--tvm-dark);
	margin: 0 0 10px;
}

/* Tabs */
.tvm-tabs {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 8px;
	margin-bottom: 20px;
}
.tvm-tab {
	padding: 9px 4px;
	border-radius: 8px;
	border: none;
	background: #eeeef0;
	color: #55585d;
	font-weight: 600;
	font-size: 13.5px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.tvm-tab:hover { background: #e2e2e5; }
.tvm-tab.active {
	background: var(--tvm-orange);
	color: #fff;
}

/* Fields */
.tvm-field {
	margin-bottom: 14px;
}
.tvm-field label {
	display: block;
	font-size: 13.5px;
	font-weight: 500;
	margin-bottom: 6px;
	color: var(--tvm-dark);
}
.tvm-field input[type="number"] {
	width: 100%;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid var(--tvm-border);
	font-size: 14px;
	background: #fff;
	color: var(--tvm-dark);
}
.tvm-field input[type="number"]:focus {
	outline: none;
	border-color: var(--tvm-orange);
	box-shadow: 0 0 0 3px rgba(240,120,44,0.15);
}
.tvm-field.tvm-field-disabled input {
	background: #f3f4f6;
	color: #b0b3b8;
	cursor: not-allowed;
}

.tvm-radio-group {
	display: flex;
	gap: 20px;
	flex-wrap: wrap;
	padding-top: 2px;
}
.tvm-radio {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13.5px;
	font-weight: 500;
	cursor: pointer;
}
.tvm-radio input { accent-color: var(--tvm-orange); }

.tvm-actions {
	display: flex;
	gap: 10px;
	margin-top: 18px;
}

.tvm-error {
	color: #dc2626;
	font-size: 13px;
	margin-top: 12px;
}

/* Formulas card */
.tvm-formulas-toggle,
.tvm-calc-app button.tvm-formulas-toggle {
	width: 100%;
	background: transparent !important;
	background-color: transparent !important;
	border: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: pointer;
	padding: 0;
	color: var(--tvm-dark) !important;
}
.tvm-formulas-toggle .tvm-card-title,
.tvm-formulas-toggle .tvm-chevron {
	color: var(--tvm-dark) !important;
}
.tvm-formulas-toggle .tvm-card-title { margin-bottom: 0; }
.tvm-chevron {
	color: var(--tvm-gray) !important;
	transition: transform .2s ease;
	font-size: 12px;
}
.tvm-chevron.tvm-collapsed { transform: rotate(180deg); }
.tvm-formulas-body {
	margin-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.tvm-formula-intro { font-size: 13.5px; color: var(--tvm-gray); margin: 0 0 4px; line-height: 1.5; }
.tvm-formula-legend { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tvm-formula-legend li { font-size: 13px; color: var(--tvm-dark); }
.tvm-formula-legend strong { color: var(--tvm-orange); font-style: italic; }
.tvm-formula-row {
	background: #f6f6f7;
	border-radius: 6px;
	padding: 12px 14px;
	font-size: 14px;
	color: #3a3d42;
	overflow-x: auto;
}
.tvm-formula-row .katex { font-size: 1.05em; }
.tvm-formula-note {
	color: var(--tvm-gray) !important;
	font-size: 12px;
	line-height: 1.5;
	margin: 4px 0 0;
}

/* Timeline */
.tvm-timeline-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.tvm-icon-btn {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	border: 1px solid var(--tvm-border);
	background: #fff;
	cursor: pointer;
	color: var(--tvm-gray);
	display: flex;
	align-items: center;
	justify-content: center;
}
.tvm-timeline {
	position: relative;
	min-height: 260px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 0;
}
.tvm-timeline-empty {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--tvm-gray);
	font-size: 14px;
}
.tvm-timeline-empty[hidden] {
	display: none;
}
.tvm-timeline-canvas-wrap {
	width: 100%;
	position: relative;
	height: 260px;
	overflow-x: auto;
	overflow-y: hidden;
}
.tvm-timeline-canvas-inner {
	height: 100%;
	min-width: 100%;
}
.tvm-timeline-canvas-wrap canvas {
	width: 100% !important;
	height: 100% !important;
}
.tvm-legend {
	display: flex;
	gap: 22px;
	justify-content: center;
	margin-top: 14px;
	font-size: 13px;
	color: var(--tvm-dark);
}
.tvm-legend-item { display: flex; align-items: center; gap: 6px; }
.tvm-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tvm-dot-orange { background: var(--tvm-orange); }
.tvm-dot-green { background: var(--tvm-green); }

/* Table */
.tvm-table-wrap { position: relative; min-height: 220px; overflow-x: auto; }
.tvm-table { white-space: nowrap; }
.tvm-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13.5px;
}
.tvm-table thead th {
	text-align: left;
	padding: 10px 12px;
	background: #f6f6f7;
	color: #55585d;
	font-weight: 600;
	border-bottom: 1px solid var(--tvm-border);
}
.tvm-table tbody td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--tvm-border);
}
.tvm-table-wrap.has-data .tvm-schedule-empty { display: none; }
.tvm-table-wrap:not(.has-data) .tvm-table { display: none; }

.tvm-schedule-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 50px 20px;
	color: var(--tvm-gray);
}
.tvm-schedule-empty-icon { font-size: 26px; margin-bottom: 10px; opacity: .6; }
.tvm-schedule-empty-title { font-weight: 600; color: var(--tvm-dark); margin: 0 0 4px; }
.tvm-schedule-empty-sub { font-size: 13px; margin: 0; }

.tvm-export-wrap { margin-top: 16px; }

/* Summary */
.tvm-summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 12px;
}
.tvm-summary-item {
	border: 1px solid var(--tvm-border);
	border-radius: 10px;
	padding: 14px;
	text-align: center;
}
.tvm-summary-label { font-size: 12.5px; color: var(--tvm-gray); margin: 0 0 6px; }
.tvm-summary-value { font-size: 17px; font-weight: 700; margin: 0; }
.tvm-color-orange { color: var(--tvm-orange); }
.tvm-color-green { color: var(--tvm-green); }
.tvm-color-blue { color: var(--tvm-blue); }
.tvm-color-purple { color: var(--tvm-purple); }
.tvm-color-dark { color: var(--tvm-dark); }

.tvm-footnote {
	text-align: center;
	font-size: 12.5px;
	color: var(--tvm-gray);
	margin-top: 24px;
}

.tvm-report-wrap {
	display: flex;
	justify-content: center;
	margin-top: 16px;
}
.tvm-btn-report {
	background: #fff;
	color: var(--tvm-gray) !important;
	border: 1px solid var(--tvm-border);
	text-decoration: none;
}
.tvm-btn-report:hover {
	background: #f9f4f0;
	color: var(--tvm-orange) !important;
	border-color: var(--tvm-orange);
}

/* Responsive tweaks */
@media (max-width: 640px) {
	.tvm-tabs { grid-template-columns: repeat(3, 1fr); }
	.tvm-actions { flex-direction: column; }
	.tvm-header { flex-direction: column; }
	.tvm-btn-ghost { align-self: flex-start; }
	.tvm-result-value { font-size: 22px; }
	.tvm-table { font-size: 12px; }
	.tvm-table thead th, .tvm-table tbody td { padding: 8px 6px; }
}
