/* Iglushka: mobile-first client pages (N3), desktop-first admin. No build step. */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e0da;
  --accent: #b5352a;
  --accent-ink: #ffffff;
  --ok: #2e7d32;
  --warn: #b26a00;
  --err: #c62828;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0.75rem 0 0.5rem; }
img { max-width: 100%; height: auto; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
body.admin .wrap { max-width: 1400px; }
body.admin { font-size: 14px; }

.topbar { background: var(--text); color: #fff; margin-bottom: 16px; }
.topbar .wrap { display: flex; align-items: center; gap: 24px; min-height: 52px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.15rem; }
.nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nav a, .nav .link { color: #ddd; text-decoration: none; }
.nav a:hover, .nav .link:hover { color: #fff; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.narrow-card { max-width: 380px; margin: 40px auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* forms */
form.stack, .stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; margin-bottom: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
label.swap { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 400; }
input, select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-width: 0;
}
input[type="color"] { padding: 2px; width: 44px; height: 34px; }
input[type="checkbox"] { width: auto; }
input.narrow, .narrow { max-width: 110px; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }
.row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
fieldset { border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; gap: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 0; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 0.85em; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.alert { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.alert.error { background: #fdecea; color: var(--err); }
.alert.ok { background: #e8f5e9; color: var(--ok); }

/* badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 600; background: #eee; color: #333; vertical-align: middle;
}
.badge.ok, .status-approved, .status-done { background: #e8f5e9; color: var(--ok); }
.status-awaiting_review { background: #fff3e0; color: var(--warn); }
.status-needs_changes { background: #fff8e1; color: var(--warn); }
.status-rejected { background: #fdecea; color: var(--err); }
.status-in_production { background: #e3f2fd; color: #1565c0; }
.badge.lock { background: #37474f; color: #fff; }
.badge.assumed { background: #fff3e0; color: var(--warn); font-weight: 500; }

/* result */
.previews { display: grid; grid-template-columns: 1fr; gap: 12px; }
.previews figure { margin: 0; background: repeating-conic-gradient(#f0f0f0 0 25%, #fff 0 50%) 0 0/16px 16px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; }
.previews img { max-height: 360px; object-fit: contain; }
figcaption { font-size: 0.85em; color: var(--muted); margin-top: 4px; }
.swatches { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.swatches li { display: flex; align-items: center; gap: 8px; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.25); vertical-align: middle; flex: none; }
.price { font-size: 1.6rem; font-weight: 700; margin: 0 0 8px; }
.issues { padding-left: 20px; margin: 0; }
.issue.error { color: var(--err); }
.issue.warning { color: var(--warn); }
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.events time { color: var(--muted); font-size: 0.85em; margin-right: 6px; }
.spinner { width: 36px; height: 36px; margin: 8px auto; border: 4px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tables */
table { border-collapse: collapse; width: 100%; }
table.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 8px 4px 0; }
table.kv td { text-align: right; padding: 4px 0; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
table.grid.compact th, table.grid.compact td { padding: 3px 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--text); color: #fff; }
.count { color: var(--muted); font-size: 0.85em; }
.tabs a.active .count { color: #ccc; }

/* admin detail */
.cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
.machine-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.machine-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.machine-card.chosen { border: 2px solid var(--ok); }
.machine-card.fail { background: #fffafa; }
.versions { list-style: none; padding: 0; margin: 0; }
.versions li { padding: 4px 0; }
.versions li.current { font-weight: 700; }
.needle { margin-right: 10px; white-space: nowrap; }
code { font-size: 0.85em; background: #f2f2f2; padding: 0 4px; border-radius: 3px; }

@media (min-width: 600px) {
  .row { grid-template-columns: 1fr 1fr; }
  .previews { grid-template-columns: 1fr 1fr; }
  .swatches { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1000px) {
  .row.four { grid-template-columns: repeat(4, 1fr); }
  .previews.four { grid-template-columns: repeat(3, 1fr); }
  .cols { grid-template-columns: minmax(0, 1fr) 340px; }
  .machine-grid { grid-template-columns: 1fr 1fr; }
}

/* language switcher (public pages) */
.langs { display: flex; gap: 10px; margin-left: auto; font-size: 0.9rem; }
.langs a { color: #bbb; text-decoration: none; letter-spacing: 0.03em; }
.langs a:hover { color: #fff; }
.langs a.active { color: #fff; font-weight: 700; }
