.auth-card [hidden],
[hidden] {
  display: none !important;
}

.account-button { margin-left: auto; white-space: nowrap; }
.account-menu { position: fixed; z-index: 30; right: max(24px, calc((100vw - 1180px)/2)); top: 68px; width: 245px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow); }
.account-menu button { width: 100%; border: 0; text-align: left; }
.auth-shell { min-height: calc(100vh - 160px); display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 70px; }
.auth-intro h1 { max-width: 650px; margin: 12px 0 20px; font: clamp(44px, 6vw, 76px)/1 Georgia, serif; }
.auth-intro>p:last-child { max-width: 600px; line-height: 1.7; color: var(--muted); }
.auth-card { max-width: 440px; width: 100%; justify-self: end; padding: 30px; background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.auth-card form { display: grid; gap: 15px; margin-top: 22px; }
.auth-card label { font-size: 12px; font-weight: 700; }
.auth-card input { margin-top: 6px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--paper); border-radius: 9px; }
.auth-tabs button { border: 0; background: transparent; }
.auth-tabs button.active { background: white; box-shadow: 0 2px 8px #173b3510; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 22px 0; }
.recovery-codes code { padding: 12px; border-radius: 7px; background: var(--paper); text-align: center; font-weight: 700; letter-spacing: .08em; }
.users-list { display: grid; gap: 10px; }
.user-row { display: grid; grid-template-columns: 44px 1fr 230px 110px; align-items: center; gap: 14px; padding: 15px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.avatar { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-weight: 800; }
.user-row small { display: block; margin-top: 3px; color: var(--muted); }

@media (max-width: 760px) {
  html { overflow-x: hidden; }
  body { min-width: 0; padding-bottom: calc(66px + env(safe-area-inset-bottom)); overflow-x: hidden; }
  button, input, select, textarea { min-height: 44px; font-size: 16px; }
  main { width: 100%; padding: 18px 12px 32px; }

  .topbar { position: sticky; height: 60px; padding: 0 10px; gap: 8px; }
  .brand { flex: 0 0 38px; }
  .brand > span { width: 36px; height: 36px; }
  .brand div { display: none; }
  .account-button { order: 2; max-width: calc(100vw - 112px); margin-left: auto; padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; border: 0; background: var(--paper); }
  .topbar > #addButton { order: 3; width: 40px; min-width: 40px; padding: 0; overflow: hidden; font-size: 0; }
  .topbar > #addButton::after { content: '＋'; font-size: 20px; }
  .account-menu { top: 56px; right: 8px; left: 8px; width: auto; padding: 7px; }
  .account-menu button { min-height: 48px; }

  #mainNav:not([hidden]) { display: flex; position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; height: calc(64px + env(safe-area-inset-bottom)); align-items: flex-start; padding: 4px 4px env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 25px #173b3510; }
  #mainNav button { display: block; flex: 1 1 0; height: 56px; min-width: 0; padding: 7px 2px; overflow: hidden; font-size: 12px; line-height: 1.15; text-overflow: ellipsis; }

  .auth-shell { min-height: auto; display: block; }
  .auth-intro { margin: 18px 4px 22px; }
  .auth-intro .eyebrow { font-size: 10px; }
  .auth-intro h1 { margin: 9px 0 13px; font-size: clamp(37px, 11vw, 48px); line-height: 1.02; }
  .auth-intro > p:last-child { margin-bottom: 0; font-size: 14px; line-height: 1.55; }
  .auth-card { max-width: none; padding: 18px; border-radius: 14px; box-shadow: 0 8px 28px #173b3510; }
  .auth-card form { gap: 13px; margin-top: 18px; }
  .auth-tabs button { min-height: 45px; padding: 8px 4px; }

  .hero { display: block; min-height: 0; padding: 28px 22px 150px; border-radius: 16px; }
  .hero::after { width: 230px; height: 230px; right: -105px; top: auto; bottom: -85px; }
  .hero h1 { max-width: 320px; margin: 8px 0 14px; font-size: clamp(40px, 12vw, 54px); }
  .hero p:not(.eyebrow) { margin: 0; font-size: 14px; line-height: 1.55; }
  .scan-button { right: 18px; bottom: 16px; width: 116px; height: 116px; padding: 10px; border-width: 5px; font-size: 13px; }
  .scan-button span { font-size: 31px; }

  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 10px 0 30px; border-radius: 12px; box-shadow: none; border: 1px solid var(--line); }
  .stats article, .stats article:last-child { grid-column: auto; padding: 15px 7px; border-right: 1px solid var(--line); border-bottom: 0; text-align: center; }
  .stats article:last-child { border-right: 0; }
  .stats b { font-size: 28px; }
  .stats span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.25; }

  .section-head, .page-title { margin: 20px 2px 15px; align-items: center; gap: 10px; }
  .section-head h2 { font-size: 25px; }
  .section-head .link { flex-shrink: 0; padding: 7px 0; font-size: 12px; }
  .page-title h1 { margin: 6px 0 0; font-size: 38px; }
  .page-title .primary { width: 44px; min-width: 44px; padding: 0; }

  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .toolbar > * { height: 46px; }
  .toolbar .search { grid-column: 1/-1; min-width: 0; }
  .toolbar select { min-width: 0; }
  .toolbar button { padding: 8px 11px; font-size: 13px; }
  .equipment-grid { grid-template-columns: 1fr; gap: 10px; }
  .card { min-width: 0; padding: 17px; }
  .card h3 { margin: 18px 0 6px; font-size: 22px; overflow-wrap: anywhere; }
  .card p { min-height: 0; }

  .timeline { gap: 8px; }
  .timeline article { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; padding: 12px; }
  .timeline article > div { min-width: 0; }
  .timeline strong, .timeline p { overflow-wrap: anywhere; }
  .timeline time { grid-column: 2; font-size: 11px; }
  .event-icon { width: 36px; height: 36px; }

  .detail-card { padding: 17px; border-radius: 14px; }
  .detail-top { display: block; }
  .detail-top > div:last-child { display: flex; gap: 8px; margin-top: 18px; }
  .detail-top > div:last-child button { flex: 1; padding: 8px; }
  .detail-card h1 { margin: 10px 0; font-size: 34px; overflow-wrap: anywhere; }
  .meta { grid-template-columns: 1fr; gap: 8px; margin: 18px 0; }
  .event-form { margin: 18px 0; padding: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .wide { grid-column: auto; }
  .actions { margin-top: 16px; }
  .actions button { flex: 1; }

  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); margin: auto; padding: 18px; overflow-y: auto; border-radius: 15px; }
  .dialog-head { position: sticky; z-index: 1; top: -18px; margin: -18px -18px 16px; padding: 18px 18px 10px; background: white; }
  .dialog-head h2 { font-size: 27px; }
  .dialog-head .icon { min-width: 44px; min-height: 44px; }
  .capture-button { min-height: 56px; }
  #toast { right: 10px; bottom: calc(75px + env(safe-area-inset-bottom)); left: 10px; text-align: center; }

  .user-row { grid-template-columns: 42px minmax(0, 1fr); gap: 11px; padding: 13px; }
  .user-row select, .user-row button { grid-column: 1/-1; width: 100%; }
  .recovery-codes { grid-template-columns: 1fr 1fr; gap: 7px; }
  .recovery-codes code { padding: 10px 5px; font-size: 12px; }
}

@media (max-width: 380px) {
  main { padding-right: 9px; padding-left: 9px; }
  .hero { padding: 24px 18px 145px; }
  .hero h1 { font-size: 38px; }
  .stats b { font-size: 24px; }
  .stats span { font-size: 9px; }
  .section-head { align-items: flex-start; }
  .section-head .link { max-width: 110px; white-space: normal; }
  .recovery-codes { grid-template-columns: 1fr; }
}
