/* Appointment detail view (slide panel) */

.apt-detail-view {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding-bottom: 24px;
}

/* Hero */
.apt-detail-hero {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.apt-detail-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.apt-detail-hero-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.apt-detail-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.apt-detail-patient-name {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
}

.apt-detail-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.apt-detail-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}

.apt-detail-visits {
    font-size: 10px;
    color: #9ca3af;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.apt-detail-balance {
    flex-shrink: 0;
    text-align: right;
}

.apt-detail-balance-label {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .5px;
}

.apt-detail-balance-amount {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    margin-top: 1px;
}

/* Meta row */
.apt-detail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.apt-detail-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.apt-detail-meta-item i {
    font-size: 11px;
    opacity: 0.6;
}

.apt-detail-meta-sep {
    color: #d1d5db;
    font-size: 10px;
}

/* Payment action at bottom */
.apt-detail-actions {
    padding: 16px 20px;
}

.apt-detail-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.apt-detail-action-payment {
    background: #16a34a;
    color: #fff;
}

.apt-detail-action-payment:hover {
    background: #15803d;
}

/* Room pill dropdown */
.apt-detail-room-dd {
    position: relative;
}

.apt-detail-room-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    transition: all 0.15s;
    user-select: none;
}

.apt-detail-room-pill:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.apt-detail-room-pill.active {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.apt-detail-room-pill i {
    font-size: 10px;
    color: #9ca3af;
}

.apt-detail-room-pill .fa-chevron-down {
    font-size: 8px;
    transition: transform 0.15s;
}

.apt-detail-room-pill.active .fa-chevron-down {
    transform: rotate(180deg);
}

.apt-detail-room-menu {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 6px);
    min-width: 160px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
    padding: 4px;
    z-index: 50;
}

.apt-detail-room-menu.show {
    display: block;
}

.apt-detail-room-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
}

.apt-detail-room-option:hover {
    background: #f3f4f6;
}

.apt-detail-room-option.selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.apt-detail-room-option i {
    font-size: 11px;
    color: #9ca3af;
    width: 14px;
    text-align: center;
}

.apt-detail-room-option.selected i {
    color: #1d4ed8;
}

.apt-detail-history-pill {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Hero sub line (provider + treatment) */
.apt-detail-hero-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.apt-detail-hero-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Patient Info Strip */
.apt-detail-patient-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
}

.apt-detail-pt-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
}

.apt-detail-pt-tag i {
    font-size: 0.65rem;
    color: #9ca3af;
}

