:root {
  --bg: #F3F1EC; --surface: #FFFFFF; --soft: #F8F6F2; --line: #E2DED5; --line2: #EEEBE4; --field: #CFCAC0;
  --ink: #1D1C1A; --ink2: #3A3833; --muted: #5F5B53;
  --accent: #0E5E57; --accent-soft: #E3EFEC; --accent-ink: #0B4F49;
  --warn: #9A4A06; --warn-soft: #FBEEDC; --warn-ink: #7A3A05;
  --ok-soft: #E4F1E8; --ok-ink: #1F5E35; --bad-soft: #F8E4E2; --bad-ink: #8E2424;
  --nav: #1D1C1A; --nav-ink: #D6D2C8; --nav-on: #3A3833;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614; --surface: #1F1E1B; --soft: #262521; --line: #34322D; --line2: #2C2A26; --field: #4A4740;
    --ink: #EDEAE3; --ink2: #D6D2C8; --muted: #A8A399;
    --accent: #3FA79C; --accent-soft: #1B3532; --accent-ink: #8FD6CC;
    --warn: #E8A24A; --warn-soft: #3A2A14; --warn-ink: #F2C58A;
    --ok-soft: #1C3324; --ok-ink: #8FD3A5; --bad-soft: #3A1C1C; --bad-ink: #F0A3A3;
    --nav: #0F0F0E; --nav-ink: #C9C4B9; --nav-on: #2B2A27;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.layout { display: flex; min-height: 100vh; }
nav.side { width: 232px; flex-shrink: 0; background: var(--nav); color: #EDEAE3; padding: 28px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.brand b { display: block; font-size: 17px; }
.brand span { font-size: 13px; color: #B7B2A7; }
.navlist { display: flex; flex-direction: column; gap: 4px; }
.navlist button { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-radius: 8px; border: none; background: transparent; color: var(--nav-ink); text-align: left; font-size: 15px; }
.navlist button.on { background: var(--nav-on); color: #FFF; font-weight: 600; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #E8A24A; color: #1D1C1A; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.mode { margin-top: auto; padding: 14px; border-radius: 10px; background: #2B2A27; font-size: 13px; }
.mode b { display: flex; align-items: center; gap: 8px; }
.mode p { margin: 6px 0 10px; font-size: 12px; color: #B7B2A7; }
.mode button { border: none; background: none; padding: 0; color: #B7B2A7; font-size: 12px; text-decoration: underline; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; display: inline-block; }

main { flex-grow: 1; min-width: 0; padding: 32px 40px; display: flex; flex-direction: column; gap: 24px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.card.flush { padding: 0; overflow: hidden; gap: 0; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kpi .v { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .l, .kpi .n { font-size: 13px; color: var(--muted); }
.banner { display: flex; align-items: center; gap: 20px; padding: 18px 22px; border-radius: 12px; background: var(--warn-soft); border: 1px solid #EBCFA6; color: var(--warn-ink); }
.banner div { flex-grow: 1; }
.banner b { display: block; }

.row { display: flex; gap: 12px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--line2); }
.row:first-of-type { border-top: none; padding-top: 0; }

.btn { height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--field); background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFF; }
.btn.warn { border-color: var(--warn); color: var(--warn-ink); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.link { border: none; background: none; padding: 0; height: auto; color: var(--accent); }
.btn.danger { color: var(--bad-ink); }
.pill { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); font-size: 13px; }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }

.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip.bad { background: var(--bad-soft); color: var(--bad-ink); }
.chip.off { background: var(--line2); color: var(--muted); }
.chip.info { background: var(--accent-soft); color: var(--accent-ink); }
.chip.dark { background: var(--ink); color: var(--bg); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--soft); padding: 12px 16px; }
td { padding: 12px 16px; border-top: 1px solid var(--line2); vertical-align: middle; }
tr.fix td { background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
tr.off td { color: var(--muted); }
.tablewrap { overflow-x: auto; }
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

form.editor { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select { height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--field); background: var(--surface); }
.field .hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; }
.formfoot { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.formfoot .actions { margin-left: auto; }
.error { color: var(--bad-ink); font-size: 14px; }

.tickets { display: flex; gap: 20px; align-items: flex-start; }
/* .card.tlist — иначе overflow:hidden у .card.flush перебивает прокрутку */
.card.tlist { width: 400px; flex-shrink: 0; max-height: calc(100vh - 200px); overflow-y: auto; position: sticky; top: 24px; }
.tlist button { width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; border: none; border-top: 1px solid var(--line2); background: var(--surface); text-align: left; }
.tlist button.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.tlist .top { display: flex; justify-content: space-between; }
.tlist .chips { display: flex; gap: 6px; }
.tdetail { flex-grow: 1; min-width: 0; padding: 24px 26px; gap: 18px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--soft); font-size: 13px; }
.facts span { display: block; color: var(--muted); }
.facts b { font-weight: 600; word-break: break-word; }
ol.timeline { margin: 0; padding: 0; list-style: none; }
ol.timeline li { display: flex; gap: 14px; }
ol.timeline .rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex-shrink: 0; }
ol.timeline .rail i { width: 12px; height: 12px; border-radius: 6px; margin-top: 4px; background: var(--accent); }
ol.timeline .rail s { width: 2px; flex-grow: 1; background: var(--line); margin: 4px 0; }
ol.timeline li:last-child .rail s { display: none; }
ol.timeline .body { padding-bottom: 16px; white-space: pre-line; }
.checks { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; }
.check-row .mark { width: 20px; height: 20px; border-radius: 10px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.mark.ok { background: var(--ok-soft); color: var(--ok-ink); }
.mark.warn { background: var(--warn-soft); color: var(--warn-ink); }
.mark.bad { background: var(--bad-soft); color: var(--bad-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
select.filter { height: 36px; padding: 0 10px; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); font-size: 13px; max-width: 240px; }
select.filter.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.search { height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); width: 220px; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos:empty { display: none; }
.photos img { cursor: zoom-in; }

dialog.viewer { width: min(1100px, 94vw); height: min(860px, 92vh); max-width: none; max-height: none; padding: 0; border: none; border-radius: 12px; background: #141413; color: #EDEAE3; display: flex; flex-direction: column; overflow: hidden; }
dialog.viewer:not([open]) { display: none; }
dialog.viewer::backdrop { background: rgba(10, 10, 9, 0.72); }
dialog.viewer .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; }
dialog.viewer .bar .small { color: #B7B2A7; font-weight: 400; margin-left: 8px; }
dialog.viewer .bar .btn { background: #2B2A27; border-color: #4A4740; color: #EDEAE3; text-decoration: none; display: inline-flex; align-items: center; }
dialog.viewer .stage { flex-grow: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 8px 56px 20px; }
dialog.viewer .stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #FFF; }
dialog.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: none; border-radius: 8px; background: #2B2A27; color: #EDEAE3; font-size: 30px; line-height: 1; }
dialog.viewer .nav.prev { left: 8px; }
dialog.viewer .nav.next { right: 8px; }
.photos img { width: 160px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; background: var(--soft); }

.bar { width: 140px; height: 8px; border-radius: 4px; background: var(--line2); overflow: hidden; display: inline-flex; vertical-align: middle; margin-right: 10px; }
.bar i { height: 8px; background: var(--accent); }
.bar i.slow { background: #C77A12; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 100%; max-width: 380px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  nav.side { width: auto; height: auto; position: static; padding: 12px 16px; gap: 12px; }
  .navlist { flex-direction: row; overflow-x: auto; }
  .navlist button { flex-shrink: 0; }
  .mode { margin-top: 0; }
  main { padding: 20px 16px; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, form.editor, .facts { grid-template-columns: 1fr; }
  .tickets { flex-direction: column; }
  .card.tlist { width: 100%; max-height: 360px; position: static; }
  .tdetail { width: 100%; }
}
