/* Оформление панели администратора.
   Цвета — те же, что в мобильном приложении: корпоративный красный.
   Тёмная тема включается по данным операционной системы. */

:root {
  --red: #c62828;
  --red-dark: #8e1c1c;
  --red-soft: #fdecea;

  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --line: #e2e5ea;
  --line-strong: #cfd4db;
  --text: #1b1f24;
  --text-dim: #656d78;
  --text-faint: #8d95a1;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 8px 24px rgba(16, 20, 26, .07);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --panel-2: #21252c;
    --line: #2c313a;
    --line-strong: #3a414c;
    --text: #e8eaed;
    --text-dim: #a3abb8;
    --text-faint: #79818e;
    --red-soft: #3a1e1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ----------------------------------------------------------------- вход */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(198, 40, 40, .12), transparent 60%),
    var(--bg);
}

.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px 28px 24px;
}

.login__logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 16px;
}

.login__title { margin: 0; font-size: 19px; }
.login__sub { margin: 4px 0 20px; color: var(--text-dim); }
.login__hint { margin: 16px 0 0; font-size: 12px; color: var(--text-faint); }

/* ------------------------------------------------------------- каркас */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100%;
}

.side {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 0; }

.side__mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}

.side__name { font-weight: 600; letter-spacing: .2px; }

.side__nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
}

.nav__item:hover { background: var(--panel-2); color: var(--text); }
.nav__item.is-active { background: var(--red-soft); color: var(--red); font-weight: 600; }
.nav__ico { width: 18px; text-align: center; opacity: .85; }

.side__user { border-top: 1px solid var(--line); padding-top: 12px; }
.side__who { display: flex; align-items: center; gap: 10px; }
.side__whoText { min-width: 0; }
.side__whoText > div:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__role { color: var(--text-faint); font-size: 12px; }
.side__acts { display: flex; gap: 6px; margin-top: 10px; }

.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
}

.main { padding: 20px 24px 48px; min-width: 0; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}

.top__title { margin: 0; font-size: 20px; }
.top__right { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- кнопки */

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--panel-2); color: var(--text); }
.btn--danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn--danger:hover { background: var(--red-soft); }
.btn--wide { width: 100%; margin-top: 6px; padding: 11px 14px; }
.btn--sm { padding: 5px 10px; font-size: 13px; }

/* -------------------------------------------------------------- блоки */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.card__title { margin: 0; font-size: 15px; }
.card__sub { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* --------------------------------------------------------------- цифры */

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat__num { font-size: 26px; font-weight: 650; letter-spacing: -.5px; }
.stat__label { color: var(--text-dim); font-size: 13px; }
.stat__note { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* -------------------------------------------------------------- таблицы */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--text-dim); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--panel-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table__wrap { max-height: 62vh; overflow: auto; }

.person { display: flex; align-items: center; gap: 10px; }
.person__name { font-weight: 550; }
.person__sub { color: var(--text-faint); font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}

.tag--ok { color: var(--ok); border-color: rgba(31, 138, 76, .4); background: rgba(31, 138, 76, .1); }
.tag--warn { color: var(--warn); border-color: rgba(178, 106, 0, .4); background: rgba(178, 106, 0, .1); }
.tag--bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.tag--live { color: var(--ok); border-color: rgba(31, 138, 76, .4); }
.tag--live::before { content: '●'; margin-right: 5px; font-size: 10px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--line-strong); }
.dot--on { background: var(--ok); }

.muted { color: var(--text-faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* -------------------------------------------------------------- формы */

.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
.field__hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  min-width: 0;
}

.input:focus, .select:focus, .textarea:focus { outline: 2px solid rgba(198, 40, 40, .35); outline-offset: -1px; border-color: var(--red); }
.textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.input--search { max-width: 320px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .select, .toolbar .input { width: auto; min-width: 150px; }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--red); }

/* -------------------------------------------------------------- окно */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal__back { position: absolute; inset: 0; background: rgba(12, 14, 18, .5); }
.modal__box {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.modal__box--wide { max-width: 820px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal__head h2 { margin: 0; font-size: 16px; }
.modal__x { border: 0; background: transparent; font-size: 15px; cursor: pointer; color: var(--text-dim); padding: 4px 6px; }
.modal__body { padding: 16px; overflow: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ сообщения */

.alert { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert--error { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }
.alert--info { background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim); }
.alert--ok { background: rgba(31, 138, 76, .12); border: 1px solid rgba(31, 138, 76, .4); color: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 90vw;
}
.toast--bad { background: var(--red); color: #fff; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-faint); }

.list { display: flex; flex-direction: column; }
.list__row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list__row:last-child { border-bottom: 0; }

/* ------------------------------------------------------------- загрузка */

.drop {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--text-dim);
  background: var(--panel-2);
  cursor: pointer;
}
.drop:hover, .drop.is-over { border-color: var(--red); color: var(--red); }
.drop__title { font-weight: 600; color: var(--text); }

.result { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result__sum { display: flex; gap: 16px; padding: 12px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--red); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; }
  .side__nav { flex-direction: row; flex-wrap: wrap; }
  .nav__item { font-size: 13px; }
  .main { padding: 16px; }
}

@media (max-width: 600px) {
  html, body { font-size: 15px; }
  .main { padding: 12px; }
  .top { flex-direction: column; align-items: stretch; }
  .top__right { width: 100%; }
  .top__right .btn { flex: 1; }
  .card__head { flex-direction: column; align-items: stretch; }
  .card__body { padding: 12px; }
  .grid--2, .grid--4 { grid-template-columns: 1fr; }
  .table th, .table td { padding: 8px 8px; font-size: 13px; }
  .table__wrap { max-height: none; overflow: visible; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .select, .toolbar .input { width: 100%; }
  .modal { padding: 10px; }
  .modal__box { max-height: 95vh; }
  .modal__foot { flex-direction: column; }
  .modal__foot .btn { width: 100%; }
  .login { padding: 16px; }
  .login__card { padding: 24px 20px; }
  .side__acts { flex-direction: column; }
  .side__acts .btn { width: 100%; }
  .row { flex-direction: column; align-items: stretch; }
  .row .btn { width: 100%; }
  .person { flex-direction: row; }
  .stat { padding: 12px; }
  .stat__num { font-size: 22px; }
}
