/* İMO Proje ve Fenni Mesuliyet Hizmet Bedeli Hesaplama - md-t.org */

:root {
	--bg: #f2f5f9;
	--surface: #ffffff;
	--ink: #1b2430;
	--ink-2: #344054;
	--muted: #667085;
	--faint: #98a2b3;
	--line: #e3e8ef;
	--line-2: #cfd6e0;
	--brand: #0b3f70;
	--brand-2: #1769c2;
	--brand-soft: #eef5fd;
	--chip: #eef2f7;
	--danger: #b42318;
	--danger-soft: #fef3f2;
	--radius: 14px;
	--radius-sm: 10px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .05);
	--c1: #1769c2;
	--c2: #0f9d8a;
	--c3: #e08a00;
	--c4: #c2416b;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

.wrap {
	max-width: 1240px;
	margin: 0 auto;
	padding: 0 16px;
}

/* ------------------------------------------------------------ üst bant */

.topbar {
	background: linear-gradient(135deg, #0b3f70 0%, #1769c2 100%);
	color: #fff;
	padding: 18px 0;
}

.topbar-in {
	display: flex;
	align-items: center;
	gap: 16px;
}

/* imologo.png köşeleri saydam değil beyaz; logonun kendi köşe yuvarlaklığıyla (213 px'te ~41 px) kırpılır */
.logo {
	flex: none;
	display: block;
	border-radius: 19%;
}

.brand { min-width: 0; }

.org {
	font-size: 12.5px;
	font-weight: 600;
	letter-spacing: .05em;
	opacity: .85;
}

.org span::before {
	content: "·";
	margin: 0 .5em;
}

.brand h1 {
	margin: 2px 0 0;
	font-size: 21px;
	font-weight: 650;
	line-height: 1.25;
}

.devs {
	margin-left: auto;
	text-align: right;
	font-size: 12.5px;
	opacity: .9;
}

.devs b { font-weight: 600; }

/* ------------------------------------------------------------ yerleşim */

.layout {
	display: grid;
	grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
	margin-top: 20px;
	margin-bottom: 20px;
}

.results,
#sonuc {
	display: grid;
	gap: 20px;
	align-content: start;
	min-width: 0;
}

/* hesap yapılınca sonuç, yapı grubu açıklamasının üstüne çıkar */
#sonuc { order: -1; }

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 18px 20px;
	min-width: 0;
}

.card-title {
	margin: 0 0 14px;
	font-size: 17px;
	font-weight: 650;
}

.card-sub {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 650;
}

.card-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.card-head .card-title { margin-bottom: 2px; }

.meta {
	font-size: 13px;
	color: var(--muted);
}

.meta b { color: var(--ink-2); font-weight: 600; }

.twocol {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
}

/* ------------------------------------------------------------ form */

fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.field { margin: 0 0 14px; }

.field > label,
.field > legend {
	display: block;
	padding: 0;
	margin: 0 0 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ink-2);
}

legend small {
	font-weight: 400;
	color: var(--muted);
}

select,
input[type="text"] {
	display: block;
	width: 100%;
	height: 42px;
	padding: 0 12px;
	border: 1px solid var(--line-2);
	border-radius: var(--radius-sm);
	background: #fff;
	color: var(--ink);
	font: inherit;
	transition: border-color .15s, box-shadow .15s;
}

select {
	appearance: none;
	padding-right: 36px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 13px center;
	cursor: pointer;
}

select:disabled {
	background-color: #f5f7fa;
	color: var(--faint);
	cursor: not-allowed;
}

select:focus,
input[type="text"]:focus {
	outline: none;
	border-color: var(--brand-2);
	box-shadow: 0 0 0 3px rgba(23, 105, 194, .18);
}

.unit { position: relative; }

.unit input { padding-right: 40px; }

.unit span {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--muted);
	font-size: 14px;
	pointer-events: none;
}

.grid3 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
	gap: 0 10px;
}

/* bölümlü seçim düğmeleri */
.seg {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 4px;
	background: var(--chip);
	border-radius: 11px;
}

.seg input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.seg label {
	flex: 1 1 0;
	min-width: max-content;
	padding: 8px 10px;
	border-radius: 8px;
	text-align: center;
	font-size: 14px;
	font-weight: 500;
	color: #475467;
	cursor: pointer;
	user-select: none;
	transition: background .15s, color .15s, box-shadow .15s;
}

.seg label:hover { color: var(--ink); }

