/* kryukov-stats — стиль веб-интерфейса. Адаптивный: телефоны от
   360 px, планшеты, десктоп (TASK.md, раздел 8). Без сборки и без
   препроцессоров — один файл. */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --green: #1e7f4f;
  --red: #b3352c;
  --amber: #d97706;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Шапка и навигация. */

.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-in {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
}

.brand {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  padding: 8px 0;
}
.brand:hover { text-decoration: none; }

.nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;         /* на телефоне прокручивается */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  color: var(--muted);
  padding: 14px 12px;       /* крупная тач-цель */
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  font-size: 15px;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.logout { margin-left: auto; }
.btn-out {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}
.btn-out:hover { color: var(--red); border-color: var(--red); }

/* Заголовок страницы и переключатель периодов. */

main.wrap { padding-top: 16px; padding-bottom: 40px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin: 8px 0 12px;
}
.page-head h1 { font-size: 24px; margin: 0; }
.period-label { color: var(--muted); font-size: 15px; }

.note {
  background: #eef4ff;
  border: 1px solid #c7dbff;
  color: #1e3a8a;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 12px;
  font-size: 14px;
}
.note.warn {
  background: #fef3e2;
  border-color: #f6d9ab;
  color: #92400e;
}

.period-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 16px;
}

.pn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.pn-kinds, .pn-arrows { display: flex; gap: 4px; }

.pn-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;         /* тач-цель */
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
}
.pn-kind:hover { text-decoration: none; border-color: var(--accent); }
.pn-kind.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pn-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 15px;
}
.pn-range input[type="date"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: var(--card);
  font: inherit;
  color: var(--ink);
}

.btn {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-ink); color: #fff; }

/* Карточки и сетки. */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}
.card h2 {
  font-size: 16px;
  margin: 0 0 12px;
  font-weight: 600;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.mcard-l { color: var(--muted); font-size: 13px; }
.mcard-v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.mcard-d { font-size: 13px; margin-top: 2px; }
.mcard-d.up { color: var(--green); }
.mcard-d.down { color: var(--red); }

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

/* Таблицы: на узких экранах прокручиваются горизонтально. */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tbl thead th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .path {
  word-break: break-all;
  max-width: 420px;
}
a.sort { color: inherit; }

/* Списки долей (браузеры, языки, источники…). */

.tbl.share td { border-bottom: none; padding: 6px 6px; }
.tbl.share { font-size: 15px; }
.c-name { white-space: nowrap; }
.c-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
}
.c-bar { width: 40%; }

.hbar {
  background: #eef1f6;
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}
.hbar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

/* Графики: SVG тянется по контейнеру, на телефоне прокручивается. */

.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

svg.chart {
  display: block;
  width: 100%;
  min-width: 640px;   /* читаемость подписей на телефонах */
  height: auto;
}
.chart-grid { stroke: #e5e7eb; stroke-width: 1; }
.chart-tick { fill: #6b7280; font-size: 13px; }
.chart-label { fill: #6b7280; font-size: 13px; }
.chart-legend { fill: #374151; font-size: 14px; }
.chart-val { fill: #374151; font-size: 12px; }
.chart-empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
}

/* Табы (страницы: обзор/входы/выходы/файлы). */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  padding-bottom: 2px;
}
.tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
  font-size: 15px;
}
.tab:hover { text-decoration: none; border-color: var(--accent); }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

/* Страница входа. */

.login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
}
.login-box h1 { font-size: 22px; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input[type="password"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
}

/* Подвал. */

.foot {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 16px 0;
  text-align: center;
}

/* Планшеты и шире — плотнее сетки карточек. */

@media (min-width: 768px) {
  .cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .page-head h1 { font-size: 28px; }
}

/* Телефон: компактнее отступы, шапка в две строки не ломается. */

@media (max-width: 480px) {
  .top-in { flex-wrap: wrap; padding: 6px 0; }
  .logout { margin-left: 0; }
  .nav { order: 3; width: 100%; }
  .card { padding: 12px; }
  .mcard-v { font-size: 22px; }
  .tbl .path { max-width: 200px; }
}
