/* 7daybook · админка и редактор. Белый минимализм, Manrope, ink #17191D. */
@font-face {
  font-family: 'Manrope';
  src: url('/static/fonts/Manrope.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #17191D;
  --muted: #5A6270;
  --faint: #8A919B;
  --line: #E6E4DE;
  --line-strong: #D7D4CC;
  --paper: #FFFFFF;
  --soft: #FAFAF8;
  --accent: #F58634;
  --accent-soft: #FDF0E5;
  --ok: #2F7D52;
  --warn: #A8661C;
  --err: #B3261E;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  font-synthesis: none;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
p { margin: 0 0 8px; }

/* ---------- шапка ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 15px; }
.brand span { color: var(--faint); font-weight: 400; margin-left: 6px; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
}
.nav a.active, .nav a:hover { background: var(--soft); color: var(--ink); }
.count { color: var(--faint); font-size: 12px; margin-left: 4px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

main { padding: 24px; max-width: 1440px; margin: 0 auto; }
main.wide { max-width: none; }

/* ---------- элементы ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.96); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--soft); color: var(--ink); }
.btn.danger { border-color: #E8C4C0; color: var(--err); }
.btn.danger:hover { background: #FCEEEC; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.pill.status-new { background: var(--accent-soft); border-color: #F6D2B4; color: #A8541B; }
.pill.status-approved, .pill.status-paid, .pill.status-done { background: #EDF6F0; border-color: #CBE5D5; color: var(--ok); }
.pill.status-changes { background: #FDF3E8; border-color: #F0D8BC; color: var(--warn); }
.pill.status-sent { background: #EEF2F8; border-color: #D6DFEC; color: #35507A; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="password"], input[type="email"], input[type="tel"], textarea, select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
  outline: none;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); }
select { padding-right: 28px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.notice.err { border-left-color: var(--err); background: #FDF6F5; }
.notice.ok { border-left-color: var(--ok); background: #F4FAF6; }

/* ---------- логин ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--soft); }
.login {
  width: 340px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.login h1 { margin-bottom: 4px; }
.login .field { margin-top: 18px; }
.login .btn { width: 100%; justify-content: center; margin-top: 18px; height: 42px; }

/* ---------- список заявок ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters a {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
}
.filters a.active { border-color: var(--line-strong); color: var(--ink); font-weight: 600; }
.search { display: flex; gap: 8px; margin-left: auto; }
.search input { width: 240px; height: 36px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--soft); }
.thumb-row { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: var(--soft); }
.thumb-row.empty { display: grid; place-items: center; color: var(--faint); font-size: 10px; }

/* ---------- карточка заявки ---------- */
.card-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.card-head .id { font-size: 12px; color: var(--faint); letter-spacing: .06em; }
.card-head h1 { margin-top: 2px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .layout-2 { grid-template-columns: 1fr; } }

.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.meta-grid .k { font-size: 12px; color: var(--muted); }
.meta-grid .v { font-weight: 600; }

.photos-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-tile { position: relative; width: 92px; }
.photo-tile img { width: 92px; height: 92px; object-fit: cover; border-radius: 6px; background: var(--soft); display: block; }
.photo-tile .tag {
  position: absolute; left: 4px; top: 4px;
  background: rgba(23, 25, 29, .78); color: #fff;
  font-size: 10px; padding: 2px 5px; border-radius: 4px;
}
.photo-tile .low { position: absolute; right: 4px; bottom: 4px; background: #fff; color: var(--warn); font-size: 10px; padding: 1px 4px; border-radius: 4px; border: 1px solid #F0D8BC; }
.photo-tile .name { font-size: 10.5px; color: var(--faint); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pages-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.page-thumb { width: 178px; }
.page-thumb .frame-wrap {
  position: relative; width: 178px; height: 178px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 6px; background: var(--soft);
}
.page-thumb .frame-wrap .inner { width: 779px; height: 779px; transform: scale(.2285); transform-origin: top left; }
.page-thumb iframe { width: 779px; height: 779px; border: 0; display: block; pointer-events: none; }
.page-thumb .cap { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.page-thumb a { display: block; }
.page-thumb:hover .frame-wrap { border-color: var(--ink); }

.issues { display: grid; gap: 6px; }
.issue { font-size: 12.5px; padding: 6px 10px; border-radius: 6px; background: var(--soft); }
.issue.error { background: #FDF1EF; color: var(--err); }
.issue.warn { background: #FDF7EE; color: var(--warn); }

.timeline { display: grid; gap: 10px; }
.timeline .item { display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 12.5px; }
.timeline .when { color: var(--faint); }

.versions .item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.versions .item:last-child { border-bottom: 0; }

.checks { display: grid; gap: 8px; }
.check { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: 12.5px; }
.check .dot { width: 14px; height: 14px; border-radius: 7px; margin-top: 2px; background: var(--soft); border: 1px solid var(--line-strong); }
.check.ok .dot { background: #E3F1E8; border-color: #A9D3B8; }
.check.no .dot { background: #FBEAE7; border-color: #E5B7B1; }

/* ---------- редактор ---------- */
body.editor-body { overflow: hidden; }
.editor {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 360px;
  height: calc(100vh - 56px);
}
.rail {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--soft);
}
.rail .page-thumb { width: 86px; }
.rail .page-thumb .frame-wrap { width: 86px; height: 86px; }
.rail .page-thumb .inner { transform: scale(.1104); }
.rail .page-thumb .cap { display: none; }
.rail .page-thumb.active .frame-wrap { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.stage { display: flex; flex-direction: column; min-width: 0; background: #F4F4F1; }
.stage-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.stage-page { flex: 1; display: grid; place-items: center; overflow: auto; padding: 24px; }
.stage-page .frame { position: relative; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 28px rgba(0, 0, 0, .06); }
.stage-page iframe { border: 0; display: block; background: #fff; }
.photo-edit select { height: 30px; font-size: 12px; padding: 0 8px; margin-top: 6px; max-width: 100%; }

.panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: #fff; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted);
  padding: 8px 6px; cursor: pointer; border-bottom: 2px solid transparent; font-size: 12.5px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab { padding: 16px; overflow-y: auto; flex: 1; }
.tab h3 { margin: 4px 0 10px; }
.tab .field + .field { margin-top: 12px; }
.tab textarea { min-height: 74px; }
.slot-meta { font-size: 11px; color: var(--faint); display: flex; justify-content: space-between; margin-top: 3px; }
.slot-meta .over { color: var(--err); font-weight: 600; }

.photo-edit { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.photo-edit img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.photo-edit .role { font-size: 12px; color: var(--muted); }
.photo-edit .acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.layout-card {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer;
}
.layout-card.active { border-color: var(--accent); background: var(--accent-soft); }
.layout-card .mini { width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 4px; background: var(--soft); position: relative; overflow: hidden; }
.layout-card .mini i { position: absolute; background: #D9DCE1; }

/* ---------- кроп ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(23, 25, 29, .5); display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.dialog { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: calc(100vh - 48px); overflow: auto; padding: 20px; }
.dialog h2 { margin-bottom: 4px; }
.crop-frame {
  position: relative; margin: 14px auto; overflow: hidden; border-radius: 6px;
  background: #EEE; cursor: grab; touch-action: none; user-select: none;
}
.crop-frame.dragging { cursor: grabbing; }
.crop-frame img { position: absolute; max-width: none; display: block; pointer-events: none; }
.crop-help { font-size: 12px; color: var(--muted); }

/* ---------- клиентская страница ---------- */
.client { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; }
.client-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.client h1 { font-size: 26px; }
.client .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 24px 0; }
@media (max-width: 640px) { .client .grid { grid-template-columns: 1fr; } }
.client .grid img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; }
.client .actions { display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; padding: 14px 0; border-top: 1px solid var(--line); }
.client .actions .btn { height: 44px; padding: 0 20px; }
.client textarea { width: 100%; }
.pay { max-width: 460px; margin: 80px auto; padding: 0 20px; }

.previews-stack { display: grid; gap: 24px; justify-items: center; }
.previews-stack iframe { width: 779px; height: 779px; border: 1px solid var(--line); background: #fff; }
