:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --error: #b91c1c;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1d2128;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #2d333c;
    --accent: #3b82f6;
    --ok: #4ade80;
    --ok-bg: #133321;
    --error: #f87171;
    --warn-bg: #3a2a0c;
    --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 8px; }
[hidden] { display: none !important; }

.btn {
  font: inherit;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
input {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}
.error { color: var(--error); margin: 8px 0; }
.ok { color: var(--ok); margin: 8px 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.placeholder { color: var(--muted); padding: 24px 0; }

/* вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px;
}
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }

/* шапка */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; }
.on-shift { flex: 1; color: var(--muted); min-width: 180px; }
.shift-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg { font: inherit; padding: 6px 12px; border: 0; background: var(--panel); color: var(--muted); cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.active { color: var(--text); font-weight: 600; }
#shift-on.active { background: var(--ok-bg); color: var(--ok); }
.me { color: var(--muted); }

/* раскладка */
.layout { display: flex; min-height: calc(100vh - 54px); }
.sidebar { width: 190px; padding: 16px 10px; border-right: 1px solid var(--line); background: var(--panel); }
.sidebar a {
  display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--accent); color: var(--accent-text); }
.content { flex: 1; padding: 24px; min-width: 0; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { font: inherit; padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* заявки */
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--line); color: var(--text); font-size: 12px; text-align: center; }
.tab[data-tab="new"] .count.hot { background: var(--error); color: #fff; }
.requests { display: grid; gap: 12px; margin-top: 16px; }
.req { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.req.unclaimed { border-left: 4px solid var(--error); }
.req-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 8px; }
.req-no { font-weight: 700; font-size: 17px; }
.req-meta { color: var(--muted); }
.req-info { white-space: pre-wrap; word-break: break-word; background: var(--bg); border-radius: var(--radius); padding: 10px 12px; margin: 6px 0 10px; }
.req-media { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.req-media img, .req-media video { max-width: 220px; max-height: 220px; border-radius: 6px; display: block; background: var(--line); }
.req-media audio { max-width: 280px; }
.req-facts { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 10px; }
.req-facts span { color: var(--muted); }
.req-facts b { font-weight: 600; }
.req-state { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.req-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.req-actions .note { color: var(--muted); font-size: 13px; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--error); border-color: var(--error); color: #fff; }
.shots { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.shots-previews { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.shot { position: relative; }
.shot img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; display: block; }
.shot button { position: absolute; top: 2px; right: 2px; padding: 0 6px; font-size: 13px; }
.file-label { display: inline-block; }
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
/* переписка */
.count.msg { background: var(--warn-bg); color: var(--warn); }
.badge-new { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 600; }
.chat { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.chat summary { cursor: pointer; display: flex; gap: 8px; align-items: center; color: var(--muted); padding: 4px 0; }
.chat[open] summary { margin-bottom: 8px; }
.feed { display: grid; gap: 6px; max-height: 360px; overflow-y: auto; padding: 2px; }
.msg { max-width: 85%; padding: 6px 10px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); }
.msg.manager { justify-self: end; background: var(--panel); }
.msg.member { justify-self: start; }
.msg.fix { border-color: var(--warn); background: var(--warn-bg); }
.msg.warn { border-color: var(--error); }
.msg.old { opacity: .65; }
.msg-head { display: flex; gap: 10px; justify-content: space-between; font-size: 12px; color: var(--muted); }
.msg.fix .msg-who { color: var(--warn); font-weight: 600; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg .req-media { margin: 6px 0 2px; }
.msg .req-media img, .msg .req-media video { max-width: 160px; max-height: 160px; }
.composer { display: grid; gap: 8px; margin-top: 10px; }
.composer textarea { font: inherit; width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); resize: vertical; }
.btn.warn { border-color: var(--error); color: var(--error); }
.alerts { display: flex; gap: 6px; }
.alerts .btn.on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.field { display: grid; gap: 6px; margin: 8px 0 12px; color: var(--muted); font-size: 14px; }
select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.leave-list { display: grid; gap: 8px; margin: 8px 0 12px; }
.leave-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--bg); border-radius: var(--radius); }

/* менеджеры */
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list th, .list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th { font-size: 13px; color: var(--muted); font-weight: 500; }
.list tr.disabled td { color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* история, участники, команды */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.filters .grow { flex: 1 1 220px; }
.filters select, .filters input { max-width: 100%; min-width: 0; }
.filters .grow input { width: 100%; }
.filters select { max-width: 220px; }
.table-wrap { overflow-x: auto; }
.list.clickable tbody tr:not(.group) { cursor: pointer; }
.list.clickable tbody tr:not(.group):hover td { background: var(--bg); }
.list tr.group td { background: var(--bg); font-weight: 600; }
.list tr.group .count { font-weight: 400; }
.list td.num { white-space: nowrap; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 13px; background: var(--line); color: var(--text); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: transparent; border: 1px solid var(--error); color: var(--error); }
.tag.wait { background: var(--warn-bg); color: var(--warn); }
dialog.wide { max-width: 760px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
.history-card .feed { max-height: none; overflow: visible; }
.history-card .req-head { margin-right: 4px; }
.who-list, .team-members { display: grid; gap: 4px; margin: 0 0 8px; }
.who-list div span, .team-members div span { color: var(--muted); }

/* настройки */
.settings { max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.settings .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num { width: 80px; }
fieldset { border: 0; padding: 0; margin: 8px 0 12px; }
legend { padding: 0; margin-bottom: 6px; }
.radio { display: flex; gap: 8px; align-items: center; padding: 3px 0; }

/* диалог */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 460px; width: calc(100% - 32px); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; padding: 10px; background: var(--bg); border-radius: var(--radius); word-break: break-all; user-select: all; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; display: flex; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .alerts { flex-wrap: wrap; }
  .filters label { flex: 1 1 140px; }
  .filters select { max-width: none; width: 100%; }
  .filters input { width: 100%; }
  .labeled td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  .labeled td:empty { display: none; }
  .list td { overflow-wrap: anywhere; }
  .msg { max-width: 100%; }
  .req-media img, .req-media video { max-width: 100%; }
  .req-media audio { max-width: 100%; }
  .content { padding: 16px; }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; }
  .list tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .list td { border: 0; padding: 3px 12px; }
  .actions { justify-content: flex-start; }
}
