.mobile-menu-checkbox {
  display: none;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mobile-menu-toggle {
  display: none;
}

@media (max-width: 850px) {
  .mobile-menu-checkbox {
    display: block;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-width: 0;
    padding: 10px 16px;
  }

  .topbar .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    max-width: none;
    gap: 7px;
    font-size: 13px;
  }

  .brand-mark {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    font-size: 17px;
  }

  .brand > span:last-child {
    min-width: 0;
    white-space: nowrap;
  }

  .brand small {
    white-space: nowrap;
    font-size: 8px;
  }

  .user-menu {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    min-width: 0;
    max-width: 100%;
    gap: 7px;
  }

  .user-menu > span {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: clamp(72px, 24vw, 150px);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .user-menu small {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-menu form {
    flex: 0 0 auto;
  }

  .user-menu .button {
    min-height: 36px;
    padding: 6px 9px;
    white-space: nowrap;
  }

  .mobile-menu-toggle {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid #354239;
    border-radius: 5px;
    background: #141b16;
    color: #e7eee8;
    font-size: 14px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
  }

  .mobile-menu-checkbox:focus-visible + .mobile-menu-toggle {
    outline: 2px solid var(--lime);
    outline-offset: 2px;
  }

  .menu-icon {
    position: relative;
    width: 18px;
    height: 14px;
    border-top: 2px solid var(--lime);
    border-bottom: 2px solid var(--lime);
  }

  .menu-icon::before {
    position: absolute;
    top: 5px;
    right: 0;
    left: 0;
    border-top: 2px solid var(--lime);
    content: "";
  }

  .mobile-menu-checkbox:checked + .mobile-menu-toggle {
    border-color: #68795f;
    border-radius: 5px 5px 0 0;
  }

  .main-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid #354239;
    border-top: 0;
    border-radius: 0 0 5px 5px;
    background: #0e1510;
  }

  .mobile-menu-checkbox:checked ~ .main-nav {
    display: grid;
  }

  .main-nav a {
    justify-content: center;
    min-width: 0;
    min-height: 42px;
    padding: 8px 6px;
    border: 1px solid #354239;
    border-radius: 4px;
    background: #18221b;
    color: #dce7de;
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .page-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 26px 16px 42px;
  }

  .page-shell > *,
  .detail-layout > *,
  .detail-main > *,
  .detail-side > *,
  .form-panel > *,
  .action-panel > * {
    min-width: 0;
    max-width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  h1 {
    font-size: clamp(25px, 7vw, 34px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  h2,
  h3 {
    overflow-wrap: anywhere;
  }

  .page-heading {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 22px;
  }

  .page-heading > *,
  .heading-actions,
  .form-actions {
    min-width: 0;
    max-width: 100%;
  }

  .heading-actions,
  .form-actions {
    flex-wrap: wrap;
  }

  .detail-layout,
  .users-layout,
  .auth-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .detail-layout {
    display: grid;
  }

  .detail-main,
  .side-section,
  .form-panel,
  .auth-form {
    width: 100%;
    max-width: 100%;
    padding: 17px;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
  }

  .detail-grid strong,
  .link-row a,
  .timeline li > div,
  .timer-row > span {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .overall-timer {
    padding: 12px;
    border: 1px solid #536449;
    border-radius: 5px;
    background: #202b21;
  }

  .overall-timer strong {
    color: var(--lime);
    font-size: 19px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .link-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .link-row a {
    max-width: 100%;
  }

  .action-panel {
    width: 100%;
  }

  .action-panel label,
  .action-panel input,
  .action-panel select,
  .action-panel textarea,
  .assign-row label,
  .assign-row select,
  .form-panel label,
  .form-panel input,
  .form-panel select,
  .form-panel textarea,
  .auth-form label,
  .auth-form input,
  .filter-bar label,
  .filter-bar input,
  .filter-bar select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .action-panel .button,
  .assign-row .button,
  .form-actions .button {
    flex: 1 1 150px;
  }

  .assign-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .search-field {
    width: 100%;
  }

  .editor-tabs {
    flex-wrap: wrap;
    gap: 4px 16px;
    overflow: visible;
  }

  .editor-tabs a {
    min-height: 40px;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 680px;
  }

  .responsive-table {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .responsive-table table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .responsive-table tbody {
    display: grid;
    gap: 10px;
  }

  .responsive-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--white);
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(98px, .7fr) minmax(0, 1.3fr);
    gap: 10px;
    align-items: start;
    min-width: 0;
    padding: 9px 2px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .responsive-table td::before {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    content: attr(data-label);
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td.empty-cell {
    display: block;
    grid-column: 1 / -1;
    text-align: center;
  }

  .responsive-table td.empty-cell::before {
    content: none;
  }

  .responsive-table .user-actions {
    min-width: 0;
  }

  .quest-create {
    grid-template-columns: minmax(0, 1fr);
  }

  .telegram-panel {
    max-width: 100%;
  }

  .footer {
    gap: 8px 16px;
    padding: 12px 16px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 9px 10px;
    padding: 9px 12px;
  }

  .topbar .brand {
    gap: 6px;
    font-size: 12px;
  }

  .brand-mark {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .brand small {
    font-size: 7px;
  }

  .user-menu {
    gap: 6px;
  }

  .user-menu > span {
    max-width: 96px;
    font-size: 11px;
  }

  .user-menu .button {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .mobile-menu-toggle {
    min-height: 40px;
  }

  .page-shell {
    padding: 22px 12px 34px;
  }

  .page-heading {
    gap: 12px;
    margin-bottom: 18px;
  }

  .heading-actions .button,
  .form-actions .button {
    flex: 1 1 130px;
  }

  .detail-layout {
    gap: 12px;
  }

  .detail-main,
  .side-section,
  .form-panel,
  .auth-form {
    padding: 14px;
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .timer-inputs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .timer-inputs input {
    width: 100%;
    min-width: 0;
  }

  .auth-layout {
    min-height: auto;
    gap: 12px;
  }

  .auth-intro {
    padding: 12px 0 4px;
  }

  .auth-intro h1 {
    font-size: clamp(30px, 9vw, 42px);
  }

  .auth-intro p {
    margin: 10px 0 16px;
    font-size: 15px;
  }

  .kpi-strip,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .users-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-bars {
    gap: 3px;
    overflow-x: auto;
  }

  .chart-column {
    flex: 0 0 34px;
  }

  .table-wrap table {
    min-width: 620px;
  }

  .responsive-table table {
    min-width: 0;
  }

  .audit-table {
    min-width: 760px;
  }

  .progress-steps {
    gap: 3px;
    font-size: 9px;
  }

  .track-late-notice {
    padding: 14px;
  }

  .pagination {
    gap: 12px;
    padding: 16px 4px;
  }
}
