:root {
  --bg: #f6f4ef; --card: #ffffff; --line: #e6e2d9; --line2: #efece6;
  --ink: #17181b; --muted: #6a6e76; --soft: #f1eee7;
  --accent: #111214; --peach: #f2a65a; --peach-bg: #fdf1e4;
  --ok: #1f8a4c; --ok-bg: #e7f5ec; --warn: #b26a00; --warn-bg: #fdf3df;
  --bad: #c0392b; --bad-bg: #fbeae7; --info: #2f5fb3; --info-bg: #e9f0fb; --gray-bg: #f0efec;
  --r: 14px; --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 6px 24px rgba(20, 20, 20, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Noto Sans", sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; } h3 { font-size: 15px; }

.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='m10 16 4 4 8-8' stroke='%23f2a65a' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/70% no-repeat; flex: none; }
.logo-mark.sm { width: 34px; height: 34px; border-radius: 10px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; animation: rise .4s ease both; }
.login-card h1 { font-size: 24px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: rgba(246, 244, 239, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand div { display: grid; line-height: 1.2; }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.tabs button:hover { background: var(--soft); color: var(--ink); }
.tabs button.on { background: var(--accent); color: #fff; }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--peach); color: #111; font-size: 12px; text-align: center; }
.pill:empty { display: none; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; display: grid; gap: 18px; animation: fade .25s ease both; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 + *, .card > h3 + * { margin-top: 12px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: stretch; }
.hero .card.dark { background: var(--accent); color: #f4f2ee; border-color: var(--accent); align-content: center; gap: 16px; }
.hero .card.dark .muted { color: #a9acb3; }
.hero h1 { font-size: 26px; line-height: 1.2; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); cursor: default; transition: transform .15s ease, box-shadow .15s ease; animation: rise .35s ease both; }
.kpi:hover { transform: translateY(-2px); }
.kpi b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.kpi.hot { background: var(--peach-bg); border-color: #f4d3ae; }
.kpi.bad b { color: var(--bad); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 11px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .1s ease, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: #cfcabe; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #2a2c30; }
.btn.peach { background: var(--peach); border-color: var(--peach); color: #111; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #b9b3a6; box-shadow: 0 0 0 3px rgba(242, 166, 90, .18); }
textarea { min-height: 84px; resize: vertical; }
label.f { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
label.f > span { font-weight: 600; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--muted); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--gray-bg); color: #444; white-space: nowrap; }
.card p .chip { white-space: normal; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.peach { background: var(--peach-bg); color: #9a4f08; }
.chip.dark { background: var(--accent); color: #fff; }
.mp { font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 6px; color: #fff; letter-spacing: .02em; }
.mp.wb { background: #8a1f9b; } .mp.ozon { background: #0b5bf0; }

/* log */
.log { background: #14161a; color: #d6d8dc; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 12px; padding: 12px 14px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* lists */
.how { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.how ul { margin: 8px 0 0; padding-left: 18px; }
.how li { margin: 4px 0; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--peach); border-radius: 99px; transition: width .5s ease; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line2); vertical-align: middle; font-size: 13.5px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* incidents */
.filters { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr) auto; gap: 10px; align-items: end; }
.inc-list { display: grid; gap: 10px; }
.inc { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; animation: rise .3s ease both; }
.inc:hover { border-color: #cfc8b8; transform: translateY(-1px); box-shadow: var(--shadow); }
.thumb { width: 64px; height: 84px; border-radius: 10px; background: var(--soft) center/cover no-repeat; border: 1px solid var(--line2); }
.inc .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.inc .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.inc .side { display: grid; gap: 6px; justify-items: end; text-align: right; }
.timer { font-size: 12.5px; font-weight: 600; }
.timer.over { color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* refs */
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ref { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: grid; animation: rise .3s ease both; }
.ref .img { aspect-ratio: 3/4; background: var(--soft) center/cover no-repeat; }
.ref .b { padding: 8px; display: grid; gap: 6px; font-size: 12.5px; }
.drop { border: 1.5px dashed #d3cdc0; border-radius: 14px; padding: 18px; text-align: center; background: #fbfaf7; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(17, 18, 20, .45); display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 32px 16px; animation: fade .15s ease both; }
.modal-box { width: 100%; max-width: 980px; background: var(--bg); border-radius: 20px; padding: 20px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: rise .25s ease both; }
.cmp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.cmp figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.cmp img { width: 100%; max-height: 360px; object-fit: contain; border-radius: 8px; background: var(--soft); }
.cmp figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.cmp .vs { display: grid; justify-items: center; gap: 4px; font-weight: 800; font-size: 22px; }
.cmp .vs small { font-size: 12px; color: var(--muted); font-weight: 600; }
.noimg { aspect-ratio: 3/4; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--soft); border-radius: 8px; padding: 10px; }
.ev img { width: 100%; max-height: 300px; object-fit: cover; object-position: top; border-radius: 10px; border: 1px solid var(--line); }
.claim-field { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.claim-field .v { white-space: pre-wrap; font-size: 13.5px; overflow-wrap: anywhere; }
.modal-box > *, .card, .stack > *, .grid > * { min-width: 0; }
.modal-box a, .card li, .copyable, .hist, code { overflow-wrap: anywhere; }
.copyable { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; white-space: pre-wrap; font-size: 13.5px; max-height: 320px; overflow: auto; }
.hist { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.x { margin-left: auto; }
.wl-row { display: grid; grid-template-columns: 110px 1fr 1.4fr auto; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: rise .2s ease both; }
.toast.bad { background: var(--bad); }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: currentColor; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; }
.demo-tag { background: repeating-linear-gradient(45deg, #fff4e6, #fff4e6 6px, #fdebd3 6px, #fdebd3 12px); color: #8a4a06; }

@keyframes sp { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .hero, .g2, .g3, .how { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .tabs { order: 3; width: 100%; margin: 0; }
  #logout { margin-left: auto; }
  main { padding: 16px 16px 48px; gap: 14px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .hero h1 { font-size: 21px; }
  .inc { grid-template-columns: 56px 1fr; }
  .inc .side { grid-column: 1 / -1; justify-items: start; text-align: left; display: flex; flex-wrap: wrap; gap: 8px; }
  .thumb { width: 56px; height: 74px; }
  .cmp { grid-template-columns: 1fr 1fr; }
  .cmp .vs { grid-column: 1 / -1; order: 3; }
  .modal { padding: 0; }
  .modal-box { border-radius: 0; min-height: 100vh; padding: 16px; }
  .wl-row { grid-template-columns: 1fr 1fr; }
  .wl-row input:nth-of-type(2) { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}
