/* =============================================================================
   Document History — searchable / sortable saved work list + detail shell
   Genericized from Rental quote history (works for estimates, quotes, …).
   ============================================================================= */

:root {
  --dh-brand: var(--brand-red, #c02030);
  --dh-brand-dark: var(--brand-red-dark, #9a1a26);
  --dh-brand-soft: var(--brand-red-soft, #fdf2f3);
  --dh-font: Arial, Helvetica, sans-serif;
  --dh-line: #ddd;
}

.dh-root .btn,
.document-history-scope .btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #666;
  background: #f5f5f5;
  color: #1a1a1a;
  font-family: var(--dh-font);
  font-size: 0.9rem;
  cursor: pointer;
}
.dh-root .btn:hover,
.document-history-scope .btn:hover { background: #e8e8e8; }
.dh-root .btn-primary,
.document-history-scope .btn-primary {
  background: var(--dh-brand);
  border-color: var(--dh-brand);
  color: #fff;
}
.dh-root .btn-primary:hover,
.document-history-scope .btn-primary:hover {
  background: var(--dh-brand-dark);
  border-color: var(--dh-brand-dark);
}
.dh-root .btn-small,
.document-history-scope .btn-small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.dh-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .dh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dh-kpi {
  background: #fff;
  border: 1px solid #e8c5c9;
  padding: 12px 14px;
  font-family: var(--dh-font);
}
.dh-kpi .n {
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--dh-brand);
}
.dh-kpi .l {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-top: 2px;
}

.dh-toolbar,
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.dh-toolbar input[type="search"],
.toolbar input[type="search"] {
  flex: 1 1 200px;
  padding: 7px 9px;
  border: 1px solid #999;
  font: inherit;
  font-family: var(--dh-font);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #ccc;
  background: #fff;
}

#history-table,
.dh-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--dh-font);
  font-size: 0.88rem;
}
#history-table th,
#history-table td,
.dh-table th,
.dh-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--dh-line);
}
#history-table th,
.dh-table th {
  background: var(--dh-brand-soft);
  color: var(--dh-brand-dark);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
#history-table tbody tr,
.dh-table tbody tr {
  cursor: pointer;
}
#history-table tbody tr:hover,
.dh-table tbody tr:hover {
  background: #fdf2f3;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { background: #f8e4e6; }
th.sortable .sort-ind {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.45;
  font-size: 0.7rem;
}
th.sortable.is-sorted .sort-ind {
  opacity: 1;
  color: var(--dh-brand);
}

.dh-detail-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.dh-root .btn-danger,
.document-history-scope .btn-danger {
  background: #fff;
  border: 1px solid #9b1c1c;
  color: #9b1c1c;
  cursor: pointer;
  font-family: var(--dh-font);
  font-size: 0.85rem;
  padding: 6px 12px;
}
.dh-root .btn-danger:hover,
.document-history-scope .btn-danger:hover {
  background: #fef2f2;
  border-color: #7f1d1d;
  color: #7f1d1d;
}
.dh-detail-head .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.dh-detail-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-family: var(--dh-font);
}
.dh-detail-status label {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--dh-brand-dark);
}
.dh-detail-status select {
  padding: 6px 8px;
  border: 1px solid #999;
  font: inherit;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #e8c5c9;
  background: #fff;
  font-family: var(--dh-font);
  font-size: 0.88rem;
}
@media (max-width: 600px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-grid .cell {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
}
.detail-grid .cell .lbl {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: bold;
  margin-bottom: 2px;
}
.detail-grid .cell .val {
  color: #1a1a1a;
}

.muted { color: #666; }
.small { font-size: 0.85rem; }
.success {
  color: #146c43;
  font-family: var(--dh-font);
  font-size: 0.85rem;
  font-weight: bold;
}
