/* KNRent Phase 11 — mobile app shell. Desktop layouts stay in main.css. */

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --app-nav-h: 4.45rem;
  --touch: 2.75rem;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.kn-mobile {
  padding-bottom: calc(var(--app-nav-h) + var(--sab) + 4.5rem);
}

body.kn-mobile.kn-admin {
  padding-bottom: calc(var(--app-nav-h) + var(--sab));
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  color: var(--ink);
  cursor: pointer;
  position: relative;
}

.icon-btn svg {
  width: 1.2rem;
  height: 1.2rem;
}

.icon-btn .badge-dot {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 99px;
  background: var(--danger);
}

.lang-switch {
  display: inline-flex;
  gap: 0.15rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem;
}

.lang-switch button {
  min-width: 2.1rem;
  min-height: 2.1rem;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink-2);
}

.lang-switch button.is-on {
  background: var(--ink);
  color: #fff;
}

.app-nav {
  display: none;
}

.app-header-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.kn-sheet-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
}

.kn-sheet-root.is-on {
  display: block;
}

.kn-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 17, 14, 0.46);
}

.kn-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(88vh, 40rem);
  overflow: auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 0.65rem 1rem calc(1.1rem + var(--sab));
  box-shadow: 0 -18px 50px -28px rgba(0, 0, 0, 0.45);
  transform: translateY(110%);
  transition: transform 220ms var(--ease);
}

.kn-sheet-root.is-on .kn-sheet {
  transform: none;
}

.kn-sheet__handle {
  width: 3rem;
  height: 0.28rem;
  border-radius: 99px;
  background: var(--line);
  margin: 0.2rem auto 0.85rem;
}

.kn-sheet h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
}

.kn-sheet .sheet-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: var(--touch);
  padding: 0.7rem 0.2rem;
  border: 0;
  background: transparent;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  color: inherit;
}

.kn-sheet .sheet-action:last-of-type {
  border-bottom: 0;
}

.install-banner,
.offline-banner,
.notify-nudge {
  display: none;
}

.m-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.m-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.m-stat strong {
  display: block;
  font-size: 1.45rem;
  font-family: var(--font-display);
}

.action-needed a,
.action-needed button.need-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: var(--touch);
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 0.45rem;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.need-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 99px;
  display: inline-block;
}

.need-dot.red { background: var(--danger); }
.need-dot.orange { background: var(--warn); }

.gallery__count {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  background: rgba(12, 20, 18, 0.78);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.search-step-nav {
  display: none;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ok);
}

.distance-chip {
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--accent);
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
}

.qr-box canvas,
.qr-box img {
  width: 168px;
  height: 168px;
  background: #fff;
  border-radius: 12px;
}

.sig-pad {
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  width: 100%;
  height: 160px;
  touch-action: none;
}

.inspect-shot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.inspect-shot label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 6.5rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 0.55rem;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 650;
}

.inspect-shot input {
  width: 100%;
}

.inspect-shot img {
  width: 100%;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 10px;
}

.form-stepper {
  display: none;
}

html[dir="rtl"] .app-nav,
html[dir="rtl"] .site-header__inner,
html[dir="rtl"] .header-end,
html[dir="rtl"] .st-shell,
html[dir="rtl"] .filters-panel,
html[dir="rtl"] .result-card,
html[dir="rtl"] .tabs-bar {
  direction: rtl;
}

html[dir="rtl"] .app-nav svg,
html[dir="rtl"] .fav-btn,
html[dir="rtl"] .icon-btn svg {
  transform: none;
}

