/* Detail popup - centred dialog on every device */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(72, 64, 48, .46);
  backdrop-filter: blur(3px);
  z-index: 190;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
  opacity: 0;
  transition: opacity .22s ease;
}

.drawer-backdrop.on { opacity: 1; }

.drawer {
  position: relative;
  margin: auto;
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.97);
  opacity: 0;
  transition: transform .26s cubic-bezier(.2, .9, .3, 1.1), opacity .2s ease;
}

.drawer-backdrop.on .drawer { transform: none; opacity: 1; }

.drawer-grip { display: none; }

/* ------------------------------ header ------------------------------ */

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  flex: none;
}

.drawer-titles { flex: 1; min-width: 0; }

.drawer-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-sub {
  margin-top: 4px;
  font-size: 12.8px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-x {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.drawer-x:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--muted); }

/* ------------------------------- body ------------------------------- */

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 24px 26px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.drawer-body::-webkit-scrollbar { width: 10px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid #fff;
  border-radius: 999px;
}

.drawer .section-label {
  margin: 24px 0 6px;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
}

.drawer .section-label:first-child { margin-top: 16px; }
.drawer .section-label::after { background: var(--line); }

/* two column detail rows on wide popups, single column on phones */
.drawer .detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 34px;
}

.drawer .detail-grid .d-item {
  padding: 11px 1px;
  gap: 16px;
  align-items: center;
  font-size: 13.2px;
}

.drawer .detail-grid .d-item .d-k { font-size: 12.6px; }
.drawer .detail-grid .d-item .d-v {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* full width rows (address, notes) stack label over value */
.drawer .detail-grid .d-item.full {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
.drawer .detail-grid .d-item.full.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.drawer .detail-grid .d-item.full.inline .d-v {
  width: auto;
  text-align: left;
  font-weight: 700;
}
.drawer .detail-grid .d-item.full.row {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}
.drawer .detail-grid .d-item.full.row .d-v {
  width: auto;
  max-width: 74%;
  white-space: normal;
  overflow: visible;
  text-align: right;
  line-height: 1.5;
}

.drawer .detail-grid .d-item.full .d-v {
  white-space: normal;
  overflow: visible;
  text-align: left;
  width: 100%;
  line-height: 1.55;
  font-weight: 600;
}

@media (max-width: 640px) {
  .drawer .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------ footer ------------------------------ */

.drawer-foot {
  flex: none;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 15px 24px;
  padding-bottom: max(15px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 -8px 20px -18px rgba(72, 64, 48, .5);
}

.drawer-foot .btn { flex: 1 1 auto; }

@media (min-width: 560px) { .drawer-foot .btn { flex: 0 0 auto; } }

@media (max-width: 640px) {
  .drawer-backdrop { padding: 12px; }
  .drawer {
    width: 100%;
    max-height: 90vh;
    border-radius: 18px;
    transform: translateY(18px) scale(.98);
  }
  .drawer-head { padding: 16px 16px 14px; }
  .drawer-title { font-size: 16.5px; }
  .drawer-x { width: 34px; height: 34px; }
  .drawer-body { padding: 4px 16px 20px; }
  .drawer .section-label { margin-top: 20px; }
  .drawer-foot { padding: 13px 16px; }
}

/* mobile-first tables */
tr[data-view] { cursor: pointer; }

@media (max-width: 800px) {
  table.table { min-width: 0; }
}

@media (max-width: 640px) {
  .table thead th {
    font-size: 10.2px;
    padding: 8px 8px;
    white-space: nowrap;
  }
  .table tbody td { padding: 10px 8px; }
  .table .cell-strong { font-size: 13px; }
  .table .cell-sub { font-size: 10.6px; }
  .table .actions { gap: 4px; }
  .table .actions .row-btn { width: 28px; height: 28px; }
  .table .actions .row-btn.view { display: none; }
  .table .actions .btn-soft { display: none; }
  .table .actions .btn-xs { padding: 4px 7px; font-size: 11px; }
  .table .badge { font-size: 11px; padding: 3px 7px; }
  .table-foot {
    flex-wrap: wrap;
    gap: 8px;
    padding: 11px 13px;
  }
}
