/* LeafLedger — стили генератора этикеток. Без фреймворков, один файл. */

:root {
  --ink: #14201a;
  --ink-soft: #4a5a51;
  --muted: #6c7c73;
  --line: #dfe6e1;
  --bg: #f6f8f6;
  --card: #ffffff;
  --accent: #2f7d4f;
  --accent-dark: #24613d;
  --accent-soft: #e8f3ec;
  --warn-bg: #fff6e5;
  --warn-line: #e8c37a;
  --danger: #a33a2a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 32, 26, 0.06), 0 8px 24px rgba(20, 32, 26, 0.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать авторские display: flex/grid — иначе
   скрытые блоки (например, Custom grid для Avery-шаблонов) остаются видны. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 650; }
.brand__mark { font-size: 20px; }
.brand__name { letter-spacing: -0.01em; }
.topbar__nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar__link { font-size: 13px; text-decoration: none; }
.topbar__link:hover { text-decoration: underline; }

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ layout */

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "data design"
    "export preview";
  gap: 16px;
  align-items: start;
}

.panel--data { grid-area: data; }
.panel--design { grid-area: design; }
.panel--export { grid-area: export; }
.panel--preview { grid-area: preview; }

@media (max-width: 1080px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "data" "design" "export" "preview";
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__head { padding: 16px 18px 0; }
.panel__title { font-size: 16px; display: flex; align-items: center; gap: 9px; }
.panel__hint { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.panel__body { padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 12px; }

.step {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* ------------------------------------------------------------------ fields */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--inline { flex-direction: column; gap: 4px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }

.input {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input--sm { font-size: 13px; padding: 6px 8px; }
.input--area { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; white-space: pre; }
.input--range { padding: 0; }
.input:disabled { background: #f2f5f3; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row--wrap { flex-wrap: wrap; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 2px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2px 12px; }

.grid-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grid-box legend { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

.mapgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }

.details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.muted { color: var(--muted); font-weight: 400; }

/* ----------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn--sm { font-size: 13px; padding: 6px 11px; }
.btn--icon { padding: 4px 10px; font-size: 16px; line-height: 1; background: #fff; border-color: var(--line); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ status */

.status { font-size: 13px; color: var(--ink-soft); margin: 0; min-height: 18px; }
.status--inline { align-self: center; }
.status--ok { color: var(--accent-dark); }
.status--err { color: var(--danger); }

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.tplinfo { font-size: 12.5px; color: var(--ink-soft); font-family: var(--mono); }

.hint { font-size: 12px; color: var(--muted); margin: 0; }

.summary { font-size: 14px; font-weight: 600; margin: 0; }
.summary span { font-weight: 400; color: var(--muted); }

.howto { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }

/* ------------------------------------------------------------------- table */

.tablewrap { max-height: 190px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table th, .table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.table th { position: sticky; top: 0; background: #f2f5f3; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); z-index: 1; }
.table tbody tr:last-child td { border-bottom: none; }

/* ----------------------------------------------------------------- preview */

.previewbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.previewbar__label { font-size: 13px; color: var(--ink-soft); min-width: 92px; }
.previewbar .field--inline { flex-direction: row; align-items: center; gap: 8px; }

.sheetwrap { background: #eef1ef; border-radius: 8px; padding: 14px; display: flex; justify-content: center; max-height: 76vh; overflow: auto; }

.sheet {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 10px rgba(20, 32, 26, 0.16);
  flex: 0 0 auto;
}

.sheet__cell { position: absolute; border: 1px dashed rgba(47, 125, 79, 0.25); }
.sheet__cell--solid { border-style: solid; border-color: rgba(20, 32, 26, 0.35); }

.sheet__text { position: absolute; white-space: pre; font-family: Helvetica, Arial, sans-serif; color: #000; }
.sheet__qr { position: absolute; display: block; }

/* ------------------------------------------------------------------ footer */

.footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px 20px 40px;
  font-size: 13px;
  color: var(--ink-soft);
}
.footer p { margin: 4px 0; }