.apt-detail-pt-tag-warn {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.apt-detail-pt-tag-warn i {
    color: #d97706;
}

/* Body */
.apt-detail-body {
    padding: 20px;
}

.apt-detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Cards (provider notes & payments) */
.apt-detail-card-header {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.apt-detail-card-header i {
    font-size: 10px;
    color: #9ca3af;
}

.apt-detail-card-list {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.apt-detail-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
}

.apt-detail-card-row.bordered {
    border-bottom: 1px solid #f3f4f6;
}

.apt-detail-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #111;
}

.apt-detail-card-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.apt-detail-card-price {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.apt-detail-card-total {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
}

.apt-detail-pay-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 99px;
    text-transform: capitalize;
    white-space: nowrap;
}

/* Payment table layout */
.apt-detail-card-table-header {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.9fr 0.9fr;
    gap: 6px;
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.apt-detail-card-table-row {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.9fr 0.9fr;
    gap: 6px;
    align-items: center;
    padding: 10px 12px;
}

/* Action buttons */
.apt-action-btn {
    flex: 1 1 0;
    min-width: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 10px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apt-action-btn:hover {
    background: #f3f4f6;
}

.apt-action-btn i {
    font-size: 11px;
    flex-shrink: 0;
}

.apt-action-edit {
    color: #fff !important;
    background: #3b82f6;
    border-color: #3b82f6;
}

.apt-action-edit:hover {
    background: #2563eb;
}

.apt-action-primary {
    color: #fff !important;
    background: #16a34a;
    border-color: #16a34a;
}

.apt-action-primary:hover {
    background: #15803d;
}

/* Payment method toggle buttons */
.pay-method-btn {
    flex: 1;
    padding: 8px 6px;
    border: 1.5px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: inherit;
}
.pay-method-btn:hover {
    border-color: var(--calendar-green, #00b300);
    color: var(--calendar-green, #00b300);
}
.pay-method-btn.active {
    border-color: var(--calendar-green, #00b300);
    background: var(--calendar-green, #00b300);
    color: #fff;
}

/* Payment services list inside modal */
.pay-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
}
.pay-item-row:last-child { border-bottom: none; }
.pay-item-name  { flex: 1; font-weight: 500; }
.pay-item-teeth { color: #9ca3af; font-size: 12px; }
.pay-item-qty   { color: #6b7280; font-size: 12px; white-space: nowrap; }
.pay-item-price { font-weight: 600; white-space: nowrap; min-width: 60px; text-align: right; }

.apt-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.apt-detail-row:last-child { border-bottom: none; }

.apt-detail-icon {
    width: 18px;
    text-align: center;
    color: #9ca3af;
    margin-top: 2px;
    flex-shrink: 0;
}

.apt-detail-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    font-weight: 600;
}

.apt-detail-value {
    font-size: 14px;
    color: #111827;
    font-weight: 500;
}

.apt-detail-room-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    cursor: pointer;
    width: 100%;
    max-width: 180px;
    margin-top: 2px;
}

.apt-detail-room-select:hover { border-color: #6b7280; }
.apt-detail-room-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px #bfdbfe; }

.apt-detail-notes-row { align-items: flex-start; }

.apt-detail-notes {
    font-size: 13px;
    color: #374151;
    line-height: 1.55;
    background: #f9fafb;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid #f0f0f0;
}

/* Action bar */
.apt-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    margin-top: auto;
}

.btn-danger-outline {
    background: #fff;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}
.btn-danger-outline:hover { background: #fee2e2; }

/* Sidebar done / closed section */

.apt-done-section {
    margin-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.apt-done-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    background: #f9fafb;
}

.apt-done-count {
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
}

/* Keep summary chip styles for any legacy usage */
.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.summary-chip.summary-completed  { background: #d1fae5; color: #065f46; }
.summary-chip.summary-noshow     { background: #f3f4f6; color: #374151; }
.summary-chip.summary-cancelled  { background: #fee2e2; color: #991b1b; }

.room-visit-text {
    font-size: 10px;
    color: #6b7280;
    font-style: italic;
}

/* Patient quick-view popover */

.apt-popover {
    position: fixed;
    z-index: 9999;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 210px;
    max-width: 270px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.apt-popover.visible {
    opacity: 1;
}

.apt-popover-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.apt-popover-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 6px 0;
}

.apt-popover-row {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 4px;
    align-items: flex-start;
}

.apt-popover-row i {
    width: 14px;
    color: #9ca3af;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Calendar dot indicators */

.day-apt-dots {
    display: flex;
    gap: 3px;
    justify-content: center;
    align-items: center;
    padding: 3px 4px 0;
    min-height: 12px;
}

.apt-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.apt-dot-overflow {
    font-size: 9px;
    font-weight: 700;
    color: #9ca3af;
    line-height: 1;
    flex-shrink: 0;
}

/* Patient history panel (slide panel) */

.ph-panel {
    display: flex;
    flex-direction: column;
}

/* Header */
.ph-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.ph-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ph-header-info {
    flex: 1;
    min-width: 0;
}

.ph-header-name {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    line-height: 1.2;
}

.ph-header-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.ph-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}

.ph-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.ph-meta-item i {
    font-size: 10px;
    color: #9ca3af;
}

/* Stats row */
.ph-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid #e5e7eb;
}

.ph-stat {
    text-align: center;
    padding: 10px 8px;
    border-right: 1px solid #f3f4f6;
}

.ph-stat:last-child {
    border-right: none;
}

.ph-stat-val {
    font-size: 20px;
    font-weight: 800;
    color: #111;
    line-height: 1;
}

.ph-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 3px;
}

/* Body content (scrolls with slide panel body) */
.ph-body {
    padding: 0;
}

/* Two-column layout for wide patient history panel */
.ph-cols {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 0;
    align-items: start;
    padding: 16px 0 20px;
}

.ph-col-left {
    padding: 0 12px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid #f3f4f6;
    min-width: 0;
}

.ph-col-right {
    padding: 0 20px 0 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* Section card (used inside columns) */
.ph-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.ph-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ph-card-header i { color: #6b7280; font-size: 11px; }

.ph-card-body { padding: 0; }

/* Small table inside ph-card */
.ph-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.ph-table th {
    padding: 7px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}
.ph-table td {
    padding: 8px 10px;
    color: #374151;
    border-bottom: 1px solid #f9fafb;
    vertical-align: middle;
}
.ph-table tr:last-child td { border-bottom: none; }
.ph-table td.right { text-align: right; }
.ph-table td.center { text-align: center; }

/* Item list rows (medications, conditions etc.) */
.ph-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 12px;
}
.ph-item-row:last-child { border-bottom: none; }
.ph-item-name { flex: 1; font-weight: 500; color: #374151; }
.ph-item-sub { font-size: 11px; color: #9ca3af; margin-top: 1px; }
.ph-item-extra { text-align: right; font-size: 11px; color: #6b7280; }

/* Dental history fields */
.ph-dental-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.ph-dental-field {
    padding: 8px 14px;
    border-bottom: 1px solid #f9fafb;
}
.ph-dental-field:nth-child(odd) { border-right: 1px solid #f3f4f6; }
.ph-dental-label { font-size: 10px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.ph-dental-val { font-size: 12px; color: #374151; }

/* Image grid */
.ph-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    padding: 12px;
}
.ph-image-thumb { border-radius: 7px; overflow: hidden; border: 1px solid #e5e7eb; aspect-ratio: 1; background: #f3f4f6; }
.ph-image-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph-image-label { font-size: 10px; color: #6b7280; text-align: center; margin-top: 3px; }

/* Legacy section (keep for backwards compat) */
.ph-section {
    margin-bottom: 0;
    padding: 0;
}

.ph-section:last-child { margin-bottom: 0; }
.ph-section:first-child { padding-top: 0; }

.ph-inline-empty { padding: 16px; text-align: center; font-size: 12px; color: #9ca3af; }
.ph-inline-empty i { font-size: 18px; display: block; margin-bottom: 6px; }
.ph-pay-amount { color: #16a34a; font-weight: 600; }
.ph-allergy-icon { color: #f59e0b; font-size: 11px; flex-shrink: 0; }
.ph-risk-wrap { padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.ph-risk-icon { font-size: 9px; }
.ph-provider-time { font-size: 10px; color: #9ca3af; }
.ph-provider-treatment { font-size: 11px; color: #6b7280; }
.ph-section-count { font-size: 11px; font-weight: 500; color: #9ca3af; margin-left: 4px; }
.ph-loading { padding: 16px; text-align: center; color: #9ca3af; font-size: 12px; }

.ph-empty {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 13px;
}

/* Visit rows */
.ph-visit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.ph-visit-row.bordered {
    border-bottom: 1px solid #f3f4f6;
}

.ph-visit-date {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
    min-width: 70px;
    flex-shrink: 0;
}

.ph-visit-info {
    flex: 1;
    min-width: 0;
}

.ph-visit-treatment {
    font-size: 12px;
    font-weight: 600;
    color: #111;
}

.ph-visit-provider {
    font-size: 11px;
    font-weight: 500;
    margin-top: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ph-visit-provider i {
    font-size: 9px;
}

/* Medications */
.ph-med-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
}

.ph-med-row.bordered {
    border-bottom: 1px solid #f3f4f6;
}

.ph-med-name {
    font-size: 12px;
    font-weight: 600;
    color: #111;
}

.ph-med-dose {
    font-size: 11px;
    font-weight: 600;
    color: #6366f1;
    background: #ede9fe;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Allergies */
.ph-allergy-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

/* Risk factors */
.ph-risk-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.ph-risk-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.ph-risk-pill i {
    font-size: 9px;
}

.ph-risk-no {
    background: #d1fae5;
    color: #065f46;
}

.ph-risk-yes {
    background: #fee2e2;
    color: #991b1b;
}

/* Header QR Code */
.ph-header-qr-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ph-header-qr {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 2px;
}
.ph-header-qr-copy {
    width: 72px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: #3b82f6;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.ph-header-qr-copy:hover { background: #2563eb; }
.ph-header-qr-copy i { margin-right: 3px; }

/* Header Print Button */
.ph-header-print-btn {
    flex-shrink: 0;
    align-self: center;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.ph-header-print-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Patient history print overlay */
#ph-print-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: #fff;
    overflow-y: auto;
    padding: 32px 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#ph-print-overlay .ph-header { margin-bottom: 16px; }
#ph-print-overlay .ph-header-name { font-size: 18px; font-weight: 700; }
#ph-print-overlay .ph-header-tags { display: flex; gap: 6px; margin-top: 4px; }
#ph-print-overlay .ph-header-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: #6b7280; }
#ph-print-overlay .ph-header-qr-wrap { display: block !important; }
#ph-print-overlay .ph-header-qr { width: 64px; height: 64px; }
#ph-print-overlay .ph-stats { display: flex; gap: 16px; margin: 16px 0 20px; }
#ph-print-overlay .ph-stat { text-align: center; padding: 12px 20px; background: #f3f4f6; border-radius: 8px; flex: 1; }
#ph-print-overlay .ph-stat-val { font-size: 22px; font-weight: 700; }
#ph-print-overlay .ph-stat-label { font-size: 11px; color: #6b7280; margin-top: 2px; }
#ph-print-overlay .ph-card { margin-bottom: 14px; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; break-inside: avoid; page-break-inside: avoid; }
#ph-print-overlay .ph-card-header { padding: 10px 14px; background: #f9fafb; font-weight: 600; font-size: 13px; border-bottom: 1px solid #e5e7eb; }
#ph-print-overlay .ph-card-header i { margin-right: 6px; color: #6b7280; }
#ph-print-overlay .ph-card-body { padding: 12px 14px; }
#ph-print-overlay table { width: 100%; border-collapse: collapse; font-size: 12px; page-break-inside: auto; }
#ph-print-overlay th,
#ph-print-overlay td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #f3f4f6; }
#ph-print-overlay th { background: #f9fafb; font-weight: 600; font-size: 11px; }
#ph-print-overlay tr { page-break-inside: avoid; page-break-after: auto; }
#ph-print-overlay .ph-item-row { display: flex; align-items: center; padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
#ph-print-overlay .ph-item-name { font-weight: 500; font-size: 13px; }
#ph-print-overlay .ph-item-sub { font-size: 11px; color: #6b7280; }
#ph-print-overlay .ph-item-extra { font-size: 11px; color: #9ca3af; margin-left: 8px; }
#ph-print-overlay .ph-cols { display: flex; gap: 16px; }
#ph-print-overlay .ph-col-left,
#ph-print-overlay .ph-col-right { flex: 1; }
#ph-print-overlay .ph-image-grid { display: flex; flex-wrap: wrap; gap: 8px; }
#ph-print-overlay .ph-image-thumb { width: 120px; height: 90px; overflow: hidden; border-radius: 6px; }
#ph-print-overlay .ph-image-thumb img { width: 100%; height: 100%; object-fit: cover; }
#ph-print-overlay .ph-allergy-icon { color: #dc2626; margin-right: 6px; }
#ph-print-overlay .ph-risk-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
#ph-print-overlay .ph-dental-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#ph-print-overlay .ph-dental-label { font-size: 11px; color: #6b7280; }
#ph-print-overlay .ph-dental-val { font-size: 13px; font-weight: 500; }
#ph-print-overlay .ph-inline-empty { color: #9ca3af; font-size: 12px; font-style: italic; }
#ph-print-overlay .apt-detail-pt-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: #f3f4f6; border-radius: 99px; font-size: 11px; }
#ph-print-overlay .ph-status-badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 600; }
body.ph-printing > *:not(#ph-print-overlay) { display: none !important; }
@media print {
    @page { margin: 1.5cm; size: A4; }
    #ph-print-overlay { padding: 0; }
}

/* PH slide panel helpers */
.ph-status-badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 600; }
.ph-avatar-lg    { width: 48px; height: 48px; font-size: 18px; flex-shrink: 0; background: #ede9fe; color: #6366f1; border: 2px solid #e0e7ef; }
.ph-padded-actions { padding: 12px 20px; }

/* Detail view helpers */
.apt-detail-card-full { grid-column: 1 / -1; }
.apt-detail-loading-strip { opacity: 0.5; }
.apt-detail-note-wrap { white-space: pre-wrap; }

/* Responsive / phone (≤ 640px) */

@media (max-width: 640px) {

    .apt-detail-hero {
        padding: 14px 14px 12px;
    }

    .apt-detail-hero-sub {
        flex-wrap: wrap;
        gap: 3px;
    }

    .apt-detail-avatar {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }

    .apt-detail-patient-name {
        font-size: 15px;
    }

    .apt-detail-balance-amount {
        font-size: 16px;
    }

    .apt-detail-patient-strip {
        padding: 10px 14px;
    }

    /* Stack the two cards vertically */
    .apt-detail-body {
        padding: 12px;
    }

    .apt-detail-columns {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Payment table: drop "Received By" and "Balance Due" on phone */
    .apt-detail-card-table-header,
    .apt-detail-card-table-row {
        grid-template-columns: 1.4fr 1fr;
    }

    .apt-detail-card-table-header span:nth-child(3),
    .apt-detail-card-table-header span:nth-child(4),
    .apt-detail-card-table-row span:nth-child(3),
    .apt-detail-card-table-row span:nth-child(4) {
        display: none;
    }

    .apt-detail-actions {
        padding: 10px 14px;
    }
}
