:root {
  --bg: #f6f4f1; --surface: #fff; --ink: #1f2a2e; --muted: #687478; --line: #e3dfd8;
  --accent: #1f6f6b; --accent-ink: #fff; --accent-soft: #e2f0ee;
  --warn: #9a5b00; --warn-soft: #fff3df; --danger: #b3261e; --danger-soft: #fdeceb;
  --ok: #1c7a3c; --ok-soft: #e5f4ea; --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font) }
button, input, select, textarea { font: inherit; color: inherit }
a { color: var(--accent) }
h1 { font-size: 22px; margin: 0 0 4px } h2 { font-size: 17px; margin: 0 0 10px } h3 { font-size: 15px; margin: 0 }
.muted { color: var(--muted) } .small { font-size: 13px }

/* каркас */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh }
.brand { padding: 0 8px 16px } .brand b { display: block; font-size: 16px } .brand span { color: var(--muted); font-size: 13px }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; border: 0; background: none; text-align: left; cursor: pointer; width: 100% }
.nav:hover { background: var(--bg) } .nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600 }
.nav .count { margin-left: auto; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 7px; font-size: 12px; font-weight: 600 }
.side-foot { margin-top: auto; padding: 10px; font-size: 13px; color: var(--muted) }
.main { padding: 24px 28px 90px; max-width: 1000px; width: 100% }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap }

/* элементы */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px }
.grid { display: grid; gap: 14px } .grid.cols3 { grid-template-columns: repeat(3, 1fr) } .grid.cols2 { grid-template-columns: repeat(2, 1fr) }
.stat b { display: block; font-size: 22px } .stat span { color: var(--muted); font-size: 13px }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 14px; cursor: pointer; min-height: 38px }
.btn:hover { border-color: #cfc9bf } .btn:disabled { opacity: .5; cursor: default }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn.primary:hover { filter: brightness(1.08) }
.btn.danger { color: var(--danger) } .btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.badge { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted) }
.badge.ok { background: var(--ok-soft); color: var(--ok) } .badge.warn { background: var(--warn-soft); color: var(--warn) }
.badge.danger { background: var(--danger-soft); color: var(--danger) } .badge.accent { background: var(--accent-soft); color: var(--accent) }
.field { display: grid; gap: 5px; margin-bottom: 14px } .field > span { font-weight: 600; font-size: 14px } .field small { color: var(--muted) }
input[type=text], input[type=password], input[type=time], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; width: 100%; min-height: 38px }
textarea { resize: vertical; min-height: 70px; line-height: 1.45 }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .nav:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.radio { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft) }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer }
.notice { border-radius: 10px; padding: 10px 14px; background: var(--warn-soft); color: var(--warn); font-size: 14px }
.notice.info { background: var(--accent-soft); color: var(--accent) } .notice.error { background: var(--danger-soft); color: var(--danger) }
table.days { border-collapse: collapse; width: 100% } table.days td { padding: 4px 6px; border-bottom: 1px solid var(--line) } table.days input[type=time] { width: 110px }

/* записи */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink) }
.entry { padding: 14px 16px; border-bottom: 1px solid var(--line) } .entry:last-child { border-bottom: 0 }
.entry-top { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap }
.entry p { margin: 6px 0 8px; color: var(--muted); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden }
.entry.deleted h3 { text-decoration: line-through; color: var(--muted) }
.group-title { padding: 12px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg) }

/* окно */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px) }
dialog::backdrop { background: rgba(20, 28, 30, .45) }
.dlg { padding: 20px 22px } .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff }
.version { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px } .version pre { white-space: pre-wrap; font: inherit; margin: 8px 0; max-height: 220px; overflow: auto }

/* проверка */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 260px; max-height: 60vh; overflow: auto; padding: 16px; background: #efeae2; border-radius: var(--radius) }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.06) }
.bubble.client { align-self: flex-end; background: #d9fdd3 } .bubble.bot { align-self: flex-start; background: #fff }
.bubble.manager { align-self: flex-start; background: #fff7e0 }
.bubble small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px }
.meta-box { margin-top: 6px; font-size: 12px; color: var(--muted); align-self: flex-start; max-width: 80% }
.composer { display: flex; gap: 8px; margin-top: 10px } .composer textarea { min-height: 44px; height: 44px }
pre.prompt { white-space: pre-wrap; font: 13px/1.5 ui-monospace, monospace; background: var(--bg); padding: 14px; border-radius: 10px; max-height: 60vh; overflow: auto }

/* публикация */
.publish-bar { position: fixed; left: 230px; right: 0; bottom: 0; background: var(--ink); color: #fff; padding: 12px 28px; display: flex; gap: 12px; align-items: center; justify-content: space-between; z-index: 5 }
.publish-bar .btn { border-color: transparent; color: var(--ink) }
.publish-bar .btn.primary { color: var(--accent-ink) }
.toast { position: fixed; top: 16px; right: 16px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 360px }
.toast.error { background: var(--danger) }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px }
.login .card { width: min(380px, 100%) }

.audit-row { display: grid; grid-template-columns: 150px 120px 1fr; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: 14px }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line) }
  .brand, .side-foot { display: none } .nav { white-space: nowrap; width: auto }
  .main { padding: 16px 16px 100px }
  .grid.cols3, .grid.cols2 { grid-template-columns: 1fr }
  .publish-bar { left: 0; padding: 10px 16px; flex-wrap: wrap }
  .audit-row { grid-template-columns: 1fr; gap: 2px }
  .bubble, .meta-box { max-width: 92% }
}
