/* Декорная — общий стиль кабинета. Палитра бренда — переменные ниже. */
@import url('/fonts/playfair-display/cyrillic-700.css');
@import url('/fonts/playfair-display/latin-700.css');
@import url('/fonts/montserrat/cyrillic-400.css');
@import url('/fonts/montserrat/latin-400.css');
@import url('/fonts/montserrat/cyrillic-600.css');
@import url('/fonts/montserrat/latin-600.css');
@import url('/fonts/marck-script/cyrillic-400.css');
@import url('/fonts/marck-script/latin-400.css');

:root {
  --green: #1f3b2d;
  --burgundy: #7a1f2b;
  --gold: #c9a24a;
  --cream: #f6efe2;
  --white: #ffffff;

  --ink: #1d2420;
  --muted: #6b6f68;
  --line: #e4dccb;
  --surface: var(--white);
  --bg: var(--cream);
  --ok: #2f6b45;
  --warn: #9a6a12;
  --danger: var(--burgundy);

  --font-head: 'Playfair Display', Georgia, serif;
  --font-text: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --font-script: 'Marck Script', cursive;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 59, 45, 0.12), 0 4px 16px rgba(31, 59, 45, 0.06);
  --nav-w: 220px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { font-family: var(--font-head); color: var(--green); line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
a { color: var(--burgundy); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.script { font-family: var(--font-script); color: var(--gold); }

/* ── Каркас ───────────────────────────────────────── */
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'top top' 'nav main';
}
.topbar {
  grid-area: top;
  background: var(--green);
  color: var(--cream);
  padding: 10px 20px;
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #b3384a, var(--burgundy));
  box-shadow: 0 -6px 0 -4px var(--gold);
  align-self: center;
}
.brand-name { font-family: var(--font-head); font-size: 24px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-family: var(--font-script); font-size: 20px; color: var(--gold); }

.nav {
  grid-area: nav;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.nav a:hover { background: var(--cream); }
.nav a.active { background: var(--green); color: var(--cream); }
.nav-icon svg {
  width: 22px; height: 22px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.content { grid-area: main; padding: 24px; max-width: 1200px; width: 100%; outline: none; }

@media (max-width: 767px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: 'top' 'main';
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .topbar { padding: 8px 16px; }
  .brand-name { font-size: 20px; }
  .brand-sub { font-size: 17px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 4px 2px env(safe-area-inset-bottom);
    flex-direction: row; justify-content: space-around; gap: 0;
    border-right: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(31, 59, 45, 0.08);
  }
  .nav a {
    flex: 1 1 auto;
    flex-direction: column; gap: 2px;
    padding: 6px 0;
    font-size: 10.5px; font-weight: 600;
    text-align: center;
  }
  .nav a span:last-child { white-space: nowrap; }
  .content { padding: 16px; }
  h1 { font-size: 24px; }
}

/* ── Элементы ─────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--green); border-radius: 8px;
  background: var(--white); color: var(--green);
  font: 600 14px var(--font-text);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--cream); }
.btn.primary { background: var(--green); color: var(--cream); }
.btn.primary:hover { background: #2b4f3d; }
.btn.danger { border-color: var(--burgundy); color: var(--burgundy); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--green); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }

input, select, textarea {
  font: 15px var(--font-text);
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fbf8f1; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.article { font-family: Consolas, 'Courier New', monospace; font-weight: 700; white-space: nowrap; color: var(--green); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--cream); color: var(--green); border: 1px solid var(--line);
}
.badge.green { background: #e3efe6; color: var(--ok); border-color: #c4dccb; }
.badge.gold { background: #f6ecd2; color: var(--warn); border-color: #ead7a6; }
.badge.red { background: #f5e1e3; color: var(--burgundy); border-color: #e8c3c8; }
.badge.gray { background: #eeeeea; color: var(--muted); border-color: #ddddd6; }

.thumb {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover;
  background: var(--green); display: block; flex: none;
}
.thumb.empty { display: grid; place-items: center; color: var(--gold); font-family: var(--font-script); font-size: 20px; }

.empty-state { text-align: center; padding: 48px 16px; }
.empty-state .script { font-size: 28px; display: block; margin-bottom: 8px; }

/* ── Тосты, диалоги, вход ──────────────────────────── */
.toasts {
  position: fixed; z-index: 50; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
@media (max-width: 767px) { .toasts { left: 16px; right: 16px; bottom: calc(var(--nav-h) + 12px); } }
.toast {
  padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow);
  background: var(--green); color: var(--cream); font-weight: 600;
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--burgundy); }
.toast.warn { background: var(--gold); color: var(--green); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

dialog.confirm { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; max-width: min(420px, calc(100vw - 32px)); }
dialog.confirm::backdrop { background: rgba(31, 59, 45, 0.45); }
dialog.confirm .row { justify-content: flex-end; margin-top: 16px; }

.login-screen {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(circle at 50% 20%, #2b4f3d, var(--green));
}
.login-card {
  background: var(--cream); border-radius: 14px; padding: 28px 24px; width: min(360px, 100%);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin-bottom: 0; text-align: center; font-family: var(--font-script); color: var(--green); }
.login-card > .muted { text-align: center; margin: -8px 0 4px; }
.login-card input { width: 100%; font-size: 16px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-error { color: var(--burgundy); font-weight: 600; margin: 0; min-height: 1em; }
.login-error:empty { display: none; }

.stub { text-align: center; padding: 56px 16px; }
.stub .script { font-size: 30px; display: block; margin-bottom: 6px; }

@media print {
  .nav, .topbar, .toasts, .no-print { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .table-wrap, .card { box-shadow: none; }
  body { background: #fff; }
}