@media (max-width: 900px) {
  body.kn-mobile .site-header {
    padding-top: var(--sat);
  }

  body.kn-mobile .site-header__inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0.45rem 0;
    gap: 0.5rem;
  }

  body.kn-mobile .nav,
  body.kn-mobile .nav-toggle,
  body.kn-mobile .auth-chip {
    display: none !important;
  }

  body.kn-mobile .header-end .btn-secondary,
  body.kn-mobile .header-end .btn-ghost {
    display: none;
  }

  body.kn-mobile .brand {
    font-size: 1.28rem;
  }

  .app-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    height: calc(var(--app-nav-h) + var(--sab));
    padding: 0.28rem 0.25rem var(--sab);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }

  .app-nav a,
  .app-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    min-height: var(--touch);
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font-size: 0.58rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border-radius: 12px;
    padding: 0 0.1rem;
  }

  .app-nav a span,
  .app-nav button span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
    hyphens: auto;
  }

  .app-nav a.is-active,
  .app-nav button.is-active {
    color: var(--accent);
  }

  .app-nav svg {
    width: 1.28rem;
    height: 1.28rem;
  }

  .app-nav a:active,
  .app-nav button:active {
    transform: scale(0.96);
  }

  .filters-panel {
    padding-bottom: calc(5.5rem + var(--sab));
  }

  .filters-applybar {
    display: flex !important;
    position: sticky;
    bottom: 0;
    gap: 0.5rem;
    background: #fff;
    padding: 0.75rem 0 calc(0.4rem + var(--sab));
  }

  .bottom-bar {
    padding-bottom: calc(0.75rem + var(--sab));
    margin-bottom: calc(var(--app-nav-h) - 0.4rem);
  }

  .site-footer {
    padding-bottom: 1rem;
    display: none;
  }

  .kn-toasts {
    bottom: calc(var(--app-nav-h) + var(--sab) + 0.5rem);
  }

  .kn-modal-root:not([hidden]) {
    display: block;
  }

  .kn-modal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    max-width: none;
    width: 100%;
    border-radius: 22px 22px 0 0;
    padding-bottom: calc(1rem + var(--sab));
  }

  .result-card,
  .result-card__price {
    grid-template-columns: 1fr;
  }

  .result-card__media {
    min-height: 210px;
  }

  .result-card__media img {
    width: 100%;
    height: 210px;
    object-fit: cover;
  }

  .kn-search-steps .search-grid {
    grid-template-columns: 1fr;
  }

  .kn-search-steps[data-search-step="1"] .s-when,
  .kn-search-steps[data-search-step="1"] .s-return,
  .kn-search-steps[data-search-step="1"] .s-type,
  .kn-search-steps[data-search-step="1"] .search-toolbar,
  .kn-search-steps[data-search-step="1"] .search-step-nav[data-for="2"],
  .kn-search-steps[data-search-step="1"] .search-step-nav[data-for="3"] {
    display: none;
  }

  .kn-search-steps[data-search-step="2"] .s-where,
  .kn-search-steps[data-search-step="2"] .s-where-extra,
  .kn-search-steps[data-search-step="2"] .s-type,
  .kn-search-steps[data-search-step="2"] .search-toolbar,
  .kn-search-steps[data-search-step="2"] .search-step-nav[data-for="1"],
  .kn-search-steps[data-search-step="2"] .search-step-nav[data-for="3"] {
    display: none;
  }

  .kn-search-steps[data-search-step="3"] .s-where,
  .kn-search-steps[data-search-step="3"] .s-where-extra,
  .kn-search-steps[data-search-step="3"] .s-when,
  .kn-search-steps[data-search-step="3"] .s-return,
  .kn-search-steps[data-search-step="3"] .search-step-nav[data-for="1"],
  .kn-search-steps[data-search-step="3"] .search-step-nav[data-for="2"] {
    display: none;
  }

  .search-step-nav {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
  }

  .kn-search-steps .search-submit {
    width: 100%;
  }

  .hero-home {
    min-height: auto;
  }

  .hero-home h1 {
    font-size: clamp(1.7rem, 8vw, 2.4rem);
  }

  .st-side {
    display: none;
  }

  .st-shell {
    grid-template-columns: 1fr;
  }

  .form-stepper {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
  }

  .form-stepper span {
    flex: 1;
    height: 0.28rem;
    border-radius: 99px;
    background: var(--line);
  }

  .form-stepper span.is-on,
  .form-stepper span.is-done {
    background: var(--accent);
  }

  #vehicle-form.kn-stepped .vf-step {
    display: none;
  }

  #vehicle-form.kn-stepped .vf-step.is-on {
    display: grid;
  }

  .admin-side {
    display: none;
  }

  .kn-admin .admin-shell {
    flex-direction: column;
  }

  .admin-top {
    padding-top: calc(0.65rem + var(--sat));
    flex-wrap: wrap;
  }

  .admin-top input {
    min-width: 0;
    width: 100%;
  }

  .admin-search {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table tr {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    margin: 0 0 0.65rem;
    padding: 0.75rem 0.85rem;
  }

  .admin-table td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.28rem 0;
    border: 0;
  }

  .admin-table td::before {
    content: attr(data-label);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 38%;
  }

  .cal-row {
    overflow-x: auto;
  }

  .install-banner,
  .notify-nudge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin: 0.5rem 0 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line);
  }

  .offline-banner.is-on {
    display: flex;
    position: sticky;
    top: calc(var(--header-h) + var(--sat));
    z-index: 36;
    background: #111;
    color: #fff;
    padding: 0.55rem 0.9rem;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .account-dash {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin: 0.85rem 0 1.1rem;
  }

  .quick-actions a,
  .quick-actions button {
    min-height: 3.2rem;
  }

  .list-row .actions {
    width: 100%;
  }

  .list-row .actions .btn {
    flex: 1;
    min-height: var(--touch);
  }

  input,
  select,
  textarea,
  .btn,
  .chip-btn {
    font-size: 16px;
  }

  .field input,
  .field select,
  .field textarea,
  .search-bar__field input,
  .search-bar__field select {
    min-height: var(--touch);
  }

  .planning-days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .timeline-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0.85rem;
    margin-bottom: 0.55rem;
  }
}

