/* Housekeeping System (HKS) — profile + photo reports */

.hks-code {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hks-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hks-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.2fr);
  gap: 1.25rem;
  align-items: start;
}

/* HTML lists report first (mobile priority); desktop keeps profile on the left */
.hks-layout .hks-profile-card { order: 1; }
.hks-layout .hks-report-card { order: 2; }

@media (max-width: 900px) {
  .hks-layout {
    grid-template-columns: 1fr;
  }
}

.hks-profile {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.hks-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-muted, #e8e8e8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  border: 1px solid var(--ink, #ccc);
}

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

.hks-profile-name {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
}

.hks-profile-dl {
  margin: 0.85rem 0 0;
  display: grid;
  gap: 0.45rem;
}

.hks-profile-dl > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.hks-profile-dl dt {
  color: var(--text-muted);
  font-weight: 500;
}

.hks-profile-dl dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.hks-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.hks-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hks-preset {
  appearance: none;
  border: 1px solid var(--ink, #ccc);
  background: var(--bg-card, #fff);
  color: inherit;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hks-preset:hover {
  border-color: var(--accent, #2563eb);
}

.hks-preset.is-active {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  color: #fff;
}

.hks-notes-hint {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
}

.hks-chatbox {
  resize: vertical;
  min-height: 4.5rem;
}

.hks-detail-photo {
  margin-top: 0.75rem;
}

.hks-detail-photo img {
  max-width: 100%;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--ink, #ccc);
}

/* Recent report cards (mobile-friendly list) */
.hks-report-list {
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

.hks-report-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--ink, #ccc);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-body, #fafafa);
}

.hks-report-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.hks-report-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hks-report-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Status filter chips — phones use chips; desktop keeps the select */
.hks-filter-chips {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.hks-filter-chip {
  appearance: none;
  border: 1px solid var(--ink, #ccc);
  background: var(--bg-card, #fff);
  color: inherit;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  min-height: 2.5rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hks-filter-chip.is-active {
  background: var(--accent, #0f766e);
  border-color: var(--accent, #0f766e);
  color: #fff;
}

.hks-photo-modal img {
  width: 100%;
  max-height: min(70vh, 560px);
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #111;
}

/* Standalone housekeeping portal */
.hk-portal-tag {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hk-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0.25rem;
  border: 1px solid var(--ink, #ccc);
  border-radius: 10px;
}

.hk-auth-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-height: 2.75rem;
  -webkit-tap-highlight-color: transparent;
}

.hk-auth-tab.is-active {
  background: var(--accent, #0f766e);
  color: #fff;
}

.hk-auth-footer {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.hk-auth-footer a {
  color: inherit;
  font-weight: 650;
}

.hk-bottom-nav {
  display: none;
}

.hk-mobile-signout {
  display: none;
}

/* Desktop: show sidebar nav for housekeeping shell */
.hk-app-shell {
  min-height: 100vh;
}

/* ── Mobile shell: fit phone viewport ── */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body.hk-portal {
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg-body, #f7f7f5);
  }

  .hk-app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  /* Override admin drawer that would hide the sidebar off-screen */
  .hk-app-shell .sidebar,
  .emp-app-shell.hk-app-shell .sidebar {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    max-height: none;
    top: auto;
    left: auto;
    bottom: auto;
    box-shadow: none !important;
    border-right: none;
    border-bottom: 1px solid var(--border-color, #ddd);
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    padding-top: calc(0.45rem + env(safe-area-inset-top, 0px));
    z-index: 40;
  }

  .hk-app-shell .sidebar-brand {
    flex: 1 1 auto;
    padding: 0.15rem 0.25rem;
    border-bottom: none;
    justify-content: flex-start;
    gap: 0.5rem;
    min-width: 0;
  }

  .hk-app-shell .sidebar-brand .logo-sm,
  .hk-app-shell .sidebar-brand .logo-sm .kaisha-logo,
  .hk-app-shell .sidebar-brand .logo-sm img {
    height: 32px;
    max-width: 80px;
  }

  .hk-app-shell .hk-portal-tag {
    margin-top: 0;
    font-size: 0.62rem;
  }

  .hk-app-shell .hk-mobile-signout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    min-height: 2.5rem;
    min-width: 4.5rem;
    padding: 0.4rem 0.75rem;
  }

  .hk-app-shell .sidebar-section {
    display: none;
  }

  .hk-app-shell .main-content {
    margin-left: 0 !important;
    width: 100%;
    max-width: 100vw;
    height: auto;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  .hk-app-shell .topbar {
    padding: 0.55rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.45rem;
    min-height: 0;
    flex-shrink: 0;
  }

  .hk-app-shell .topbar-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  .hk-app-shell .topbar-title h1,
  .hk-app-shell .topbar-title h2 {
    font-size: 1.05rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hk-app-shell .topbar-title p,
  .hk-app-shell .topbar-sub {
    display: block !important;
    margin: 0.15rem 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.3;
  }

  .hk-app-shell .topbar-actions {
    order: 3;
    width: 100%;
    display: flex;
    gap: 0.4rem;
    justify-content: stretch;
  }

  .hk-app-shell .topbar-actions .btn {
    flex: 1 1 0;
    min-height: 2.65rem;
    white-space: nowrap;
    justify-content: center;
  }

  /* Meetings is secondary on phones — keep report CTA primary */
  .hk-app-shell .topbar-actions [data-meetings-view-btn] {
    display: none;
  }

  .hk-app-shell .page-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.75rem 0.75rem calc(4.75rem + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* Prevent iOS zoom on focus */
  .hk-app-shell .form-control,
  .hk-app-shell select.form-control,
  .hk-app-shell textarea.form-control,
  .hk-app-shell input[type="text"],
  .hk-app-shell input[type="email"],
  .hk-app-shell input[type="tel"],
  .hk-app-shell input[type="password"],
  .hk-app-shell input[type="search"] {
    font-size: 16px !important;
    max-width: 100%;
    min-height: 2.75rem;
  }

  .hk-app-shell textarea.form-control {
    min-height: 5.5rem;
  }

  .hk-app-shell .btn {
    touch-action: manipulation;
  }

  .hk-app-shell .btn-sm {
    min-height: 2.5rem;
    padding: 0.45rem 0.75rem;
  }

  /* Sticky bottom tab bar */
  .hk-bottom-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--bg-card, #fff);
    border-top: 2px solid var(--ink, #111);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
    gap: 0.25rem;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  }

  .hk-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    padding: 0.4rem 0.35rem;
    border-radius: 10px;
    color: var(--text-secondary, #444);
    font-size: 0.7rem;
    font-weight: 650;
    text-decoration: none;
    min-height: 3.15rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .hk-bottom-nav a .nav-icon,
  .hk-bottom-nav a svg {
    width: 22px;
    height: 22px;
  }

  .hk-bottom-nav a.active {
    background: var(--accent-50, #ecfdf5);
    color: var(--accent, #0f766e);
  }

  /* Dashboard: report form first (primary job on phone) */
  .hks-layout {
    gap: 0.85rem;
  }

  .hks-layout .hks-profile-card {
    order: 2;
  }

  .hks-layout .hks-report-card {
    order: 1;
  }

  .hks-profile {
    gap: 0.75rem;
  }

  .hks-avatar {
    width: 56px;
    height: 56px;
    font-size: 0.95rem;
  }

  .hks-profile-name {
    font-size: 1.05rem;
  }

  .hks-profile-dl > div {
    grid-template-columns: 5rem 1fr;
    gap: 0.35rem;
    font-size: 0.82rem;
  }

  .hks-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .hks-preset {
    border-radius: 12px;
    padding: 0.75rem 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hks-form-actions {
    justify-content: stretch;
    position: sticky;
    bottom: 0.25rem;
    z-index: 5;
    margin-top: 0.75rem;
    padding-top: 0.35rem;
    background: linear-gradient(to top, var(--bg-card, #fff) 70%, transparent);
  }

  .hks-form-actions .btn {
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
    font-weight: 700;
  }

  .hk-app-shell .expense-bill-row {
    flex-direction: column;
    align-items: stretch;
  }

  .hk-app-shell .expense-bill-preview {
    width: 100%;
    height: 180px;
    border-radius: 10px;
  }

  .hk-app-shell .expense-bill-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .hk-app-shell .expense-bill-controls .btn {
    width: 100%;
    min-height: 2.85rem;
    justify-content: center;
  }

  .hk-app-shell .expense-bill-controls .btn-primary,
  .hk-app-shell .hks-photo-capture {
    font-weight: 700;
  }

  .hk-app-shell .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.85rem !important;
  }

  .hk-app-shell .stat-card {
    padding: 0.65rem 0.45rem;
    text-align: center;
  }

  .hk-app-shell .stat-label {
    font-size: 0.65rem;
  }

  .hk-app-shell .stat-value {
    font-size: 1.2rem;
  }

  /* Prefer card list over wide tables on phones */
  .hk-app-shell .hks-recent-table,
  .hk-app-shell .hks-reports-table {
    display: none !important;
  }

  .hk-app-shell .hks-report-list {
    display: flex;
  }

  .hk-app-shell .hks-report-item {
    padding: 0.95rem;
    border-radius: 10px;
    background: var(--bg-card, #fff);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  }

  .hk-app-shell .hks-report-item-actions {
    gap: 0.4rem;
  }

  .hk-app-shell .hks-report-item-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
    justify-content: center;
  }

  .hk-app-shell .card-header {
    padding: 0.75rem 0.85rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
  }

  .hk-app-shell .card-header .btn {
    min-height: 2.4rem;
  }

  .hk-app-shell .card-body {
    padding: 0.85rem;
  }

  .hk-app-shell .search-bar {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 0.35rem;
  }

  .hk-app-shell .search-bar .form-control {
    width: 100%;
    max-width: none;
  }

  /* Hide native select when chip filters are present */
  .hk-app-shell .search-bar:has(.hks-status-select) {
    display: none;
  }

  .hk-app-shell .hks-status-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .hk-app-shell .hks-filter-chips {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
    margin: 0 0 0.85rem;
    scrollbar-width: none;
  }

  .hk-app-shell .hks-filter-chips::-webkit-scrollbar {
    display: none;
  }

  .hk-app-shell .hks-filter-chip {
    flex: 0 0 auto;
  }

  /* Toasts above bottom nav */
  body.hk-portal .toast-container {
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    top: auto;
    left: 0.65rem;
    right: 0.65rem;
  }

  /* Modal sheets clear the tab bar */
  body.hk-portal .modal-overlay {
    align-items: flex-end;
    padding: 0;
    z-index: 200;
  }

  body.hk-portal .modal {
    max-width: 100%;
    max-height: min(88dvh, 92vh);
    border-radius: 14px 14px 0 0;
    margin-bottom: 0;
  }

  body.hk-portal .modal-footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.hk-portal .modal-footer .btn {
    min-height: 2.75rem;
    flex: 1 1 auto;
  }
}

@media (max-width: 400px) {
  .hks-presets {
    grid-template-columns: 1fr;
  }

  .hk-app-shell .stats-grid {
    grid-template-columns: 1fr;
  }

  .hk-app-shell .hks-report-item-actions .btn {
    min-width: 100%;
  }
}

/* Auth page on phones */
@media (max-width: 480px) {
  body.hk-auth-page {
    min-height: 100dvh;
  }

  body.hk-auth-page .login-page {
    padding: 0.75rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    align-items: flex-start;
    min-height: 100dvh;
  }

  body.hk-auth-page .login-card.hk-auth-card {
    width: 100%;
    max-width: 100%;
    margin: 0.5rem 0;
    padding: 1.25rem 1rem;
  }

  body.hk-auth-page .form-control,
  body.hk-auth-page input.form-control {
    font-size: 16px !important;
    min-height: 2.85rem;
  }

  body.hk-auth-page .btn-block {
    min-height: 3rem;
    font-size: 1rem;
  }

  body.hk-auth-page .hk-auth-tab {
    font-size: 0.9rem;
  }
}
