* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f6f8;
  color: #1a1f24;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: #111827; color: white;
  position: relative;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: white; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.topbar nav a { color: #e5e7eb; text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: #fff; }

.nav-toggle { display: none; }
.nav-toggle-btn { display: none; font-size: 22px; cursor: pointer; color: #fff; user-select: none; padding: 4px 8px; }

/* ---------- Контейнер и карточки ---------- */
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.card {
  background: white; border-radius: 10px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 20px;
}
h1, h2, h3, h4 { margin-top: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  border: 1px solid #d1d5db; background: white; cursor: pointer;
  text-decoration: none; color: #111; font-size: 14px; font-family: inherit;
  line-height: 1.2;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef2f7;
         font-size: 14px; vertical-align: top; }
th { color: #6b7280; font-weight: 600; text-transform: uppercase;
     font-size: 11px; letter-spacing: .04em; }

/* ---------- Формы и сетки ---------- */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: 14px; font-family: inherit; background: white;
}
label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 14px; }

/* ---------- Бейджи и статусы ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px;
         font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-accepted      { background: #e0e7ff; color: #3730a3; }
.badge-in_progress   { background: #fef3c7; color: #92400e; }
.badge-waiting_parts { background: #fee2e2; color: #991b1b; }
.badge-ready         { background: #dcfce7; color: #166534; }
.badge-issued        { background: #e5e7eb; color: #374151; }
.badge-cancelled     { background: #fee2e2; color: #991b1b; }
.low { background: #fff7ed; }
.muted { color: #6b7280; }
.msg { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
       padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
       padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* ---------- Планшеты ---------- */
@media (max-width: 900px) {
  .container { padding: 0 14px; }
}

/* ---------- Мобильные ---------- */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 6px;
    align-items: center;
  }
  .topbar .brand { font-size: 16px; flex: 1; }

  .nav-toggle-btn {
    display: block;
    order: 2;
  }
  .topbar nav {
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    padding: 0;
  }
  .nav-toggle:checked ~ nav {
    max-height: 800px;
    padding: 8px 0;
  }
  .topbar nav a,
  .topbar nav button {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 6px;
    text-align: left;
    width: 100%;
  }
  .topbar nav form { display: block; width: 100%; }
  .topbar nav form button { width: 100%; text-align: left; }

  .container { padding: 0 12px; margin: 14px auto; }
  .card { padding: 14px; border-radius: 8px; }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }

  /* Таблицы — минимум, чтобы не сжимались в кашу */
  table { min-width: 600px; }
  th, td { padding: 8px 10px; font-size: 13px; }

  /* Поля формы — в одну колонку */
  .row { grid-template-columns: 1fr; gap: 12px; }

  /* Кнопки — крупнее для тапов */
  .btn { padding: 10px 16px; font-size: 15px; }
  .btn-sm { padding: 8px 12px; font-size: 13px; }

  /* Поля ввода — 16px предотвращает auto-zoom на iOS */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }

  /* Скролл-обёртки карточек с кнопками в таблицах */
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
}

/* ---------- Очень маленькие экраны ---------- */
@media (max-width: 420px) {
  .topbar .brand { font-size: 15px; }
  h1 { font-size: 20px; }
  .badge { font-size: 11px; padding: 2px 7px; }
}

.hero-title { font-size: 38px; }
@media (max-width: 768px) {
  .hero-title { font-size: 24px; }
}