:root {
  --ink: #1F2328; --ink2: #475467; --muted: #8A94A6; --line: #E4E7EC; --bg: #F2F3F5; --card: #fff;
  --brand: #FBD558; --dark: #1F2328; --ok: #12B76A;
  --critical: #D92D20; --recommended: #E0A100; --deeper_inspection: #2E6FD8; --observations: #8A94A6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Noto Sans", -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans-SemiBold.ttf"); font-weight: 600; }
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans-Bold.ttf"); font-weight: 700; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* верхняя панель */
.topbar { height: 56px; background: var(--dark); color: #fff; display: flex; align-items: center; padding: 0 18px;
          border-bottom: 3px solid var(--brand); gap: 18px; position: sticky; top: 0; z-index: 20; }
.topbar img { height: 32px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; color: #C9CED6; font-weight: 600; }
.topbar nav a.on, .topbar nav a:hover { background: #2B3138; color: #fff; }
.topbar .sp { flex: 1; }
.topbar form button { background: none; border: 0; color: #C9CED6; cursor: pointer; }

.page { max-width: 1180px; margin: 24px auto; padding: 0 18px; }
h1 { font-size: 22px; margin: 0 0 16px; }
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
       padding: 7px 13px; cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c5cbd4; }
.btn.primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn.primary:hover { background: #343a42; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: var(--ink); }
.btn.danger { color: var(--critical); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #FBD55899; border-color: #e0b93c; }
label.f { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin: 10px 0 4px; }

.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* список отчётов */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input { max-width: 320px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.row { cursor: pointer; }
table.list tr.row:hover td { background: #FAFBFC; }
.counts { display: flex; gap: 6px; }
.counts span { min-width: 26px; text-align: center; border-radius: 6px; color: #fff; font-weight: 700; font-size: 12px; padding: 2px 6px; }
.counts span.z { opacity: .18; }
.status-processing { background: #EEF4FF; color: #2E6FD8; }
.status-review { background: #FFFAEB; color: #B54708; }
.status-approved { background: #ECFDF3; color: #067647; }
.status-failed { background: #FEF3F2; color: #B42318; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* вход */
.login { max-width: 360px; margin: 12vh auto; padding: 28px; text-align: center; }
.login img { height: 70px; background: var(--dark); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.login .err { color: var(--critical); margin: 8px 0; }

/* редактор */
.editor { display: grid; grid-template-columns: 330px 1fr 330px; height: calc(100vh - 56px - 58px); }
.ebar { height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.ebar .title { font-weight: 700; font-size: 16px; }
.ebar .sub { color: var(--muted); font-size: 13px; }
.ebar .sp { flex: 1; }
.save-state { font-size: 12px; color: var(--muted); min-width: 92px; text-align: right; }
.save-state.err { color: var(--critical); }
.tabs { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink2); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px #0002; }
.tabs button.stale::after { content: " ⚠"; color: var(--recommended); }
.tabs button.missing { color: #b8bec8; }

.pane { overflow-y: auto; padding: 16px; }
.pane.left { background: #fff; border-right: 1px solid var(--line); }
.pane.right { background: #fff; border-left: 1px solid var(--line); }
.pane h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; }
.pane h3:first-child { margin-top: 0; }
.cover-prev { position: relative; aspect-ratio: 3/2; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff;
              display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.cover-prev img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.cover-prev span { position: absolute; left: 6px; bottom: 4px; font-size: 11px; color: var(--muted); background: #fffc; padding: 0 4px; border-radius: 4px; }
.cover-empty { color: var(--muted); font-size: 12px; padding: 12px; text-align: center; }
#coverSel { margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.confirm { display: flex; gap: 8px; align-items: center; margin-top: 6px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.confirm.no { background: #FEF3F2; color: #B42318; }
.confirm.yes { background: #ECFDF3; color: #067647; }
.crmname { font-size: 12px; color: var(--muted); margin-top: 4px; }
.drive-sel { display: flex; gap: 4px; }
.drive-sel button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 4px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--ink2); }
.drive-sel button.on { color: #fff; }
.voice { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.voice .h { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.voice audio { width: 100%; height: 32px; margin-top: 6px; }
.voice.failed { border-color: #FDA29B; background: #FEF3F2; }
.checklist div { font-size: 13px; padding: 2px 0; }

.center { padding: 16px 20px 80px; overflow-y: auto; }
.notes { background: #FFFAEB; border: 1px solid #FEDF89; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.notes b { display: block; margin-bottom: 4px; color: #B54708; }
.notes li { margin: 2px 0; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: #FFFAEB; border: 1px solid #FEDF89; }
.banner.info { background: #EFF4FF; border: 1px solid #B2CCFF; }
.banner.err { background: #FEF3F2; border: 1px solid #FDA29B; }
.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

.dcard { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: var(--radius); margin-bottom: 12px; }
.dcard .dh { display: flex; align-items: center; gap: 8px; padding: 10px 12px 0; }
.dcard .handle { cursor: grab; color: #c0c6cf; font-size: 18px; user-select: none; }
.dcard .num { font-weight: 700; color: var(--muted); }
.dcard select.cat { width: auto; font-weight: 700; color: var(--c); border-color: transparent; background: color-mix(in srgb, var(--c) 10%, #fff); }
.dcard .db { padding: 6px 12px 12px; }
.dcard .row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.dcard input.node { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink2); }
.dcard input.comp { font-weight: 700; font-size: 15px; }
.dcard .lbl { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 8px 0 3px; }
.dcard textarea { min-height: 44px; }
.quote { font-size: 12px; color: var(--ink2); background: var(--bg); border-radius: 6px; padding: 5px 8px; margin-top: 8px; }
.quote b { color: var(--muted); }
.dcard.readonly select.cat { pointer-events: none; }

.strip { display: flex; flex-wrap: wrap; gap: 6px; min-height: 64px; padding: 6px; margin-top: 8px; border: 1.5px dashed #D0D5DD; border-radius: 8px; background: #FAFBFC; }
.strip.empty::before { content: "Перетащите фото из галереи справа"; color: var(--muted); font-size: 12px; align-self: center; margin: 0 auto; }
.ph { position: relative; width: 84px; height: 64px; border-radius: 6px; overflow: hidden; cursor: grab; flex: none; background: #ddd; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph .lb { position: absolute; left: 3px; bottom: 3px; background: #000a; color: #fff; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; }
.ph .x { position: absolute; right: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #000b; color: #fff; font-size: 12px; line-height: 18px; cursor: pointer; padding: 0; display: none; }
.ph:hover .x { display: block; }

.okcard { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--ok); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.okcard .row2 { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; align-items: start; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-size: 15px; margin: 0; }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gitem { position: relative; border-radius: 8px; overflow: hidden; border: 2px solid transparent; cursor: grab; background: #ddd; aspect-ratio: 4/3; }
.gitem img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.gitem.unassigned { border-color: var(--recommended); }
.gitem .lb { position: absolute; left: 5px; top: 5px; background: #000a; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.gitem .uses { position: absolute; left: 5px; bottom: 5px; display: flex; gap: 3px; }
.gitem .uses span { background: #fff; color: var(--ink); font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; border-left: 3px solid var(--c); }
.gitem .zoom { position: absolute; right: 5px; top: 5px; width: 24px; height: 24px; border-radius: 6px; border: 0; background: #000a; color: #fff; cursor: pointer; }
.gitem .cap { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, #000c); color: #fff; font-size: 11px; padding: 14px 6px 4px; display: none; }
.gitem:hover .cap { display: block; }
.legend { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.sortable-ghost { opacity: .35; }
.drop-hover { border-color: var(--brand) !important; background: #FFFBEA !important; }

.lightbox { position: fixed; inset: 0; background: #000e; z-index: 50; display: none; align-items: center; justify-content: center; flex-direction: column; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; }
.lightbox .meta { color: #fff; margin-top: 10px; font-size: 14px; }
.lightbox button { position: absolute; top: 50%; background: #fff2; color: #fff; border: 0; font-size: 34px; width: 52px; height: 72px; border-radius: 8px; cursor: pointer; }
.lightbox .prev { left: 20px; } .lightbox .next { right: 20px; }
.lightbox .close { top: 20px; right: 20px; height: 52px; font-size: 26px; }

.modal-bg { position: fixed; inset: 0; background: #0008; z-index: 40; display: none; align-items: center; justify-content: center; }
.modal-bg.on { display: flex; }
.modal { background: #fff; border-radius: 12px; width: min(640px, 94vw); max-height: 88vh; overflow: auto; padding: 22px; }
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal pre { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 12px; font: 13px/1.5 "Noto Sans", sans-serif; max-height: 46vh; overflow: auto; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal ul { padding-left: 18px; }
.processing { text-align: center; padding: 80px 20px; color: var(--ink2); }
.spinner { width: 36px; height: 36px; border: 4px solid #E4E7EC; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; display: none; max-width: 80vw; }
.toast.on { display: block; }
.toast.err { background: #B42318; }

/* механики */
.mech-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.mech-form { padding: 16px; }
.req { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; }
.req .who { flex: 1; }
.req small, .muted { color: var(--muted); }
