:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f0ebe3;
  --text: #22201c;
  --muted: #6f685e;
  --line: #e2dbd0;
  --accent: #8a6a43;
  --accent-ink: #ffffff;
  --ok: #2f7a4f;
  --warn: #a8661b;
  --danger: #b23b32;
  --focus: #c79a5c;
  --shadow: 0 1px 2px rgba(34, 32, 28, .06), 0 4px 16px rgba(34, 32, 28, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1f1d1a;
    --surface-2: #2a2723;
    --text: #ece7df;
    --muted: #a39a8d;
    --line: #36322c;
    --accent: #c9a274;
    --accent-ink: #1b1915;
    --ok: #5cb784;
    --warn: #e0a25a;
    --danger: #e0756b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; font-weight: 650; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.break { overflow-wrap: anywhere; }
.mt { margin-top: 1.25rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem clamp(16px, 3vw, 32px); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: .5rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-weight: 800; letter-spacing: .14em; font-size: .95rem; }
.brand-sub { color: var(--muted); font-size: .85rem; }
.brand-lg .brand-mark { font-size: 1.3rem; }
.nav { display: flex; gap: .25rem; }
.nav a { color: var(--muted); padding: .35rem .7rem; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.logout { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.user { color: var(--muted); font-size: .9rem; }

.page { padding: clamp(16px, 3vw, 32px); max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.count { color: var(--muted); font-weight: 500; font-size: 1.1rem; margin-left: .35rem; }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: .5rem .95rem; font: inherit; font-weight: 550; cursor: pointer;
  min-height: 38px; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: .88rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-ghost { background: transparent; }
.linkish { background: none; border: 0; padding: .2rem 0 0; color: var(--accent); font: inherit; font-size: .82rem; cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 550; }
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: .5rem .65rem; min-height: 38px; width: 100%;
  font-weight: 400;
}
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: flex-start; gap: .5rem; color: var(--text); font-weight: 500; }
label.check input { width: auto; min-height: 0; margin-top: .25rem; accent-color: var(--ok); }

.filters {
  display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(180px, 2fr) auto;
  gap: .75rem; align-items: end; background: var(--surface); padding: 1rem; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 1.25rem;
}
.filter-actions { display: flex; gap: .5rem; }

/* gallery */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); }
.card-link { color: inherit; display: block; }
.card-link:hover { text-decoration: none; }
.thumb { aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.broken::after, .preview.broken::after { content: "Нет превью"; display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .85rem; }
.card-body { padding: .75rem .85rem .9rem; display: grid; gap: .3rem; }
.card-title { font-weight: 650; text-transform: none; }
.card-title::first-letter { text-transform: uppercase; }
.card-meta { color: var(--muted); font-size: .88rem; }
.card-file { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 650; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-unreviewed { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge-approved { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge-rejected, .badge-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge-reshoot, .badge-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }

/* photo page */
.photo-nav { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.spacer { flex: 1; }
.photo-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 1.5rem; align-items: start; }
.photo-media { position: sticky; top: 76px; }
.preview { background: var(--surface-2); border-radius: var(--radius); overflow: hidden; min-height: 240px; display: grid; place-items: center; }
.preview img { max-width: 100%; max-height: calc(100vh - 220px); display: block; object-fit: contain; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 1rem 0 0; font-size: .88rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.photo-side { display: grid; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.panel-head h2 { margin: 0; }
.panel-confirmed { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.panel-ai { background: var(--surface-2); box-shadow: none; }
.draft { font-size: .72rem; font-weight: 650; color: var(--warn); margin-left: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.hint { font-size: .85rem; color: var(--muted); margin: 0 0 .85rem; }
.warn-box { background: color-mix(in srgb, var(--warn) 12%, transparent); border-left: 3px solid var(--warn); padding: .5rem .7rem; border-radius: 6px; font-size: .88rem; margin: 0 0 .75rem; }
.review-form, .content-form { display: grid; gap: .8rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
dl.ai { display: grid; grid-template-columns: 130px 1fr; gap: .45rem 1rem; margin: 0 0 .5rem; font-size: .9rem; }
dl.ai dt { color: var(--muted); }
dl.ai dd { margin: 0; }
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; font-size: .88rem; }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; color: var(--text); box-shadow: var(--shadow); }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile-num { font-size: 2.2rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .9rem; }
.tile-accent .tile-num { color: var(--accent); }
.tile-ok .tile-num { color: var(--ok); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: .6rem; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; }
.stats-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; margin: 0; font-size: .92rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.hbars { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.hbars li { display: grid; grid-template-columns: 9rem 1fr 2.5rem; gap: .6rem; align-items: center; font-size: .9rem; }
.hb-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hb-track span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; }
.hb-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 2rem 1.75rem; box-shadow: var(--shadow); display: grid; gap: 1rem; }
.login-card .brand { flex-direction: column; gap: .1rem; margin-bottom: .5rem; }
.form-error { color: var(--danger); margin: 0; font-size: .9rem; }

/* flashes */
.flashes { display: grid; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .65rem .9rem; border-radius: 9px; font-size: .92rem; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.flash-error { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); color: var(--danger); }

/* responsive */
@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .filters .grow { grid-column: 1 / -2; }
  .stats-cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .photo-layout { grid-template-columns: 1fr; }
  .photo-media { position: static; }
  .preview img { max-height: 70vh; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .5rem 1rem; }
  .brand-sub { display: none; }
  .logout .user { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .grow, .filter-actions { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .card-body { padding: .55rem .6rem .7rem; }
  .row2 { grid-template-columns: 1fr; }
  .stats-cols { grid-template-columns: 1fr; }
  dl.ai { grid-template-columns: 1fr; gap: .1rem; }
  dl.ai dd { margin-bottom: .5rem; }
  .hbars li { grid-template-columns: 6.5rem 1fr 2rem; }
  .tile-num { font-size: 1.7rem; }
}