.seg input:checked + label {
	background: #fff;
	color: var(--brand-2);
	font-weight: 600;
	box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

.seg input:focus-visible + label {
	outline: 2px solid var(--brand-2);
	outline-offset: 1px;
}

/* seçenek kartları */
.opts {
	display: grid;
	gap: 6px;
}

.opt {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border: 1px solid #dfe5ee;
	border-radius: var(--radius-sm);
	background: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: border-color .15s, background .15s;
}

.opt:hover { border-color: var(--line-2); }

.opt input {
	flex: none;
	width: 17px;
	height: 17px;
	margin: 0;
	accent-color: var(--brand-2);
}

.opt:has(input:checked) {
	border-color: var(--brand-2);
	background: var(--brand-soft);
}

.opt:has(input:focus-visible) {
	outline: 2px solid var(--brand-2);
	outline-offset: 1px;
}

.subpanel {
	margin: 0 0 14px;
	padding-left: 12px;
	border-left: 3px solid #d6e4f5;
}

.subpanel .field:last-child { margin-bottom: 0; }

.alert {
	margin: 0 0 12px;
	padding: 10px 12px;
	border: 1px solid #fecdca;
	border-radius: var(--radius-sm);
	background: var(--danger-soft);
	color: var(--danger);
	font-size: 14px;
	font-weight: 500;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border-radius: var(--radius-sm);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s, border-color .15s, opacity .15s;
}

.btn.primary {
	width: 100%;
	height: 46px;
	border: 0;
	background: var(--brand-2);
	color: #fff;
	font-size: 15.5px;
}

.btn.primary:hover { background: #125aa8; }

.btn.primary:focus-visible {
	outline: 3px solid rgba(23, 105, 194, .35);
	outline-offset: 2px;
}

.btn:disabled {
	opacity: .55;
	cursor: default;
}

.btn.ghost {
	flex: none;
	height: 38px;
	padding: 0 14px;
	border: 1px solid var(--line-2);
	background: #fff;
	color: var(--ink-2);
	font-size: 14px;
}

.btn.ghost:hover { border-color: var(--brand-2); color: var(--brand-2); }

/* ------------------------------------------------------------ yapı grubu açıklaması */

.info {
	max-height: 330px;
	overflow: auto;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--ink-2);
}

.info h3 {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 650;
	letter-spacing: .02em;
	color: var(--brand);
}

.info p { margin: 0; }

.info hr {
	margin: 14px 0;
	border: 0;
	border-top: 1px solid var(--line);
}

.placeholder {
	padding: 14px 6px;
	text-align: center;
	color: var(--muted);
}

/* ------------------------------------------------------------ sonuç */

.kpis {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.kpi {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px;
	border: 1px solid #e1e9f4;
	border-top: 3px solid var(--c1);
	border-radius: 12px;
	background: #f7faff;
}

.kpi:nth-child(2) { border-top-color: var(--c2); }
.kpi:nth-child(3) { border-top-color: var(--c3); }
.kpi:nth-child(4) { border-top-color: var(--c4); }

.kpi-label {
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
}

.kpi strong {
	font-size: 21px;
	font-weight: 700;
	color: var(--brand);
	font-variant-numeric: tabular-nums;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.kpi small {
	font-size: 12px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

/* "Net …" ve "KDV …" tutarlarıyla birlikte bölünmeden kalır */
.kpi small .nw { white-space: nowrap; }

.kv {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	margin: 0;
	font-size: 14px;
}

.kv dt,
.kv dd {
	margin: 0;
	padding: 6px 0;
	border-bottom: 1px solid #eef1f5;
}

.kv dt {
	padding-right: 14px;
	color: var(--muted);
	font-weight: 500;
}

.kv dt small {
	display: block;
	font-size: 11.5px;
	font-weight: 400;
	color: var(--faint);
	line-height: 1.3;
}

.kv dd {
	text-align: right;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.kv dt:nth-last-of-type(1),
.kv dd:nth-last-of-type(1) { border-bottom: 0; }

.formulas {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.formulas li {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 4px 12px;
	font-size: 13.5px;
}

.formulas b { font-weight: 600; color: var(--ink-2); }

.formulas code {
	padding: 3px 8px;
	border-radius: 6px;
	background: #f3f6fa;
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
	font-size: 12.5px;
	color: var(--ink);
}

.note {
	margin: 12px 0 0;
	padding: 8px 10px;
	border-radius: 8px;
	background: #fff8e6;
	color: #8a5a00;
	font-size: 13px;
}

.chart-card { padding: 10px 10px 6px; }

#grafik {
	width: 100%;
	height: 400px;
}

/* ------------------------------------------------------------ alt bilgi */

.footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 4px 16px;
	padding-top: 4px;
	padding-bottom: 28px;
	font-size: 12.5px;
	color: var(--muted);
}

.print-only { display: none; }

/* Baskı grafiği ekranda görünmez; yazı ölçüleri doğru çıksın diye ekran dışında çizilir.
   Ölçü js/imo.js BASKI ile aynı: A4 dikey sayfada grafik kartının iç ölçüsü. */
.print-chart {
	position: absolute;
	top: 0;
	left: -10000px;
	width: 690px;
	height: 240px;
	visibility: hidden;
	pointer-events: none;
}

/* ------------------------------------------------------------ duyarlı */

@media (max-width: 1100px) {
	.twocol { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
	.layout { grid-template-columns: minmax(0, 1fr); }
	.topbar-in { flex-wrap: wrap; }
	.devs {
		width: 100%;
		margin-left: 0;
		text-align: left;
		padding-left: 72px;
	}
}

@media (max-width: 520px) {
	body { font-size: 14.5px; }
	.topbar { padding: 14px 0; }
	.logo { width: 46px; height: 46px; }
	.brand h1 { font-size: 17px; }
	.devs { padding-left: 0; }
	.card { padding: 16px; }
	.seg label { font-size: 13.5px; padding: 8px 6px; }
	.card-head { flex-wrap: wrap; }
	#grafik { height: 340px; }
}

@media (max-width: 480px) {
	.kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ yazdırma (A4) */

@page {
	size: A4 portrait;
	margin: 12mm 12mm 14mm;
}

@media print {
	html,
	body { background: #fff; }

	body {
		color: #000;
		font-size: 10pt;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.wrap {
		max-width: none;
		padding: 0;
	}

	.topbar {
		background: none;
		color: #000;
		padding: 0 0 8px;
		border-bottom: 2px solid var(--brand);
	}

	.logo {
		width: 40px;
		height: 40px;
	}

	.org { color: var(--brand); opacity: 1; }
	.brand h1 { font-size: 15pt; }

	.devs,
	#hesapform,
	#yapibilgi,
	#yazdir { display: none !important; }

	.layout {
		display: block;
		margin: 8px 0 0;
	}

	.results,
	#sonuc { display: block; }

	.card {
		margin: 0 0 7px;
		padding: 8px 12px;
		border: 1px solid var(--line-2);
		border-radius: 8px;
		box-shadow: none;
		break-inside: avoid;
		page-break-inside: avoid;
	}

	.card-title { font-size: 12.5pt; }
	.card-sub { font-size: 10.5pt; margin-bottom: 4px; }
	.card-head { margin-bottom: 8px; }
	.meta { font-size: 9pt; }

	.kpis {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 6px;
	}

	.kpi { padding: 7px 8px; gap: 2px; }
	.kpi-label { font-size: 8pt; }
	.kpi strong { font-size: 11.5pt; }
	.kpi small { font-size: 7.5pt; }
	.kpi small .nw { display: block; }
	.kpi small .sep { display: none; }

	.twocol {
		grid-template-columns: 1fr 1fr;
		gap: 8px;
		margin-bottom: 8px;
	}

	.twocol .card { margin: 0; }

	.kv { font-size: 8.5pt; }
	.kv dt,
	.kv dd { padding: 1px 0; }
	.kv dt small { display: inline; font-size: 7pt; margin-left: 4px; }

	.formulas { gap: 3px; }
	.formulas li { font-size: 8.5pt; }
	.formulas code { font-size: 8pt; padding: 1px 6px; }
	.note { font-size: 8.5pt; margin-top: 6px; padding: 4px 8px; }

	.chart-card { padding: 4px; }
	#grafik { display: none !important; }

	.print-chart {
		position: static;
		width: auto;
		height: auto;
		visibility: visible;
	}

	.print-chart .highcharts-container,
	.print-chart svg {
		width: 100% !important;
		height: auto !important;
	}

	.print-chart svg { display: block; }

	.footer {
		gap: 2px 10px;
		margin-top: 6px;
		padding: 6px 0 0;
		border-top: 1px solid var(--line-2);
		font-size: 7pt;
		color: #444;
	}

	.print-only { display: block; }

	a { color: inherit; text-decoration: none; }
}
