:root {
  --copper: #C89B6E;
  --copper-dark: #A87B4E;
  --copper-light: #E5C8A5;
  --bg: #F7F3EE;
  --surface: #FFFFFF;
  --ink: #2A2520;
  --muted: #8B7E70;
  --border: #E5DDD2;
  --success: #4A7C59;
  --danger: #B5483A;
  --warn: #C99A4A;
  --shadow: 0 1px 2px rgba(42, 37, 32, 0.04), 0 8px 24px rgba(42, 37, 32, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink);
}
.brand .dot { width: 10px; height: 10px; background: var(--copper); border-radius: 50%; }

.nav { display: flex; gap: 18px; align-items: center; }
.nav a { color: var(--ink); font-weight: 500; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav .role-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--copper-light);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: 'Inter', sans-serif; letter-spacing: -0.01em; }
h1 { font-size: 26px; margin: 0 0 18px; font-weight: 700; }
h2 { font-size: 19px; margin: 0 0 12px; font-weight: 700; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--copper);
  background: var(--copper);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  text-decoration: none;
}
.btn:hover { background: var(--copper-dark); border-color: var(--copper-dark); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--copper-dark); }
.btn.ghost:hover { background: var(--bg); color: var(--copper-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #983e32; border-color: #983e32; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.form { display: grid; gap: 14px; max-width: 520px; }
.form .row { display: grid; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); font-weight: 600; }
.form input, .form select, .form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(200, 155, 110, 0.15);
}

.error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f3c6c1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

table.users {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.users th, table.users td {
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
table.users th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
table.users tr:last-child td { border-bottom: none; }
table.users tr:hover td { background: rgba(200,155,110,0.04); }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.tag.admin { background: #efe1d2; color: #6a4a2a; }
.tag.manager { background: #d8e6d8; color: #2d5a3a; }
.tag.trainee { background: #e6e0f0; color: #4a3a6a; }
.tag.employee { background: #d6e8ef; color: #2a566a; }
.tag.off { background: #ececec; color: #888; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #F7F3EE 0%, #EFE3D1 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.08);
}
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }

/* Progress bar */
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar.small { height: 6px; max-width: 140px; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--copper) 0%, var(--copper-dark) 100%);
  transition: width 0.4s ease;
}

/* Day grid (admin plan list) */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.day-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: block;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.day-card:hover {
  transform: translateY(-1px);
  border-color: var(--copper);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
}
.day-card.block-1 { border-left: 3px solid #C89B6E; }
.day-card.block-2 { border-left: 3px solid #4A7C59; }
.day-card.block-3 { border-left: 3px solid #C99A4A; }
.day-card.block-4 { border-left: 3px solid #6E5BC8; }
.day-card.exam {
  background: linear-gradient(135deg, #fff 0%, #fdf2e6 100%);
  border-color: var(--copper);
  font-weight: 600;
}
.day-card.buffer { opacity: 0.65; }
.day-card .day-num { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }
.day-card .day-title { margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.day-card .day-meta { margin-top: 8px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* Materials list */
.materials { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.material {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: flex-start;
}
.material-icon { font-size: 22px; line-height: 1; flex-shrink: 0; width: 30px; text-align: center; }
.material-body { flex: 1; min-width: 0; }
.material-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.material-title a { color: var(--copper-dark); }
.material-video { background: #fffaf3; }
.material-price { background: #f3f9f3; }
.material-folder { background: #f5f5fa; }

/* Schedule table */
table.schedule { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.schedule td { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
table.schedule tr:last-child td { border-bottom: none; }
table.schedule td.time { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; width: 110px; white-space: nowrap; }

/* Stat cards */
.card.stat { text-align: center; padding: 18px 12px; }
.stat-num { font-size: 32px; font-weight: 700; color: var(--copper-dark); font-family: 'Inter', sans-serif; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-top: 4px; }

@media (max-width: 720px) {
  .container { padding: 16px; }
  table.users thead { display: none; }
  table.users tr { display: block; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 8px 12px; }
  table.users td { display: flex; justify-content: space-between; border: none; padding: 6px 0; }
  table.users td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
  }
}

/* ============================================================
   Mobile-first адаптация (этап 1, 2026-05-24)
   ============================================================ */

/* Bottom navigation — показывается только на мобильном */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  /* Прячем десктоп-навигацию (имя+роль остаются в шапке) */
  .topbar .nav a:not(.role-keep):not(.logout-keep) { display: none; }
  .topbar { padding: 10px 14px; }
  .topbar .nav { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .nav .role-badge { font-size: 10px; padding: 2px 6px; }
  .nav .muted { display: none; }

  .brand { font-size: 15px; }

  /* Контент сдвигается, чтобы не залезал под bottom-nav (высота 65px + 12px воздуха) */
  body { padding-bottom: calc(77px + env(safe-area-inset-bottom)); }

  /* Нижняя плашка с иконками */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(42,37,32,0.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)) 4px;
    z-index: 100;
    justify-content: space-around;
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 10px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    border-radius: 8px;
    min-height: 52px;
  }
  .bottom-nav a .ico { font-size: 22px; line-height: 1; }
  .bottom-nav a.active { color: var(--copper-dark); background: rgba(200,155,110,0.10); }
  .bottom-nav a:active { background: rgba(200,155,110,0.18); }

  /* Touch-friendly кнопки и инпуты */
  .btn { min-height: 44px; padding: 11px 18px; font-size: 15px; }
  .btn.small { min-height: 36px; padding: 7px 12px; font-size: 13px; }
  .form input, .form select, .form textarea {
    min-height: 44px;
    font-size: 16px; /* iOS не зумит при focus, если >=16px */
    padding: 12px 14px;
  }
  .form { max-width: 100%; }

  h1 { font-size: 22px; margin-bottom: 14px; }
  h2 { font-size: 17px; }

  .card { padding: 16px; border-radius: 8px; }

  .grid { grid-template-columns: 1fr; gap: 10px; }

  .day-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .day-card { padding: 10px; }

  .actions { gap: 8px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 480px) {
  .container { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .brand .dot { width: 8px; height: 8px; }
  .bottom-nav a { font-size: 9px; }
  .bottom-nav a .ico { font-size: 20px; }
}

/* «Установить приложение» подсказка */
.install-hint {
  position: fixed;
  bottom: 70px;
  left: 12px;
  right: 12px;
  background: var(--copper);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 200;
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.install-hint.show { display: flex; }
.install-hint button {
  background: #fff;
  color: var(--copper-dark);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
.install-hint .close {
  background: transparent;
  color: #fff;
  padding: 4px 8px;
  font-size: 16px;
}
