/* o.infomos.online — light theme, functional, quiet */

:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F4F4EF;
  --border: #E6E5DE;
  --border-strong: #D6D4CB;
  --text: #101418;
  --text-muted: #5B6470;
  --accent: #2F6DF6;
  --accent-contrast: #FFFFFF;
  --accent-soft: #E8EFFE;
  --accent-dark: #1E55D1;
  --success: #0E8A5F;
  --success-soft: #E3F4EC;
  --error: #B23131;
  --error-soft: #F9E6E6;
  --warn: #8B6A00;
  --shadow-sm: 0 1px 2px rgba(16, 20, 24, .05);
  --shadow-md: 0 6px 22px rgba(16, 20, 24, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --space: 16px;
  --fs-1: 28px;
  --fs-2: 20px;
  --fs-3: 16px;
  --fs-body: 15px;
  --fs-sm: 13px;
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.h1 { font-size: var(--fs-1); }
.h2 { font-size: var(--fs-2); margin-bottom: 12px; }
.h3 { font-size: var(--fs-3); margin: 12px 0 8px; font-weight: 600; color: var(--text); }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }

/* Top bar */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; }
.brand img { height: 36px; width: auto; }
.nav { display: flex; gap: 4px; }
.nav__link {
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
}
.nav__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.balance {
  display: inline-flex; flex-direction: column; align-items: flex-end;
  padding: 4px 12px; border-radius: var(--radius-sm); background: var(--accent-soft);
  line-height: 1.1;
}
.balance__label { font-size: 10px; color: var(--accent-dark); letter-spacing: .04em; text-transform: uppercase; }
.balance__value { font-weight: 600; color: var(--accent-dark); font-size: 14px; }
.user-chip { color: var(--text-muted); font-size: var(--fs-sm); }
.logout-form { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 14px/1 var(--font); color: var(--text);
  padding: 10px 16px; border: 1px solid var(--border-strong);
  background: var(--surface); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .12s ease; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary {
  background: var(--accent); color: var(--accent-contrast); border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--accent-contrast); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--block { width: 100%; }
.btn--lg { padding: 14px 22px; font-size: 15px; }
.btn--sm { padding: 6px 10px; font-size: var(--fs-sm); }

/* Page */
.page { max-width: 1240px; margin: 0 auto; padding: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: var(--fs-sm); }
.alert--error { background: var(--error-soft); color: var(--error); border: 1px solid #F2C9C9; }
.alert--ok    { background: var(--success-soft); color: var(--success); border: 1px solid #C7E8D6; }

/* Login page */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1000px 500px at 50% -10%, #EBF1FD 0%, transparent 60%), var(--bg); }
.auth__card {
  background: var(--surface); padding: 32px; border-radius: var(--radius-lg);
  width: 100%; max-width: 400px; box-shadow: var(--shadow-md); border: 1px solid var(--border);
  text-align: center;
}
.auth__logo { height: 44px; width: auto; margin: 0 auto 20px; }
.auth__title { font-size: 22px; margin-bottom: 6px; }
.auth__sub { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 22px; }
.form { display: grid; gap: 14px; text-align: left; }
.field { display: grid; gap: 6px; }
.field__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.input {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.input:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }

/* Layout — generator */
.layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* Boards side */
.boards {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto;
}
.boards__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.boards__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.thumb {
  position: relative; aspect-ratio: 1 / 1;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  background: var(--surface-2);
  transition: border-color .1s ease, box-shadow .1s ease;
}
.thumb input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; opacity: 0; cursor: pointer; appearance: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { border-color: var(--border-strong); }
.thumb--active, .thumb:has(input:checked) {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.thumb__dim {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(16,20,24,.7); color: #fff; padding: 1px 5px; border-radius: 4px;
  font-size: 10px;
}

/* Upload */
.upload { display: grid; gap: 10px; }
.upload__drop {
  position: relative; display: grid; place-items: center; text-align: center;
  padding: 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer;
  transition: border-color .1s ease, background .1s ease;
}
.upload__drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload__drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload__drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload__icon { font-size: 22px; color: var(--accent); line-height: 1; }
.upload__text { font-weight: 500; margin-top: 4px; }
.upload__hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* Generator form */
.generator { display: grid; gap: 20px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: grid; place-items: center; text-align: center;
  padding: 18px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; user-select: none;
  transition: all .12s ease;
}
.tile input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tile__label { font-weight: 500; color: var(--text); }
.tile:hover { border-color: var(--border-strong); background: var(--surface-2); }
.tile:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark);
  box-shadow: 0 0 0 2px var(--accent-soft) inset;
}
.tile:has(input:checked) .tile__label { color: var(--accent-dark); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  position: relative;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 14px;
  transition: all .12s ease;
}
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill:hover { background: var(--surface-2); border-color: var(--border-strong); }
.pill:has(input:checked) {
  background: var(--accent); color: var(--accent-contrast); border-color: var(--accent);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.fence-variant { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 6px; }
.admin-model { border-top: 1px dashed var(--border); padding-top: 14px; }

.submit-row {
  margin-top: 4px; display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding-top: 16px; border-top: 1px solid var(--border);
}

/* Result */
.result {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.result__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result__actions { display: flex; gap: 8px; }
.result__body { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
@media (max-width: 720px) { .result__body { grid-template-columns: 1fr; } }
#resImg { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.result__meta {
  display: grid; gap: 8px;
  padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--fs-sm);
}
.result__meta dt { color: var(--text-muted); font-size: 12px; }
.result__meta dd { margin: 0 0 8px; font-weight: 500; }

/* Loader */
.loader {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; display: grid; place-items: center; gap: 10px; text-align: center;
}
.loader__ring {
  width: 42px; height: 42px; border: 3px solid var(--surface-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
.loader__stage { font-weight: 500; }
.loader__sub { color: var(--text-muted); font-size: var(--fs-sm); }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

/* Generation page */
.result-page { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .result-page { grid-template-columns: 1fr; } }
.result-page__img img {
  width: 100%; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.result-page__fail {
  padding: 40px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); text-align: center;
}
.result-page__side { display: grid; gap: 18px; position: sticky; top: 80px; }
.kv { display: grid; grid-template-columns: 140px 1fr; row-gap: 6px; column-gap: 12px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 500; }
.result-page__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Gallery */
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.gcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.gcard__img { display: block; aspect-ratio: 4/3; background: var(--surface-2); }
.gcard__img img { width: 100%; height: 100%; object-fit: cover; }
.gcard__body { padding: 12px 14px; display: grid; gap: 6px; }
.gcard__title { font-weight: 600; }
.gcard__meta { color: var(--text-muted); font-size: var(--fs-sm); }
.gcard__price { font-size: var(--fs-sm); margin-top: 4px; }
.gcard__actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); color: var(--text-muted); font-weight: 500; }
.table td { vertical-align: top; }
.table tr:hover td { background: var(--surface-2); }

/* Delete controls + danger button */
.thumb-wrap { position: relative; aspect-ratio: 1 / 1; }
.thumb-wrap .thumb { position: absolute; inset: 0; aspect-ratio: auto; }
.thumb__del {
  position: absolute; top: 4px; right: 4px; margin: 0;
  opacity: 0; transition: opacity .15s;
}
.thumb-wrap:hover .thumb__del,
.thumb-wrap:focus-within .thumb__del { opacity: 1; }
.btn--danger {
  background: #D64545; color: #fff; border-color: #D64545;
}
.btn--danger:hover { background: #B53535; border-color: #B53535; }
.btn--xs {
  padding: 2px 8px; font-size: 12px; line-height: 1.4; border-radius: 999px; min-width: 22px;
}
.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input[type="number"] { width: 120px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* User note field */
.user-note { margin: 18px 0; display: grid; gap: 6px; }
.user-note h3 {
  display: inline-flex; align-items: center; gap: 8px;
}
.user-note h3::before {
  content: "важно";
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: #FFE9B0; color: #7A5200;
}
.user-note textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; resize: vertical; min-height: 72px; background: var(--surface);
}
.user-note textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,246,.15); }
.user-note__counter { font-size: 11px; color: var(--text-muted); text-align: right; }
.note-important {
  background: #FFF7E0; border-left: 3px solid #E8A220; padding: 6px 10px; border-radius: 4px;
  font-size: var(--fs-sm); word-wrap: break-word;
}
.gcard__note {
  font-size: 12px; color: #7A5200; background: #FFF5D9;
  padding: 4px 8px; border-radius: 4px; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload__drop { cursor: pointer; }
.upload__drop--busy {
  opacity: .6; pointer-events: none;
}
.upload__drop--busy::after {
  content: ""; display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--surface-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; margin-left: 8px;
  vertical-align: middle;
}

/* Download menu (details/summary) */
.dl-menu { position: relative; display: inline-block; }
.dl-menu summary { list-style: none; cursor: pointer; }
.dl-menu summary::-webkit-details-marker { display: none; }
.dl-menu[open] summary { background: var(--surface-2); }
.dl-menu__list {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,.08); padding: 6px; min-width: 200px;
  display: grid; gap: 2px;
}
.dl-menu__list a {
  display: block; padding: 8px 12px; border-radius: 4px;
  color: var(--text); text-decoration: none; font-size: var(--fs-sm);
}
.dl-menu__list a:hover { background: var(--surface-2); color: var(--accent); }
.dl-menu--sm .dl-menu__list { min-width: 140px; }

/* Variants picker */
.variants-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }

/* Result grid */
.result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.result__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.result__grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.result__grid--multi { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.rcard { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; gap: 10px; position: relative; }
.rcard img { width: 100%; height: auto; display: block; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.rcard__body { padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: relative; z-index: 3; }
.rcard .dl-menu__list { z-index: 4; }
.rcard__meta { font-size: var(--fs-sm); color: var(--text-muted); flex: 1 1 auto; }
.rcard--error { padding: 20px; }
.rcard__error { color: #B53535; font-size: var(--fs-sm); }

/* Correction modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,20,24,.55); z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: 560px; width: 100%; padding: 24px; display: grid; gap: 14px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal textarea { width: 100%; min-height: 110px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; resize: vertical; }
.modal textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,246,.15); }
.modal__counter { text-align: right; font-size: 11px; color: var(--text-muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Scene source upload (second image) */
.scene-source { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; background: var(--surface-2); margin-bottom: 14px; }
.scene-source__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scene-source__preview { max-height: 120px; display: block; margin-top: 10px; border-radius: var(--radius-sm); }

/* Scene source swap mode */
#genForm:not(.swap-mode) .pill[data-as-is] { display: none; }
#genForm.swap-mode .js-hide-on-swap { display: none !important; }

/* Global page loader (overlay) */
.global-loader {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(16,20,24,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: glFade .18s ease-out;
}
@keyframes glFade { from { opacity: 0; } to { opacity: 1; } }
.global-loader__card {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px 36px; display: grid; gap: 10px; place-items: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: 440px; text-align: center;
}
.global-loader__ring {
  width: 52px; height: 52px; border: 3px solid var(--surface-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
.global-loader__title { font-weight: 600; font-size: 15px; }
.global-loader__sub   { color: var(--text-muted); font-size: var(--fs-sm); }

/* Before/After compare slider */
.compare { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius-sm); user-select: none; touch-action: none; background: var(--surface-2); }
.compare img { display: block; width: 100%; height: auto; pointer-events: none; }
.compare__after { position: absolute; inset: 0; clip-path: inset(0 0 0 50%); }
.compare__handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25);
  transform: translateX(-50%); cursor: ew-resize;
}
.compare__grip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; color: #101418;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.1);
}
.compare:focus-within .compare__grip,
.compare:hover .compare__grip { box-shadow: 0 2px 12px rgba(0,0,0,.35), 0 0 0 2px var(--accent); }
.compare__lbl {
  position: absolute; top: 12px;
  background: rgba(16,20,24,.75); color: #fff;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  pointer-events: none;
}
.compare__lbl--before { left: 12px; }
.compare__lbl--after  { right: 12px; }
