/* =====================================================================
   Namma Property Admin - phone first, wide layout on desktop (900px and above).
   Loaded after admin.css (the common look shared with the client screens).
   ===================================================================== */
body.adm { background: var(--bg); }
img { max-width: 100%; }
.shell { display: flex; min-height: 100vh; }
.shell > .side { display: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.content main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 16px; }
.adm .np-footer { position: static; margin-bottom: calc(58px + env(safe-area-inset-bottom)); }
.adm.no-nav .np-footer { margin-bottom: 0; }
.adm.no-nav .content main { max-width: 420px; }
.page-title .back-d { display: none; }
.page-title { gap: 10px; flex-wrap: wrap; }

/* Bottom menu (phone) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; font-size: 11px; font-weight: 600; color: var(--muted); }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.on { color: var(--brand); }
.adm .toast { bottom: 80px; }

/* Lists and filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; flex: 1 1 140px; }
.filters .btn { flex: 0 0 auto; padding: 11px 16px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; font: inherit; background: #fff; }
.search .btn { padding: 10px 14px; }
.date-bar[hidden] { display: none; }
.date-bar .step {
  flex: 0 0 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
a.chip { display: block; }
.chips.wrap { flex-wrap: wrap; }
.chips.wrap .chip { flex: 0 0 auto; padding: 6px 12px; }
.err-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.card-box h2 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: default; }

/* Pager */
.pager { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; font-size: 13px; margin: 12px 0; }
.pager .per a, .pager .nav a { padding: 4px 9px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-weight: 600; }
.pager .per a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .off { color: #cbd5e1; padding: 4px 9px; }
.pager .info { color: var(--muted); }

/* Tables (reports, clients). The table scrolls inside its box: headings stay on top,
   the grand total stays at the bottom. */
.tbl-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 150px); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: #e6faf6; color: var(--brand-dark); text-align: left; padding: 10px 12px; white-space: nowrap; font-size: 13px; }
.tbl td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .nw { white-space: nowrap; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl tfoot td { position: sticky; bottom: 0; z-index: 1; background: #134e4a; color: #fff; font-weight: 700; border-top: 0; white-space: nowrap; }
.tbl td small { color: var(--muted); }
/* When a wide report is scrolled sideways, the first column stays in view */
.tbl:not(.stack) td:first-child { position: sticky; left: 0; background: var(--surface); }
.tbl:not(.stack) th:first-child { left: 0; z-index: 2; }
.tbl:not(.stack) tfoot td:first-child { background: #134e4a; z-index: 2; }

/* Phone: a table marked "stack" shows each row as a small card */
@media (max-width: 699px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr { border-top: 6px solid var(--bg); padding: 6px 0; }
  .tbl.stack tr:first-child { border-top: 0; }
  .tbl.stack td { border: 0; padding: 4px 14px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto; }
  .tbl.stack td.main { font-weight: 700; font-size: 15px; text-align: left; }
  .tbl.stack td.main::before { content: none; }
  .tbl-wrap.stack-wrap { max-height: none; overflow: visible; }
  .tbl.stack tfoot { display: block; position: sticky; bottom: calc(58px + env(safe-area-inset-bottom)); }
  .tbl.stack tfoot tr { border-top: 0; padding: 4px 0; background: #134e4a; border-radius: 0 0 var(--radius) var(--radius); }
  .tbl.stack tfoot td { position: static; background: none; }
  .tbl.stack tfoot td::before { color: #d1fae5; }
  .tbl.stack td:empty { display: none; }
}

/* Desktop */
@media (min-width: 900px) {
  .shell > .side {
    display: flex; flex-direction: column; gap: 14px; flex: 0 0 232px;
    position: sticky; top: 0; height: 100vh; padding: 18px 14px;
    background: linear-gradient(180deg, var(--brand), var(--brand-dark)); color: #fff;
  }
  .shell > .side .brand { display: flex; gap: 10px; align-items: center; }
  .shell > .side .brand img { width: 42px; height: 42px; border-radius: 10px; }
  .shell > .side .en { font-size: 18px; font-weight: 700; line-height: 1.15; }
  .shell > .side .kn { font-family: "Noto Sans Kannada", sans-serif; font-size: 14px; color: #fde68a; }
  .shell > .side .hdr-badge { align-self: flex-start; }
  .shell > .side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 6px; }
  .shell > .side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #d1fae5; font-weight: 600; }
  .shell > .side nav a svg { width: 20px; height: 20px; }
  .shell > .side nav a:hover { background: #ffffff1a; }
  .shell > .side nav a.on { background: #fff; color: var(--brand-dark); }
  .shell > .side .who { font-size: 13px; color: #d1fae5; }
  .shell > .side .who a { color: #fff; font-weight: 700; text-decoration: underline; }

  .adm:not(.no-nav) .np-header { display: none; }
  .bottom-nav { display: none; }
  .adm .np-footer { margin-bottom: 0; }
  .adm .toast { bottom: 40px; }
  .content main { padding: 22px 28px; }
  .page-title { padding: 14px 28px; font-size: 18px; position: sticky; top: 0; z-index: 9; justify-content: flex-start; }
  .page-title .back-d { display: inline; font-size: 14px; }
  .page-title .right { margin-left: auto; }

  .top-filters { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
  .top-filters > * { flex: 0 1 380px; }
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .tile { padding: 16px 18px; }
  .tile .num { font-size: 34px; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
  .prop-list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
  .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .detail-grid .gallery img { max-height: 320px; }
  .search { max-width: 520px; }
  .narrow { max-width: 520px; }
  .tbl-wrap { max-height: calc(100vh - 250px); }
}

@media print {
  .shell > .side, .bottom-nav, .np-header, .np-footer, .filters, .pager, .search, .chips, .tabs, .no-print { display: none !important; }
  .tbl-wrap { max-height: none; overflow: visible; box-shadow: none; }
  .tbl th, .tbl tfoot td { position: static; }
  body.adm { background: #fff; }
}
