/* Админка VastyaFarm — телефон (портрет), светлая и тёмная тема. Цвета — в духе игры: сливочный фон,
   сочный зелёный, тёплые карточки с мягкой тенью. Безопасные зоны: env(safe-area-inset-*). */
:root {
  --bg: #f6f1e3;
  --card: #fffbf2;
  --line: #eadfc6;
  --text: #2f2a1f;
  --hint: #857a63;
  --green: #5a9a3a;
  --green-dark: #477d2c;
  --green-soft: #e3efd5;
  --btn: #477d2c;
  --btn-edge: #355f20;
  --red: #c8432f;
  --red-soft: #f7dfd8;
  --amber: #e7a92c;
  --shadow: 0 2px 0 rgba(120, 96, 50, 0.12), 0 6px 18px rgba(120, 96, 50, 0.1);
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
:root[data-scheme="dark"] {
  --bg: #1d2118;
  --card: #272c21;
  --line: #3a4130;
  --text: #f1ead8;
  --hint: #a8a08a;
  --green: #6fb24a;
  --green-dark: #5c9a3b;
  --green-soft: #2f3d25;
  --btn: #3f7a26;
  --btn-edge: #2c5a1a;
  --red: #e0654f;
  --red-soft: #4a2a23;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { min-height: 100%; display: flex; flex-direction: column; padding-left: var(--safe-left); padding-right: var(--safe-right); }

/* шапка: полоса окружения + название */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-top: var(--safe-top); }
.env { text-align: center; font-weight: 800; font-size: 12px; letter-spacing: 0.12em; padding: 3px 0; background: #b7b09b; color: #fff; }
.env.staging { background: #f2c230; color: #3a2c00; }
.env.prod { background: #d33b2c; color: #fff; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--green); box-shadow: inset 0 -3px 0 var(--green-dark); font-size: 19px; }
.who { color: var(--hint); font-size: 14px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }

.main { flex: 1; padding: 4px 12px calc(84px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; }
.splash { margin: 30vh auto 0; color: var(--hint); font-weight: 700; }

/* карточка экрана */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 4px; }
.panel-title { font-weight: 800; font-size: 17px; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--hint); font-size: 20px; border-radius: 12px; }
.icon-btn:active { background: var(--green-soft); }
.panel-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.block-title { font-weight: 700; color: var(--hint); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

/* форма параметров */
.form { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.form .grow { flex: 1 1 180px; }
.input, .select { width: 100%; min-height: 46px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); padding: 10px 12px; outline: none; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--green); }
textarea.input { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--hint); font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.field-label { font-size: 13px; color: var(--hint); margin: 0 0 4px 2px; }

.btn { min-height: 46px; padding: 0 18px; border-radius: 14px; border: 0; background: var(--btn); color: #fff; font-weight: 800; box-shadow: inset 0 -3px 0 var(--btn-edge); cursor: pointer; }
.btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--btn-edge); }
.btn:disabled { opacity: 0.55; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); box-shadow: none; }
.btn.danger { background: var(--red); box-shadow: inset 0 -3px 0 #9c3020; }
.btn.wide { width: 100%; }

/* карточка «ключ — значение» */
/* строка: подпись слева забирает остаток, значение справа — по своей ширине (не больше 62%); переносится подпись,
   а не значение; значение рвётся только по пробелам */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv .k { flex: 1 1 0; min-width: 38%; color: var(--hint); }
.kv .v { flex: 0 1 auto; max-width: 62%; text-align: right; font-weight: 700; overflow-wrap: break-word; word-break: normal; hyphens: none; }

/* строки таблицы — карточками */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--bg); }
.row-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-title { font-weight: 800; overflow-wrap: break-word; min-width: 0; }
.row-side { color: var(--hint); font-size: 14px; white-space: nowrap; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 14px; color: var(--hint); }
.row-meta b { color: var(--text); font-weight: 700; }
.row-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.btn.ghost.danger-text { color: var(--red); border-color: var(--red-soft); }
.empty { color: var(--hint); font-size: 15px; padding: 6px 2px; }

.muted { color: var(--hint); font-weight: 400; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.id { font-family: var(--mono); background: var(--green-soft); border-radius: 8px; padding: 1px 6px; cursor: pointer; }
.ok { color: var(--green); font-weight: 800; }
.bad { color: var(--red); font-weight: 800; }
.note { background: var(--green-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.note.warn { background: var(--red-soft); }

/* действия */
.actions { display: flex; flex-direction: column; gap: 10px; }
.action-btn { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 8px 16px; gap: 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); font-weight: 700; text-align: left; }
.action-btn .tag { white-space: nowrap; flex-shrink: 0; font-size: 12px; font-weight: 800; border-radius: 8px; padding: 2px 8px; background: var(--green-soft); color: var(--green-dark); }
.action-btn .tag.medium { background: #fbecc5; color: #8a5a00; }
.action-btn .tag.high { background: var(--red-soft); color: var(--red); }

/* нижняя панель */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around; gap: 4px;
  padding: 6px calc(8px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(8px + var(--safe-left));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(120, 96, 50, 0.1); }
.tab { flex: 1; min-height: 52px; border: 0; background: transparent; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--hint); font-size: 12px; font-weight: 700; }
.tab .ic { font-size: 20px; line-height: 1; }
.tab.on { color: var(--green-dark); background: var(--green-soft); }

/* окно подтверждения */
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(30, 24, 12, 0.45); display: flex; align-items: flex-end; justify-content: center; padding: 12px 12px calc(12px + var(--safe-bottom)); }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow: auto; }
.sheet h2 { margin: 0; font-size: 19px; }
.sheet .lines { margin: 0; padding-left: 18px; }
.sheet .buttons { display: flex; gap: 10px; }
.sheet .buttons .btn { flex: 1; }
.band { border-radius: 10px; padding: 6px 10px; font-weight: 800; font-size: 13px; }
.band.high { background: var(--red-soft); color: var(--red); }
.band.medium { background: #fbecc5; color: #8a5a00; }

.toast { position: fixed; left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right)); top: calc(8px + var(--safe-top)); z-index: 11; margin: 0 auto; max-width: 520px; background: #2f2a1f; color: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); font-weight: 600; }
.toast.err { background: var(--red); }

