/* Геотехнический расчет уголковой подпорной стены — стили интерфейса.
   Все правила изолированы внутри .grw-app, чтобы не конфликтовать с темой WordPress. */

.grw-app {
	--grw-bg: #f4f6f8;
	--grw-surface: #ffffff;
	--grw-surface-2: #f8fafb;
	--grw-ink: #18222b;
	--grw-ink-2: #46535e;
	--grw-muted: #6b7782;
	--grw-line: #dde3e8;
	--grw-line-2: #c9d2da;
	--grw-accent: #1f5f7a;
	--grw-accent-2: #164a60;
	--grw-accent-soft: #e6f0f4;
	--grw-ok: #1d7a46;
	--grw-ok-soft: #e5f4eb;
	--grw-warn: #a35d00;
	--grw-warn-soft: #fff3df;
	--grw-bad: #b42318;
	--grw-bad-soft: #fdecea;
	--grw-radius: 12px;
	--grw-radius-sm: 8px;
	--grw-shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 4px 16px rgba(16, 24, 32, .05);
	--grw-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--grw-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

	box-sizing: border-box;
	max-width: 1320px;
	margin: 20px auto;
	background: var(--grw-bg);
	border: 1px solid var(--grw-line);
	border-radius: 16px;
	color: var(--grw-ink);
	font-family: var(--grw-font);
	font-size: 15px;
	line-height: 1.45;
	text-align: left;
	overflow: hidden;
	-webkit-text-size-adjust: 100%;
}
.grw-app *, .grw-app *::before, .grw-app *::after { box-sizing: border-box; }
.grw-app p, .grw-app ul, .grw-app li { margin: 0; padding: 0; border: 0; letter-spacing: normal; text-transform: none; }
.grw-app sub { font-size: .72em; line-height: 0; vertical-align: -.25em; }
.grw-app [hidden] { display: none !important; }

