/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ============================================================ */
@media (max-width: 1100px) {
  header {
    padding: 12px 16px;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  header h1 { font-size: 18px; flex: 1; }
  .who { display: none; }

  .container { padding: 0 10px; margin: 14px auto; }
  .card { padding: 16px; margin-bottom: 12px; border-radius: var(--radius); }
  .card h2 { font-size: 15px; margin-bottom: 12px; }

  /* iOS: не даём зумить при фокусе */
  input[type=text], input[type=email], input[type=password],
  input[type=date], textarea,
  select:not(.select-wrap select) {
    font-size: 16px;
  }

  .controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .train-type-tabs { width: 100%; margin-bottom: 0; }
  .train-type-tabs button { flex: 1; padding: 12px 8px; font-size: 13px; }
  .train-type-tabs .tt-icon { margin-right: 4px; }

  .date-picker-wrap { width: 100%; }
  .date-input {
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  .row { gap: 10px; }
  .row > * { flex-basis: 100%; min-width: 0; }

  .emp-header-row { flex-direction: column; gap: 12px; padding-left: 0; }
  .emp-header-title { font-size: 15px; }
  .train-number-block { width: 100%; min-width: 0; }
  .train-number-label { font-size: 14px; }

  .sheet-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    padding: 10px 12px;
  }
  .sheet-meta .sep { display: none; }
  .sheet-meta button.mini { align-self: flex-start; }

  .emp-header { display: none; }

  .group { margin-bottom: 14px; }
  .group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-bottom: none;
  }
  .group-header .g-title { display: flex; align-items: center; gap: 8px; }
  .group-header .g-icon { font-size: 15px; line-height: 1; }
  .group-header .count {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
  }
  .group-header.pos-tablet      { background-color: var(--c-pos-tablet); }
  .group-header.pos-bartender   { background-color: var(--c-pos-bartender); }
  .group-header.pos-1kl         { background-color: var(--c-pos-1kl); }
  .group-header.pos-bk          { background-color: var(--c-pos-bk); }
  .group-header.pos-bb          { background-color: var(--c-pos-bb); }
  .group-header.pos-mt3         { background-color: var(--c-pos-mt3); }
  .group-header.pos-mt10        { background-color: var(--c-pos-mt10); }
  .group-header.pos-instructor  { background-color: var(--c-pos-instructor); color: #fff; }
  .group-header.pos-instructor .count { background: rgba(255, 255, 255, .35); }
  .group-header.pos-none        { background-color: var(--surface); color: var(--muted); }

  .group .emp {
    display: block;
    padding: 14px 14px 12px;
    border-radius: 0;
    margin-bottom: 0;
    border-top: none;
    position: relative;
    background: #FFFFFF;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .group .emp:last-child { border-radius: 0 0 var(--radius) var(--radius); }

  .emp-fio-line { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .emp-num {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    background: var(--brand);
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
  }

  .emp-name {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    line-height: 1.3;
    padding: 0;
    margin: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
  }
  .emp-name .fio-surname { font-weight: 700; }
  .emp-name .fio-rest    { font-weight: 400; }

  .emp-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .emp-chip-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .emp-chip-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
  }
  .emp-chips .select-wrap select {
    min-height: 38px;
    font-size: 14px;
    padding: 8px 22px 8px 10px;
    background-size: 8px;
    background-position: right 6px center;
  }

  .emp-flags {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px 8px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }
  .flag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: var(--radius);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .flag:active { background: var(--surface); }
  .flag input[type=checkbox] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--brand);
  }
  .flag.is-disabled { opacity: .45; cursor: not-allowed; }
  .flag.is-on { color: var(--clove); font-weight: 700; }
  .flag .flag-icon { font-size: 14px; line-height: 1; }

  .emp-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
  .emp-actions button {
    height: 42px;
    min-height: 42px;
    padding: 0 8px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    width: 100%;
  }
  .emp-actions .st-confirm,
  .emp-actions .st-decline {
    background: #FFFFFF;
    color: var(--text);
    border: 1px solid var(--line);
  }
  .emp-actions .st-confirm.on { background: var(--ok);  border-color: var(--ok);  color: #fff; }
  .emp-actions .st-decline.on { background: var(--bad); border-color: var(--bad); color: #fff; }
  .emp-actions .danger.mini {
    background: #FFFFFF;
    color: var(--bad);
    border: 1px solid var(--line);
    font-size: 18px;
    padding: 0;
  }
  .emp-actions .danger.mini:hover { background: var(--bad); color: #FFFFFF; }

  .changes-block { padding: 14px; }
  .changes-block h3 { font-size: 15px; margin-bottom: 8px; }
  .changes-list li { padding: 8px 10px; font-size: 13px; gap: 8px; }

  .add-emp-row { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .add-emp-row .add-emp-label { font-size: 15px; margin-bottom: 8px; }
  .add-emp-row > div:last-child { align-items: stretch; }
  .add-emp-row button { width: 100%; }

  .comment-block { padding: 14px; margin-top: 14px; }
  .comment-label { font-size: 15px; }
  .comment-hint { margin-top: 12px; font-size: 12px; padding: 8px 12px; }

  th, td { padding: 8px 10px; font-size: 13px; }
  #adminView .row > * { flex-basis: 100%; }
  #authView .card { margin: 20px auto !important; }

  .crew-summary { margin-top: 18px; padding-top: 16px; }
  .crew-summary h3 { font-size: 15px; margin-bottom: 10px; }

  .crew-summary-table-wrap { max-width: 100%; margin: 0; }

  .crew-summary-table { font-size: 13px; }
  .crew-summary-table thead th { padding: 8px 6px; font-size: 10px; letter-spacing: .3px; }
  .crew-summary-table thead th:first-child { width: 34px; }
  .crew-summary-table thead th:last-child { width: 160px; }
  .crew-summary-table tbody td { padding: 8px 6px; font-size: 12px; }
  .crew-summary-table tbody td:first-child { width: 34px; }
  .crew-summary-table .fio-surname { font-weight: 700; }
  .pos-chip { padding: 2px 8px; font-size: 11px; }
  .activity-chip { padding: 2px 8px; font-size: 11px; }

  .form-actions { flex-direction: column; }
  .form-actions button { min-width: 0; width: 100%; }

  .flights-chips { gap: 6px; }
  .flight-chip {
    font-size: 13px;
    padding: 7px 12px;
    min-height: 38px;
    min-width: 66px;
  }

  .table-wrap table { min-width: 640px; font-size: 13px; }
  .table-wrap th,
  .table-wrap td { padding: 8px 10px; }
  .table-wrap .detail-list { max-width: 260px; font-size: 11px; }
}

@media (max-width: 420px) {
  header h1 { font-size: 16px; }
  header { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  header button.ghost { padding: 8px 12px; font-size: 13px; min-height: 36px; }

  .card { padding: 14px; }
  .emp-chips { gap: 6px; }
  .emp-chips .select-wrap select { font-size: 13px; padding: 7px 20px 7px 8px; }
  .flag { font-size: 11px; gap: 5px; padding: 5px 2px; }
  .flag input[type=checkbox] { width: 16px; height: 16px; }
  .flag .flag-icon { font-size: 12px; }

  .emp-actions button { font-size: 12px; height: 40px; min-height: 40px; }
  .emp-actions .danger.mini { font-size: 16px; }

  .emp-name { font-size: 15px; }

  .train-type-tabs button { font-size: 12px; padding: 10px 6px; }
  .train-type-tabs .tt-icon { display: none; }

  .date-input { font-size: 16px; min-height: 44px; }

  .crew-summary-table thead th { padding: 6px 4px; }
  .crew-summary-table tbody td { padding: 6px 4px; font-size: 11px; }
  .pos-chip { padding: 2px 6px; font-size: 10px; }
  .activity-chip { padding: 2px 6px; font-size: 10px; }

  .changes-block h3 { font-size: 14px; }
  .changes-list li { font-size: 12px; }

  .flight-chip {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 34px;
    min-width: 58px;
  }
  .flights-label { font-size: 11px; }
  .flights-legend { font-size: 11px; gap: 12px; }

  .table-wrap table { min-width: 560px; font-size: 12px; }
  .table-wrap th,
  .table-wrap td { padding: 6px 8px; }
}

@media (max-width: 360px) {
  .emp-actions button { font-size: 11px; height: 38px; min-height: 38px; }
  .emp-actions .danger.mini { font-size: 14px; }
  .emp-name { font-size: 14px; }
  .flight-chip { min-width: 50px; padding: 5px 8px; font-size: 12px; }
  .flag { font-size: 11px; gap: 4px; }
  .flag input[type=checkbox] { width: 16px; height: 16px; }
  .card { padding: 12px; }
}

@media (max-width: 950px) and (orientation: landscape) {
  header {
    padding: 8px 14px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  header h1 { font-size: 16px; }
  .card { padding: 12px; margin-bottom: 10px; }
  .flights-section { margin-top: 12px; padding-top: 10px; }
  .emp-flags { padding: 6px 0; margin-bottom: 8px; }
  .form-actions { flex-direction: row; }
  .form-actions button { min-width: 0; }
}

@media (max-width: 600px) {
  #tgHeaderBtn .btn-txt { display: none; }
  #tgHeaderBtn { padding: 6px 12px; }
  .rep-table td:nth-child(2), .rep-table td:nth-child(3) { min-width: 160px; }
  .rep-block { padding: 14px 12px 6px; }
  .modal-card { padding: 16px; }
}