.gate { margin: 18vh 8px 0; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.gate .big { font-size: 48px; }
.gate h1 { margin: 0; font-size: 22px; }
.gate p { margin: 0; color: var(--hint); }

/* шаг 2: движение ресурса, строка-ссылка, карточка игрока */
.plus { color: var(--green); font-weight: 800; }
.minus { color: var(--red); font-weight: 800; }
.row.link { position: relative; padding-right: 30px; cursor: pointer; }
.row.link:active { background: var(--green-soft); }
.row .chev { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--hint); font-size: 24px; font-weight: 700; }
.card-top { display: flex; justify-content: space-between; gap: 8px; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.panel.head .panel-body.result { padding-top: 6px; padding-bottom: 8px; }
.panel.head .kv-row { padding: 5px 0; font-size: 15px; }
.chips { position: sticky; top: var(--top-h, 0px); z-index: 4; display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 6px 12px 8px; background: var(--bg); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 700; font-size: 15px; box-shadow: var(--shadow); }
.chip.on { background: var(--btn); border-color: var(--btn-edge); color: #fff; box-shadow: inset 0 -3px 0 var(--btn-edge); }
.tab-body { display: flex; flex-direction: column; gap: 12px; }

/* шаг 2, по разбору вида: значения не рвутся посреди слова, даты и числа — целиком */
.nowrap { white-space: nowrap; }
.detail { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 6px; font-family: var(--mono); font-size: 12px; line-height: 1.35; color: var(--hint); overflow-wrap: anywhere; cursor: pointer; }
.detail.open { display: block; -webkit-line-clamp: unset; }
.kv .go { cursor: pointer; }
.kv .v.go { color: var(--green-dark); }
.chev-inline { margin-left: 6px; color: var(--hint); font-weight: 700; }
.fold { border-top: 1px dashed var(--line); padding-top: 8px; }
.fold > summary { cursor: pointer; color: var(--hint); font-weight: 700; font-size: 14px; min-height: 44px; display: flex; align-items: center; list-style: none; }
.fold > summary::before { content: '›'; display: inline-block; width: 18px; font-size: 20px; transition: transform 0.15s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary::-webkit-details-marker { display: none; }
.action-name { display: flex; flex-direction: column; gap: 2px; }
.action-hint { font-size: 13px; font-weight: 400; color: var(--hint); }

/* вторая очередь: графики статистики (свой SVG; цвета — проверенная палитра, у тёмной темы — свои шаги) */
.chart { display: flex; flex-direction: column; gap: 6px; --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100; }
:root[data-scheme="dark"] .chart { --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { stroke: var(--hint); stroke-width: 1; opacity: 0.6; }
.chart-svg .tick { fill: var(--hint); font-size: 11px; font-family: var(--font); }
.chart-svg .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .ln.plan { stroke-dasharray: 5 4; stroke-width: 1.6; }
.chart-svg .dot { stroke: var(--card); stroke-width: 1.5; }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart .s0 { stroke: var(--s0); fill: var(--s0); background: var(--s0); }
.chart .s1 { stroke: var(--s1); fill: var(--s1); background: var(--s1); }
.chart .s2 { stroke: var(--s2); fill: var(--s2); background: var(--s2); }
.chart .s3 { stroke: var(--s3); fill: var(--s3); background: var(--s3); }
.chart-svg .ln.s0, .chart-svg .ln.s1, .chart-svg .ln.s2, .chart-svg .ln.s3 { fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.sw.plan { height: 0; background: transparent !important; border-top: 2px dashed; }
.sw.plan.s0 { border-color: var(--s0); } .sw.plan.s1 { border-color: var(--s1); } .sw.plan.s2 { border-color: var(--s2); } .sw.plan.s3 { border-color: var(--s3); }
.chart-tip { font-size: 13px; color: var(--hint); min-height: 18px; }
.chart-note { font-size: 13px; color: var(--hint); line-height: 1.35; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.hbar-label { color: var(--text); }
.hbar-val { color: var(--text); font-weight: 700; white-space: nowrap; }
.hbar-track { position: relative; height: 10px; border-radius: 5px; background: var(--green-soft); margin-top: 4px; }
.hbar-fill { height: 100%; border-radius: 5px; }
.hbar-plan { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed var(--s1); }

/* семь разделов в нижней панели: подписи ужимаются, не выходят за экран */
.nav { gap: 2px; padding-left: calc(4px + var(--safe-left)); padding-right: calc(4px + var(--safe-right)); }
.tab { min-width: 0; padding: 0 2px; font-size: 11px; }
.tab > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
