/* Прототип этапа 1 ОСА. Палитра и каркас — как в static/css/app.css портала. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2430;
  --muted: #6b7686;
  --accent: #2f6fde;
  --accent-soft: #e8f0fd;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --ok: #2f855a;
  --ok-soft: #e6f4ea;
  --sidebar: #1f2a37;
  --sidebar-text: #c9d2dd;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 24px; font-weight: 600; }
h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }

/* Каркас */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  width: 248px;
  flex-shrink: 0;
  padding: 20px 12px;
  background: var(--sidebar);
  color: var(--sidebar-text);
}

.brand {
  padding: 0 12px 20px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand:hover { text-decoration: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255, 255, 255, .12); color: #fff; }

.user {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.user-name { color: #fff; font-weight: 600; }
.user .muted { color: var(--sidebar-text); opacity: .7; }
.user label { display: block; margin-top: 12px; font-size: 12px; opacity: .7; }
.user select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  background: #273444;
  color: #fff;
  font: inherit;
  font-size: 14px;
}

.content { flex: 1; min-width: 0; padding: 24px 32px 48px; }

.proto-banner {
  margin: -8px 0 20px;
  padding: 8px 12px;
  border: 1px dashed #c7d3e6;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #234a8f;
  font-size: 13px;
}

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.crumbs { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.meta { margin-top: 4px; color: var(--muted); font-size: 14px; }

/* Вкладки */
.tabs { display: flex; gap: 24px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 8px 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { border-color: var(--accent); color: var(--text); font-weight: 600; }

/* Карточки и сетки */
.card {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card + .card { margin-top: 16px; }
.card { overflow-x: auto; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }

.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { margin-top: 2px; font-size: 26px; font-weight: 600; line-height: 1.2; }
.tile-value.name { font-size: 18px; }
.tile-sub { color: var(--muted); font-size: 13px; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; font-size: 13px; text-align: left; white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafd; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Чипы и статусы */
.chip {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  white-space: nowrap;
}
.chip.accent { border-color: #c7d8f7; background: var(--accent-soft); color: #234a8f; }
.tag { display: inline-block; margin: 0 4px 2px 0; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: #234a8f; font-size: 12px; }
.sev { display: inline-block; min-width: 92px; padding: 1px 8px; border-radius: 999px; font-size: 12px; text-align: center; white-space: nowrap; }
.sev-disaster { background: var(--danger-soft); color: var(--danger); border: 1px solid #f2b8b1; }
.sev-high { background: #fdeee4; color: #b8501c; border: 1px solid #f4c3a3; }
.sev-average { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d49b; }
.sev-warning { background: #fffbe6; color: #8a6d0b; border: 1px solid #efe1a0; }
.sev-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #b6dcc3; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; }
.dot-ok { background: var(--ok); }
.dot-bad { background: var(--danger); }
.dot-warn { background: var(--warn); }

.bar { height: 8px; border-radius: 4px; background: #dbe5f7; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* Кнопки и формы */
.button {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.button:hover { filter: brightness(1.08); text-decoration: none; }
.button.secondary { border-color: var(--border); background: var(--surface); color: var(--text); font-weight: 500; }
.button.small { padding: 3px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.form label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }

/* Боковое меню раздела (документация, админка) */
.split { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
.subnav { display: flex; flex-direction: column; gap: 2px; }
.subnav .group { margin: 12px 8px 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.subnav .group:first-child { margin-top: 0; }
.subnav a { padding: 6px 10px; border-radius: 6px; color: var(--text); font-size: 14px; }
.subnav a:hover { background: #eaeef4; text-decoration: none; }
.subnav a.active { background: var(--accent-soft); color: #234a8f; font-weight: 600; }

/* Статья */
.article h1 { margin-bottom: 4px; font-size: 22px; }
.article h2 { margin-top: 20px; }
.article p, .article li { line-height: 1.6; }
.article pre { padding: 10px 12px; border-radius: 6px; background: #f1f3f6; font-size: 13px; overflow-x: auto; }
.article code { padding: 1px 4px; border-radius: 4px; background: #f1f3f6; font-size: 13px; }
.article pre code { padding: 0; background: none; }

/* План объекта */
.plan { display: flex; align-items: center; justify-content: center; min-height: 220px; border: 1px dashed #c3cad5; border-radius: 6px; background: #fafbfc; }

/* Календарь */
.roster-wrap { overflow-x: auto; }
.roster { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.roster th { padding: 2px; border: 0; text-align: center; font-weight: 500; }
.roster th.we { color: var(--text); }
.roster th.today { color: var(--accent); font-weight: 700; }
.roster td { padding: 0; border: 0; }
.roster td.name { padding: 2px 10px 2px 0; white-space: nowrap; font-size: 13px; }
.roster td.name .muted { font-size: 11px; }
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border: 1px solid #e6e9ee;
  border-radius: 4px;
  font-size: 11px;
}
.cell.duty { border-color: #9cbcf1; background: var(--accent-soft); color: #234a8f; font-weight: 600; }
.cell.day { background: #f0f2f5; }
.cell.ot { border: 1.5px solid var(--text); font-weight: 600; }
.cell.ot.pending { border-style: dashed; }
.cell.today { box-shadow: 0 0 0 2px var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend .cell { display: inline-flex; width: 18px; height: 14px; margin-right: 6px; vertical-align: -3px; }

/* Окно и уведомления */
.modal-back { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 28, 38, .45); z-index: 20; }
.modal { width: 100%; max-width: 480px; padding: 20px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .2); }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 360px; padding: 10px 14px; border-radius: 6px; background: #1f2a37; color: #fff; font-size: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); z-index: 30; }

.placeholder { padding: 24px; border: 1px dashed #c3cad5; border-radius: var(--radius); background: #fafbfc; color: var(--muted); }
.note { margin-top: 8px; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-wide, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; }
  .content { padding: 16px; }
  .form { grid-template-columns: minmax(0, 1fr); }
}