@media (max-width: 430px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .inspect-shot {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 320px) {
  .app-nav {
    font-size: 0.56rem;
  }

  .container {
    width: min(1120px, calc(100% - 0.9rem));
  }
}

@media (min-width: 901px) {
  .app-nav,
  .install-banner,
  .filters-applybar,
  .search-step-nav,
  .form-stepper {
    display: none !important;
  }

  .kn-search-steps .s-type {
    max-width: 16rem;
    margin-top: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kn-sheet,
  .app-nav a,
  .app-nav button {
    transition: none;
  }
}

/* Profile — app-like, 320px+ */
.profile-app {
  max-width: 36rem;
  width: min(36rem, calc(100% - 0.5rem));
  margin-inline: auto;
  padding-bottom: 1.5rem;
  overflow-x: hidden;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 4.1rem;
  height: 4.1rem;
  min-width: 4.1rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.15rem;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-hero h1 {
  margin: 0.1rem 0 0.15rem;
  font-size: 1.25rem;
  word-break: break-word;
}

.profile-block h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin: 0 0 0.45rem 0.2rem;
}

.profile-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.85rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.profile-row:last-child {
  border-bottom: 0;
}

.profile-row__label {
  font-weight: 650;
  flex: 1;
}

.profile-row__meta {
  color: var(--ink-2);
  font-size: 0.82rem;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-row__chev {
  color: var(--ink-2);
  font-size: 1.2rem;
  line-height: 1;
}

[dir="rtl"] .profile-row__chev {
  transform: scaleX(-1);
}

.profile-row.is-danger .profile-row__label {
  color: var(--danger);
}

.profile-panel {
  margin-bottom: 1.25rem;
}

.lang-switch--profile {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem;
}

.lang-switch--profile button {
  flex: 1;
  min-width: 5.5rem;
  min-height: 2.75rem;
}

.auth-register-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.auth-register-grid .auth-span,
.auth-register-grid .field.auth-span {
  grid-column: 1 / -1;
}

body.kn-ai-open {
  overflow: hidden;
}

body.kn-ai-open .app-nav {
  display: none !important;
}

@media (max-width: 430px) {
  .auth-register-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    padding: 0.85rem;
  }

  .profile-row {
    padding-inline: 0.85rem;
  }
}

@media (max-width: 320px) {
  .profile-app {
    width: 100%;
  }

  .profile-avatar {
    width: 3.4rem;
    height: 3.4rem;
    min-width: 3.4rem;
  }
}