/* ---------- Шапка ---------- */
.grw-head {
	display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
	padding: 18px 24px;
	background: linear-gradient(135deg, #16232d 0%, #1f3a4a 100%);
	color: #fff;
}
.grw-app .grw-head__title { font-size: 1.3rem; font-weight: 700; color: #fff; line-height: 1.25; font-family: var(--grw-font); }
.grw-app .grw-head__sub { margin-top: 3px; font-size: .86rem; color: #b8c7d2; }

.grw-status {
	display: inline-flex; align-items: center; gap: 8px;
	padding: 7px 14px; border-radius: 999px;
	background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18);
	font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap;
}
.grw-status__dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa9b5; flex: none; }
.grw-app[data-state="ok"] .grw-status__dot { background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .25); }
.grw-app[data-state="fail"] .grw-status__dot { background: #ff6b5e; box-shadow: 0 0 0 3px rgba(255, 107, 94, .25); }
.grw-app[data-state="busy"] .grw-status__dot { background: #ffd166; animation: grw-pulse 1s infinite; }
.grw-app[data-state="stale"] .grw-status__dot { background: #ffd166; }
@keyframes grw-pulse { 50% { opacity: .35; } }

/* ---------- Сетка ---------- */
.grw-layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); align-items: start; }

/* ---------- Ввод ---------- */
.grw-inputs {
	padding: 16px; display: flex; flex-direction: column; gap: 10px;
	border-right: 1px solid var(--grw-line); background: var(--grw-bg); margin: 0;
}
.grw-group {
	background: var(--grw-surface); border: 1px solid var(--grw-line); border-radius: var(--grw-radius);
	box-shadow: var(--grw-shadow); overflow: hidden;
}
.grw-group > summary {
	list-style: none; cursor: pointer; user-select: none;
	display: flex; align-items: center; gap: 10px;
	padding: 12px 14px; font-weight: 650; font-size: .95rem; color: var(--grw-ink);
}
.grw-group > summary::-webkit-details-marker { display: none; }
.grw-group > summary::after {
	content: ""; margin-left: auto; width: 8px; height: 8px;
	border-right: 2px solid var(--grw-muted); border-bottom: 2px solid var(--grw-muted);
	transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.grw-group[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.grw-group > summary:focus-visible { outline: 2px solid var(--grw-accent); outline-offset: -2px; }
.grw-group__num {
	display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
	background: var(--grw-accent-soft); color: var(--grw-accent); font-size: .8rem; font-weight: 700;
}
.grw-group__body {
	display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px;
	padding: 4px 14px 16px; border-top: 1px solid var(--grw-line); padding-top: 14px;
}

.grw-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.grw-field--wide { grid-column: 1 / -1; }
.grw-app .grw-field__label { font-size: .8rem; font-weight: 600; color: var(--grw-ink-2); line-height: 1.3; margin: 0; }
.grw-field__hint { font-size: .72rem; color: var(--grw-muted); min-height: 1em; font-variant-numeric: tabular-nums; }
.grw-field.is-clamped .grw-field__hint { color: var(--grw-warn); font-weight: 600; }

.grw-input { position: relative; display: flex; align-items: center; }
.grw-app .grw-input input,
.grw-app .grw-select select {
	width: 100%; height: 40px; margin: 0;
	padding: 0 10px; border: 1px solid var(--grw-line-2); border-radius: var(--grw-radius-sm);
	background: var(--grw-surface); color: var(--grw-ink);
	font: 600 15px/1 var(--grw-font); font-variant-numeric: tabular-nums;
	box-shadow: none; outline: none; transition: border-color .15s, box-shadow .15s;
	-webkit-appearance: none; appearance: none;
}
.grw-app .grw-input input { padding-right: 52px; }
.grw-input__unit {
	position: absolute; right: 10px; font-size: .75rem; color: var(--grw-muted); pointer-events: none; font-weight: 500;
}
.grw-select { position: relative; }
.grw-select::after {
	content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
	border-right: 2px solid var(--grw-muted); border-bottom: 2px solid var(--grw-muted); transform: rotate(45deg); pointer-events: none;
}
.grw-app .grw-select select { padding-right: 32px; font-weight: 500; font-size: 14px; text-overflow: ellipsis; cursor: pointer; }
.grw-app .grw-input input:hover, .grw-app .grw-select select:hover { border-color: #a9b6c1; }
.grw-app .grw-input input:focus, .grw-app .grw-select select:focus {
	border-color: var(--grw-accent); box-shadow: 0 0 0 3px rgba(31, 95, 122, .18);
}

/* Переключатель */
.grw-switch { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .84rem; color: var(--grw-ink-2); margin: 2px 0 0; }
.grw-switch { position: relative; }
.grw-switch input { position: absolute; left: 0; top: 0; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.grw-switch__track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px; background: #c3ccd4; transition: background .2s; }
.grw-switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.grw-switch input:checked + .grw-switch__track { background: var(--grw-accent); }
.grw-switch input:checked + .grw-switch__track::after { transform: translateX(16px); }
.grw-switch input:focus-visible + .grw-switch__track { box-shadow: 0 0 0 3px rgba(31, 95, 122, .25); }

/* ---------- Кнопки ---------- */
.grw-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 4px; }
.grw-app .grw-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	height: 44px; padding: 0 18px; margin: 0; border-radius: var(--grw-radius-sm);
	font: 650 15px/1 var(--grw-font); letter-spacing: 0; text-transform: none; text-decoration: none;
	cursor: pointer; border: 1px solid transparent; box-shadow: none; transition: background .15s, border-color .15s, opacity .15s;
}
.grw-app .grw-btn--primary { background: var(--grw-accent); color: #fff; }
.grw-app .grw-btn--primary:hover { background: var(--grw-accent-2); color: #fff; }
.grw-app .grw-btn--ghost { background: var(--grw-surface); color: var(--grw-ink-2); border-color: var(--grw-line-2); }
.grw-app .grw-btn--ghost:hover { background: var(--grw-surface-2); color: var(--grw-ink); }
.grw-app .grw-btn--sm { height: 36px; padding: 0 14px; font-size: 14px; }
.grw-app .grw-btn:focus-visible { outline: 2px solid var(--grw-accent); outline-offset: 2px; }
.grw-app .grw-btn[disabled] { opacity: .7; cursor: progress; }
.grw-btn__spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: grw-spin .7s linear infinite; }
.grw-app[data-state="busy"] .grw-btn__spinner { display: inline-block; }
@keyframes grw-spin { to { transform: rotate(360deg); } }

/* ---------- Результаты ---------- */
.grw-results { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grw-card {
	background: var(--grw-surface); border: 1px solid var(--grw-line); border-radius: var(--grw-radius);
	box-shadow: var(--grw-shadow); padding: 16px; min-width: 0;
}
.grw-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grw-app .grw-card__title { font-size: 1rem; font-weight: 700; color: var(--grw-ink); line-height: 1.3; font-family: var(--grw-font); }
.grw-card--details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
.grw-card--details > summary::-webkit-details-marker { display: none; }
.grw-card--details > summary::after {
	content: ""; margin-left: auto; width: 8px; height: 8px;
	border-right: 2px solid var(--grw-muted); border-bottom: 2px solid var(--grw-muted); transform: rotate(45deg); transition: transform .2s;
}
.grw-card--details[open] > summary { margin-bottom: 12px; }
.grw-card--details[open] > summary::after { transform: rotate(-135deg); }
.grw-app .grw-empty { color: var(--grw-muted); font-size: .9rem; padding: 6px 0; }

.grw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.grw-app .grw-chip {
	display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; margin: 0;
	border-radius: 999px; border: 1px solid var(--grw-line-2); background: var(--grw-surface);
	font: 500 13px/1 var(--grw-font); color: var(--grw-ink-2); cursor: pointer; user-select: none; text-transform: none;
}
.grw-app .grw-chip { position: relative; }
.grw-chip input { position: absolute; left: 0; top: 0; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.grw-app .grw-chip:has(input:checked) { background: var(--grw-accent-soft); border-color: #9ec0cf; color: var(--grw-accent-2); }
.grw-app .grw-chip:has(input:focus-visible) { outline: 2px solid var(--grw-accent); outline-offset: 1px; }
.grw-app .grw-chip--btn:hover { background: var(--grw-surface-2); }

.grw-canvas-wrap {
	position: relative; width: 100%; aspect-ratio: 16 / 10; min-height: 260px; max-height: 560px;
	border: 1px solid var(--grw-line); border-radius: var(--grw-radius-sm); overflow: hidden; background: #fff;
}
.grw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.grw-canvas:active { cursor: grabbing; }
.grw-app .grw-hint { margin-top: 8px; font-size: .75rem; color: var(--grw-muted); }

.grw-stale {
	padding: 10px 14px; border-radius: var(--grw-radius-sm);
	background: var(--grw-warn-soft); color: var(--grw-warn); border: 1px solid #f3d29a; font-size: .86rem; font-weight: 600;
}
.grw-alerts:empty { display: none; }
.grw-alert { padding: 10px 14px; border-radius: var(--grw-radius-sm); font-size: .86rem; background: var(--grw-warn-soft); color: #6d3f00; border: 1px solid #f3d29a; }
.grw-alert + .grw-alert { margin-top: 6px; }
.grw-alert--bad { background: var(--grw-bad-soft); color: var(--grw-bad); border-color: #f5c2bd; }
.grw-app.is-stale .grw-checks, .grw-app.is-stale .grw-rc, .grw-app.is-stale [data-out="details"] { opacity: .45; filter: grayscale(.4); }

/* Проверки */
.grw-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.grw-check {
	border: 1px solid var(--grw-line); border-radius: var(--grw-radius-sm); padding: 12px; background: var(--grw-surface-2);
	display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.grw-check__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.grw-check__name { font-size: .84rem; font-weight: 650; color: var(--grw-ink-2); line-height: 1.3; }
.grw-check__value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--grw-ink); line-height: 1.15; }
.grw-check__value small { font-size: .78rem; font-weight: 500; color: var(--grw-muted); margin-left: 4px; }
.grw-check__sub { font-size: .76rem; color: var(--grw-muted); font-variant-numeric: tabular-nums; }

.grw-badge {
	display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
	font-size: .72rem; font-weight: 700; white-space: nowrap; flex: none;
}
.grw-badge--ok { background: var(--grw-ok-soft); color: var(--grw-ok); }
.grw-badge--bad { background: var(--grw-bad-soft); color: var(--grw-bad); }

.grw-bar { position: relative; height: 6px; border-radius: 999px; background: #e3e8ed; overflow: hidden; }
.grw-bar__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--grw-ok); transition: width .4s ease; }
.grw-bar__fill.is-warn { background: #d98c00; }
.grw-bar__fill.is-bad { background: var(--grw-bad); }

/* Железобетон */
.grw-rc { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.grw-sec { border: 1px solid var(--grw-line); border-radius: var(--grw-radius-sm); overflow: hidden; background: var(--grw-surface); }
.grw-sec__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--grw-surface-2); border-bottom: 1px solid var(--grw-line); }
.grw-sec__name { font-weight: 700; font-size: .9rem; }
.grw-sec__name span { display: block; font-weight: 500; font-size: .74rem; color: var(--grw-muted); }
.grw-sec__rebar { padding: 12px 12px 4px; font-size: 1.4rem; font-weight: 750; color: var(--grw-accent-2); font-variant-numeric: tabular-nums; }
.grw-sec__rebar small { display: block; font-size: .75rem; font-weight: 500; color: var(--grw-muted); margin-top: 2px; }
.grw-sec__rows { padding: 6px 12px 12px; }
.grw-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--grw-line); font-size: .82rem; }
.grw-row:last-child { border-bottom: 0; }
.grw-row__k { color: var(--grw-ink-2); }
.grw-row__v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.grw-row__v.is-bad { color: var(--grw-bad); }
.grw-row__v.is-ok { color: var(--grw-ok); }

/* Промежуточные результаты */
.grw-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; }
.grw-app .grw-kv__h { grid-column: 1 / -1; margin: 10px 0 4px; font-size: .8rem; font-weight: 700; color: var(--grw-accent); text-transform: uppercase; letter-spacing: .04em; }
.grw-app .grw-kv__h:first-child { margin-top: 0; }
.grw-method ul { padding-left: 18px; margin: 0; }
.grw-app .grw-method li { list-style: disc; margin: 0 0 8px 0; font-size: .84rem; color: var(--grw-ink-2); }

.grw-foot { display: flex; justify-content: flex-end; }
.grw-mobilebar { display: none; }

/* ---------- Адаптивность ---------- */
@media (max-width: 1024px) {
	.grw-layout { grid-template-columns: 1fr; }
	.grw-inputs { border-right: 0; border-bottom: 1px solid var(--grw-line); }
	.grw-inputs { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
	.grw-actions { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
	.grw-app { margin: 12px 0; border-radius: 12px; font-size: 14px; max-width: 100%; }
	.grw-head { padding: 14px 16px; }
	.grw-app .grw-head__title { font-size: 1.12rem; }
	.grw-status { display: none; }
	.grw-inputs { display: flex; align-items: stretch; padding: 12px; }
	.grw-results { padding: 12px; }
	.grw-card { padding: 12px; }
	.grw-canvas-wrap { aspect-ratio: 1 / 1.08; max-height: 70vh; }
	.grw-chips { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin-right: -12px; padding-right: 12px; scrollbar-width: none; }
	.grw-chips::-webkit-scrollbar { display: none; }
	.grw-app .grw-chip { flex: none; }
	.grw-checks, .grw-rc { grid-template-columns: 1fr; }
	.grw-app .grw-input input, .grw-app .grw-select select { font-size: 16px; height: 44px; } /* без авто-зума iOS */

	/* Плавающая панель расчета */
	.grw-mobilebar {
		display: flex; align-items: center; justify-content: space-between; gap: 12px;
		position: sticky; bottom: 0; z-index: 20;
		padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
		background: rgba(255, 255, 255, .96); border-top: 1px solid var(--grw-line);
		-webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
	}
	.grw-mobilebar__status { display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; color: var(--grw-ink-2); min-width: 0; }
	.grw-mobilebar__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.grw-app[data-state="ok"] .grw-mobilebar .grw-status__dot { background: var(--grw-ok); }
	.grw-app[data-state="fail"] .grw-mobilebar .grw-status__dot { background: var(--grw-bad); }
	.grw-app[data-state="busy"] .grw-mobilebar .grw-status__dot,
	.grw-app[data-state="stale"] .grw-mobilebar .grw-status__dot { background: #d98c00; }
}
@media (max-width: 380px) {
	.grw-group__body { grid-template-columns: 1fr; }
	.grw-actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
	.grw-app * { transition: none !important; animation: none !important; }
}

/* ---------- Печать ---------- */
@media print {
	.grw-app { border: 0; background: #fff; max-width: none; margin: 0; }
	.grw-head { background: #fff; color: #000; border-bottom: 2px solid #000; }
	.grw-app .grw-head__title { color: #000; }
	.grw-app .grw-head__sub { color: #444; }
	.grw-status, .grw-mobilebar, .grw-actions, .grw-foot, .grw-chips, .grw-hint, .grw-card__head .grw-chip { display: none !important; }
	.grw-layout { grid-template-columns: 1fr; }
	.grw-inputs { display: grid; grid-template-columns: 1fr 1fr; border: 0; background: #fff; }
	.grw-group, .grw-card { box-shadow: none; break-inside: avoid; }
	.grw-card--details { display: block; }
	.grw-canvas-wrap { max-height: none; }
}

/* Защита заголовков от стилей темы (подчеркивания, градиентный текст, фон-«маркер») */
.grw-app .grw-head__title,
.grw-app .grw-head__sub,
.grw-app .grw-card__title {
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
	text-shadow: none !important;
	padding: 0 !important;
	margin: 0 !important;
	text-decoration: none !important;
	-webkit-background-clip: border-box !important;
	background-clip: border-box !important;
	font-family: var(--grw-font) !important;
	letter-spacing: normal !important;
	text-transform: none !important;
}
.grw-app .grw-head__title { color: #ffffff !important; -webkit-text-fill-color: #ffffff !important; font-size: 1.3rem !important; font-weight: 700 !important; line-height: 1.25 !important; }
.grw-app .grw-head__sub { color: #b8c7d2 !important; -webkit-text-fill-color: #b8c7d2 !important; font-size: .86rem !important; margin-top: 3px !important; }
.grw-app .grw-card__title { color: var(--grw-ink) !important; -webkit-text-fill-color: var(--grw-ink) !important; font-size: 1rem !important; font-weight: 700 !important; line-height: 1.3 !important; }
.grw-app .grw-head__title::before, .grw-app .grw-head__title::after,
.grw-app .grw-card__title::before { content: none !important; display: none !important; }
@media (max-width: 720px) { .grw-app .grw-head__title { font-size: 1.12rem !important; } }
@media print {
	.grw-app .grw-head__title { color: #000 !important; -webkit-text-fill-color: #000 !important; }
	.grw-app .grw-head__sub { color: #444 !important; -webkit-text-fill-color: #444 !important; }
}
