/**
 * Tolheim fallback stylesheet.
 *
 * Provides decent default styling when css_framework=none, plus hooks for
 * overriding framework output. Uses CSS variables for easy theme overrides.
 *
 * To customize for your site, add CSS like:
 *   :root {
 *     --th-primary: #your-brand-color;
 *   }
 * in your template's custom.css.
 */

:root {
    --th-primary: #0d6efd;
    --th-primary-hover: #0a58ca;
    --th-success: #198754;
    --th-warning: #ffc107;
    --th-danger: #dc3545;
    --th-secondary: #6c757d;
    --th-info: #0dcaf0;
    --th-muted: #6c757d;
    --th-border: #dee2e6;
    --th-bg-light: #f8f9fa;
    --th-radius: 0.375rem;
    --th-gap: 0.75rem;
    --th-pad: 1rem;
}

/* Typography helpers */
.th-text-muted { color: var(--th-muted); }
.th-text-sm { font-size: 0.875em; }
.th-text-end { text-align: right; }
.th-text-center { text-align: center; }
.th-text-danger { color: var(--th-danger); }
.th-text-warning { color: #b58900; }
.th-text-bold { font-weight: 600; }
.th-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Spacing */
.th-mb-1 { margin-bottom: 0.25rem; }
.th-mb-2 { margin-bottom: 0.5rem; }
.th-mb-3 { margin-bottom: 1rem; }
.th-mt-4 { margin-top: 1.5rem; }
.th-p-3 { padding: 1rem; }
.th-divider { border-top: 1px solid var(--th-border); margin: 1rem 0; }
.th-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Flex */
.th-flex { display: flex; }
.th-flex-gap { gap: var(--th-gap); }
.th-flex-wrap { flex-wrap: wrap; }
.th-flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Grid */
.th-row { display: flex; flex-wrap: wrap; margin: 0 calc(var(--th-gap) * -0.5); }
.th-row-gap { row-gap: var(--th-gap); }
.th-col { padding: 0 calc(var(--th-gap) * 0.5); box-sizing: border-box; flex: 1 1 0; min-width: 0; }
.th-col-full { flex: 0 0 100%; }
.th-col-half { flex: 0 0 50%; }
.th-col-third { flex: 0 0 33.333%; }
.th-col-two-thirds { flex: 0 0 66.666%; }
.th-col-quarter { flex: 0 0 25%; }
.th-col-three-quarters { flex: 0 0 75%; }
.th-col-sidebar { flex: 0 0 33.333%; }
.th-col-main { flex: 0 0 66.666%; }
@media (max-width: 768px) {
    .th-col-half,
    .th-col-third,
    .th-col-two-thirds,
    .th-col-quarter,
    .th-col-three-quarters,
    .th-col-sidebar,
    .th-col-main {
        flex: 0 0 100%;
    }
}

/* Cards */
.th-card {
    background: #fff;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    margin-bottom: var(--th-pad);
}
.th-card-body { padding: var(--th-pad); }
.th-card-header {
    padding: 0.75rem var(--th-pad);
    background: var(--th-bg-light);
    border-bottom: 1px solid var(--th-border);
    font-weight: 600;
}
.th-list { list-style: none; padding: 0; margin: 0; }
.th-list-item {
    padding: 0.5rem var(--th-pad);
    border-bottom: 1px solid var(--th-border);
}
.th-list-item:last-child { border-bottom: 0; }

/* Buttons */
.th-button {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--th-radius);
    background: var(--th-bg-light);
    color: #212529;
    transition: background .15s, border-color .15s;
}
.th-button:hover { background: #e9ecef; }
.th-button-sm { padding: 0.25rem 0.5rem; font-size: 0.875em; }
.th-button-primary { background: var(--th-primary); color: #fff; border-color: var(--th-primary); }
.th-button-primary:hover { background: var(--th-primary-hover); color: #fff; }
.th-button-secondary { background: #fff; border-color: var(--th-secondary); color: var(--th-secondary); }
.th-button-secondary:hover { background: var(--th-secondary); color: #fff; }
.th-button-success { background: var(--th-success); color: #fff; border-color: var(--th-success); }
.th-button-warning { background: var(--th-warning); color: #212529; border-color: var(--th-warning); }
.th-button-danger { background: #fff; border-color: var(--th-danger); color: var(--th-danger); }
.th-button-danger:hover { background: var(--th-danger); color: #fff; }
.th-button-danger-solid { background: var(--th-danger); color: #fff; border-color: var(--th-danger); }
.th-button-outline-primary { background: #fff; border-color: var(--th-primary); color: var(--th-primary); }
.th-button-outline-primary:hover { background: var(--th-primary); color: #fff; }

/* Alerts */
.th-alert {
    padding: var(--th-pad);
    border-radius: var(--th-radius);
    border: 1px solid transparent;
    margin-bottom: var(--th-pad);
}
.th-alert-info { background: #cfe2ff; border-color: #b6d4fe; color: #084298; }
.th-alert-warning { background: #fff3cd; border-color: #ffe69c; color: #664d03; }
.th-alert-danger { background: #f8d7da; border-color: #f5c2c7; color: #842029; }
.th-alert-success { background: #d1e7dd; border-color: #badbcc; color: #0a3622; }
.th-alert-secondary { background: #e2e3e5; border-color: #d3d6d8; color: #41464b; }

/* Badges */
.th-badge {
    display: inline-block;
    padding: 0.25em 0.5em;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    border-radius: var(--th-radius);
    background: var(--th-secondary);
}
.th-badge-primary { background: var(--th-primary); }
.th-badge-success { background: var(--th-success); }
.th-badge-warning { background: var(--th-warning); color: #212529; }
.th-badge-danger { background: var(--th-danger); }
.th-badge-info { background: var(--th-info); color: #212529; }

/* Forms */
.th-label { display: block; margin-bottom: 0.25rem; }
.th-label-bold { font-weight: 600; }
.th-input, .th-select, .th-textarea {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    background: #fff;
    box-sizing: border-box;
}
.th-help { font-size: 0.875em; color: var(--th-muted); margin-top: 0.25rem; }
.th-form-group { margin-bottom: var(--th-pad); }

/* Tables */
.th-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--th-pad);
}
.th-table th,
.th-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--th-border);
    text-align: left;
    vertical-align: top;
}
.th-table th { font-weight: 600; }
.th-table-sm th, .th-table-sm td { padding: 0.4rem; }
.th-table-striped tr:nth-child(even) { background: var(--th-bg-light); }

/* Headings */
.th-h1 { font-size: 1.75rem; margin: 0 0 var(--th-pad); }
.th-h4 { font-size: 1.25rem; margin: 1rem 0 0.5rem; }

/* UIKit-adjacent helper classes we introduced */
.th-badge-success { background-color: var(--th-success); color: #fff; }
.th-badge-warning { background-color: var(--th-warning); color: #212529; }
.th-badge-danger  { background-color: var(--th-danger); color: #fff; }
.th-badge-secondary { background-color: var(--th-secondary); color: #fff; }
.th-badge-info    { background-color: var(--th-info); color: #212529; }

/* Component-specific micro-styles */
.com-tolheim-items .th-mono,
.com-tolheim-checkouts .th-mono,
.com-tolheim-reservations .th-mono {
    font-size: 0.95em;
}

/* Pagination */
.th-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--th-gap);
    margin-top: var(--th-pad);
    padding-top: 0.5rem;
    border-top: 1px solid var(--th-border);
    font-size: 0.9em;
}
.th-pagination-info {
    color: var(--th-muted);
}
.th-pagination-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.th-pagination-link,
.th-pagination-current,
.th-pagination-ellipsis {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--th-radius);
    text-decoration: none;
    color: #212529;
    border: 1px solid transparent;
    min-width: 2rem;
    text-align: center;
}
.th-pagination-link {
    border-color: var(--th-border);
    background: #fff;
}
.th-pagination-link:hover {
    background: var(--th-bg-light);
}
.th-pagination-current {
    background: var(--th-primary);
    color: #fff;
    border-color: var(--th-primary);
    font-weight: 600;
}
.th-pagination-ellipsis {
    color: var(--th-muted);
    cursor: default;
}
.th-pagination-disabled {
    color: var(--th-muted);
    border-color: var(--th-border);
    background: var(--th-bg-light);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ---- Modal ---- */
body.th-modal-open {
    overflow: hidden;
}
.th-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10050;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.th-modal-backdrop.th-modal-shown { opacity: 1; }
.th-modal {
    background: #fff;
    border-radius: var(--th-radius);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    width: 100%;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    transform: translateY(10px);
    transition: transform 0.2s;
}
.th-modal-backdrop.th-modal-shown .th-modal { transform: translateY(0); }
.th-modal-small  { max-width: 420px; }
.th-modal-medium { max-width: 640px; }
.th-modal-large  { max-width: 900px; }
.th-modal-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--th-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.th-modal-title { margin: 0; font-size: 1.15rem; font-weight: 600; }
.th-modal-close {
    background: none;
    border: 0;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    color: var(--th-muted);
    border-radius: var(--th-radius);
}
.th-modal-close:hover {
    background: var(--th-bg-light);
    color: #212529;
}
.th-modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
}
.th-modal-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--th-border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.th-modal-btn {
    padding: 0.4rem 1rem;
    border-radius: var(--th-radius);
    border: 1px solid var(--th-border);
    background: #fff;
    cursor: pointer;
    font-size: 0.95rem;
}
.th-modal-btn:hover { background: var(--th-bg-light); }
.th-modal-btn:disabled { opacity: 0.5; cursor: wait; }
.th-modal-btn-primary {
    background: var(--th-primary);
    border-color: var(--th-primary);
    color: #fff;
}
.th-modal-btn-primary:hover { background: var(--th-primary-hover); }
.th-modal-btn-danger {
    background: var(--th-danger);
    border-color: var(--th-danger);
    color: #fff;
}
.th-modal-btn-success {
    background: var(--th-success);
    border-color: var(--th-success);
    color: #fff;
}
.th-modal-btn-cancel {
    background: #fff;
    border-color: var(--th-border);
    color: #212529;
}

/* Form bits inside modal */
.th-modal-body .th-field { margin-bottom: 0.85rem; }
.th-modal-body .th-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.th-modal-body .th-field label .th-required { color: var(--th-danger); }
.th-modal-body input[type="text"],
.th-modal-body input[type="date"],
.th-modal-body input[type="number"],
.th-modal-body input[type="email"],
.th-modal-body select,
.th-modal-body textarea {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    background: #fff;
    font-size: 0.95rem;
    box-sizing: border-box;
}
.th-modal-body .th-field-error input,
.th-modal-body .th-field-error select,
.th-modal-body .th-field-error textarea {
    border-color: var(--th-danger);
}
.th-modal-body .th-field-message {
    color: var(--th-danger);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}
.th-modal-body .th-field-hint {
    color: var(--th-muted);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}
.th-modal-body .th-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.th-modal-body .th-row .th-field {
    flex: 1 1 0;
    min-width: 180px;
}

/* ---- Toasts ---- */
.th-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10060;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
}
.th-toast {
    pointer-events: auto;
    padding: 0.75rem 1rem;
    border-radius: var(--th-radius);
    background: #333;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s, transform 0.25s;
    max-width: 400px;
}
.th-toast-shown { opacity: 1; transform: translateY(0); }
.th-toast-success { background: var(--th-success); }
.th-toast-error   { background: var(--th-danger); }
.th-toast-info    { background: var(--th-primary); }
.th-toast-warning { background: var(--th-warning); color: #212529; }

/* ---- Drop zone (CSV import) ---- */
.th-dropzone {
    display: block;
    border: 2px dashed var(--th-border);
    border-radius: var(--th-radius);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--th-muted);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 0.75rem;
}
.th-dropzone:hover,
.th-dropzone.th-dropzone-active {
    border-color: var(--th-primary);
    background: var(--th-bg-light);
}
.th-dropzone input[type="file"] { display: none; }
.th-dropzone-selected {
    color: #212529;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    background: var(--th-bg-light);
    border-radius: var(--th-radius);
    margin-bottom: 0.75rem;
}

/* ---- Widget layout ---- */
.th-widget { position: relative; }
.th-widget-heading { margin-bottom: 0.75rem; }
.th-widget-toolbar { margin-bottom: 0.75rem; }
.th-widget-toolbar-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.th-widget-filters { margin-bottom: 0.75rem; }
.th-widget-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.th-widget-filter-row input[type="search"],
.th-widget-filter-row select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    background: #fff;
    min-width: 140px;
    flex: 1 1 140px;
}
.th-widget-filter-row input[type="search"] {
    flex: 2 1 200px;
}
.th-widget-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--th-muted);
}

/* Bulk action bar */
.th-widget-bulkbar {
    margin-bottom: 0.75rem;
}
.th-bulkbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    background: #fff3cd;
    border: 1px solid #ffe69c;
    border-left: 4px solid var(--th-warning);
    border-radius: var(--th-radius);
    flex-wrap: wrap;
}
.th-bulkbar-count {
    font-weight: 600;
    margin-right: auto;
    color: #664d03;
}

/* CSV reference expanders */
.th-ref-expander {
    margin-bottom: 0.5rem;
    background: var(--th-bg-light);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    padding: 0.25rem 0.75rem;
}
.th-ref-expander summary {
    cursor: pointer;
    padding: 0.4rem 0;
    font-size: 0.9em;
    color: var(--th-muted);
}
.th-ref-expander summary:hover { color: #212529; }
.th-chip-list {
    padding: 0.5rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.th-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #fff;
    border: 1px solid var(--th-border);
    border-radius: 1rem;
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Typeahead results dropdown */
.th-typeahead-results {
    border: 1px solid var(--th-border);
    border-top: 0;
    border-radius: 0 0 var(--th-radius) var(--th-radius);
    background: #fff;
    max-height: 280px;
    overflow-y: auto;
    margin-top: -1px;
    margin-bottom: 0.5rem;
}
.th-typeahead-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--th-border);
}
.th-typeahead-item:last-child { border-bottom: 0; }
.th-typeahead-item:hover,
.th-typeahead-item.th-typeahead-active {
    background: var(--th-bg-light);
}
.th-typeahead-empty {
    padding: 0.75rem;
    color: var(--th-muted);
    font-style: italic;
    font-size: 0.9em;
}

/* Reservation slot rendering */
.th-slot-loading td { background: var(--th-bg-light); }
.th-slot-container {
    padding: 0.4rem 0.5rem 0.6rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.th-slot {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.6rem;
    background: #fff;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    font-size: 0.92em;
}
.th-slot-fulfilled {
    border-left: 3px solid var(--th-success, #28a745);
}
.th-slot-pending {
    border-left: 3px solid #d0d7de;
    background: var(--th-bg-light);
}
.th-slot-icon {
    width: 1.3em;
    text-align: center;
    color: var(--th-muted);
}
.th-slot-fulfilled .th-slot-icon { color: var(--th-success, #28a745); font-weight: 700; }
.th-slot-text { flex: 1 1 auto; min-width: 0; }
.th-slot-state, .th-slot-actions { flex: 0 0 auto; }
.th-slot-escape {
    margin-top: 0.4rem;
    padding-left: 0.5rem;
    font-size: 0.85em;
}
.th-slot-escape a {
    color: var(--th-warning, #b08000);
    text-decoration: underline;
    text-decoration-style: dotted;
}
.th-slot-loading-msg { padding: 0.5rem; }

/* Fulfill modal header */
.th-fulfill-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--th-border);
}

/* Token field with copy button */
.th-token-row {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}
.th-token-row input {
    flex: 1 1 auto;
    background: var(--th-bg-light);
}

/* ============================================================
 * Barcode / QR rendering inside edit modals (1.4.1)
 * ============================================================ */
.th-token-qr-wrap {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fafafa;
    border-radius: 6px;
}
.th-token-qr-wrap canvas {
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

.th-barcode-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}
.th-barcode-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #fafafa;
    border-radius: 6px;
    margin-top: 0.25rem;
}
.th-barcode-wrap canvas {
    background: white;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.th-barcode-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.95rem;
}
.th-barcode-kind {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    background: #e8eef5;
    color: #475569;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

/* ============================================================
 * Unavailable reason display in items module (1.6.0)
 * ============================================================ */
.th-status-reason {
    margin-top: 0.25rem;
    font-style: italic;
    cursor: help;
}
.th-unavailable-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
}
.th-unavailable-reason {
    margin-top: 0.25rem;
    font-size: 1.05rem;
}
.th-unavailable-note {
    margin-top: 0.4rem;
    color: #555;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

/* ============================================================
 * Events module (1.8.0)
 * ============================================================ */

.th-events-filters {
    background: #f7f7f7;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.th-events-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}
.th-events-filter-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: #555;
}
.th-events-filter-row label.th-events-search {
    flex: 1 1 200px;
}
.th-events-filter-row input[type="text"],
.th-events-filter-row input[type="date"],
.th-events-filter-row select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}
.th-events-actions-detail {
    margin-top: 0.5rem;
}
.th-events-actions-detail summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    padding: 0.25rem 0;
    user-select: none;
}
.th-events-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.4rem;
    padding: 0.5rem 0;
}
.th-events-action-chk {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-family: ui-monospace, monospace;
}

.th-events-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.th-events-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.th-events-row:hover {
    background: #f9f9f9;
    border-color: #ccc;
}
.th-events-row-time {
    flex: 0 0 auto;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    color: #666;
    min-width: 5rem;
}
.th-events-row-main {
    flex: 1 1 auto;
    min-width: 0;
}
.th-events-row-title {
    font-weight: 600;
    font-size: 0.95rem;
}
.th-events-row-sub {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.1rem;
}
.th-events-row-actor {
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.15rem;
}
.th-events-flag-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}
.th-events-flag-badge.th-events-flag-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}
.th-events-flag-badge.th-events-flag-resolved {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

/* Modal */
.th-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.th-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.th-modal-sm { max-width: 400px; }
.th-modal-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.th-modal-close {
    background: none;
    border: 0;
    font-size: 1.25rem;
    cursor: pointer;
    color: #666;
    padding: 0 0.25rem;
}
.th-modal-body {
    padding: 1rem;
    flex: 1 1 auto;
}
.th-modal-actions {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.th-events-modal-meta {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}
.th-events-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0.5rem 0;
}
.th-events-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.6rem;
    background: #fafafa;
    border-radius: 4px;
    font-size: 0.9rem;
}
.th-events-detail-key {
    color: #666;
    text-transform: capitalize;
    flex: 0 0 auto;
}
.th-events-detail-val {
    flex: 1 1 auto;
    text-align: right;
    word-break: break-word;
}
.th-events-detail-val .th-events-link {
    background: none;
    border: 0;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    padding: 0 0.2rem;
}
.th-events-empty {
    padding: 0.5rem;
    color: #888;
    font-style: italic;
}
.th-events-muted {
    color: #888;
}
.th-events-flags-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.th-events-flag-row {
    padding: 0.5rem 0.75rem;
    background: rgba(245, 158, 11, 0.06);
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
}
.th-events-flag-row .th-events-flag-status {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.th-events-flag-pending { color: #b45309; }
.th-events-flag-resolved { color: #047857; }
.th-events-flag-note {
    margin: 0.3rem 0;
}
.th-events-flag-actions {
    margin-top: 0.4rem;
}
.th-events-no-flags {
    color: #888;
    font-style: italic;
    padding: 0.5rem;
}
.th-events-raw-detail {
    margin-top: 1rem;
    padding: 0.5rem;
    background: #f7f7f7;
    border-radius: 4px;
}
.th-events-raw-detail summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    user-select: none;
}
.th-events-raw {
    margin: 0.5rem 0 0;
    padding: 0.5rem;
    background: #1a1a1a;
    color: #ddd;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* ============================================================
 * Flags module (1.8.0)
 * ============================================================ */

.th-flags-filters {
    background: #f7f7f7;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.th-flags-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}
.th-flags-filter-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: #555;
}
.th-flags-filter-row label.th-flags-search { flex: 1 1 200px; }
.th-flags-filter-row input,
.th-flags-filter-row select {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

.th-flags-status-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
}
.th-tab {
    background: none;
    border: 0;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: #555;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    border-bottom: 2px solid transparent;
}
.th-tab.th-tab-active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}
.th-tab:hover:not(.th-tab-active) {
    background: #ececec;
}

.th-flags-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.th-flags-row {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    padding: 0.75rem 1rem;
}
.th-flags-row.th-flags-row-resolved {
    border-left-color: #10b981;
    opacity: 0.85;
    background: #fafafa;
}
.th-flags-row-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}
.th-flags-row-type {
    font-weight: 600;
    color: #444;
}
.th-flag-status {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}
.th-flag-status.th-flag-pending { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.th-flag-status.th-flag-resolved { background: rgba(16, 185, 129, 0.12); color: #047857; }
.th-flags-row-date {
    margin-left: auto;
    font-size: 0.75rem;
    color: #888;
    font-family: ui-monospace, monospace;
}
.th-flags-row-target {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}
.th-flags-row-note {
    background: #fff8eb;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
    white-space: pre-wrap;
}
.th-flags-row-resolved .th-flags-row-note { background: #f0fdf4; }
.th-flags-row-meta {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.4rem;
}
.th-flags-row-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

.th-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 0;
}
.th-pagination-info {
    color: #666;
    font-size: 0.85rem;
}

/* ============================================================
 * Signature display in supervisor reservation detail (1.9.0)
 * ============================================================ */
.th-signature-block {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.th-signature-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 0.25rem;
}
.th-signature-meta {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.th-signature-name {
    font-weight: 500;
    color: #0f172a;
}
.th-signature-thumb {
    display: inline-block;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px;
    cursor: zoom-in;
}
.th-signature-thumb img {
    display: block;
    max-width: 280px;
    max-height: 110px;
    height: auto;
    width: auto;
}

/* Inline signature thumbnail in event details (1.9.3) */
.th-events-signature-thumb {
    display: inline-block;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px;
    cursor: zoom-in;
}
.th-events-signature-thumb img {
    display: block;
    max-width: 240px;
    max-height: 80px;
    height: auto;
    width: auto;
}

/* ============================================================
 * Capture sections (2.1.0) — payment + waiver capture in
 * reservation modals (admin/supervisor and PWA).
 * ============================================================ */

.th-capture-host {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.th-capture-section {
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    padding: 0.75rem 1rem;
    background: var(--th-bg-light);
}
.th-capture-section-payment { border-left: 4px solid var(--th-primary); }
.th-capture-section-waiver  { border-left: 4px solid var(--th-info); }

/* Empty-state highlights driven by category capture mode */
.th-capture-empty-highlight {
    background: #fff8db;        /* soft yellow */
    border-color: #f5d96d;
}
.th-capture-empty-mandatory {
    background: #ffeaea;        /* soft red */
    border-color: #f1a8a8;
}

.th-capture-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.th-capture-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.th-capture-latest {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: #fff;
    padding: 0.75rem;
    border-radius: var(--th-radius);
    border: 1px solid var(--th-border);
}
.th-capture-is-correction {
    background: #fff5e6;
    border-color: #f5c97a;
}
.th-capture-qr-wrap {
    flex: 0 0 auto;
}
.th-capture-qr {
    display: block;
    width: 140px;
    height: 140px;
    background: #fff;
}
.th-capture-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.th-capture-ref {
    word-break: break-all;
    margin-bottom: 0.25rem;
    font-size: 0.875em;
}
.th-capture-when {
    color: var(--th-muted);
    font-size: 0.8125em;
    margin-bottom: 0.25rem;
}
.th-capture-notes {
    font-size: 0.875em;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--th-border);
}

.th-capture-empty {
    background: #fff;
    border: 1px dashed var(--th-border);
    border-radius: var(--th-radius);
    padding: 0.75rem;
    color: var(--th-muted);
    font-size: 0.875em;
}
.th-capture-empty-mandatory .th-capture-empty {
    color: #8a3a3a;
    border-color: #f1a8a8;
}

.th-capture-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* History reveal — uses native <details>/<summary> */
.th-capture-history {
    margin-top: 0.5rem;
    font-size: 0.875em;
}
.th-capture-history > summary {
    cursor: pointer;
    color: var(--th-muted);
    padding: 0.25rem 0;
    user-select: none;
}
.th-capture-history > summary:hover {
    color: var(--th-primary);
}
.th-capture-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--th-border);
}
.th-capture-history-row {
    background: #fff;
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius);
    padding: 0.5rem 0.75rem;
}
.th-capture-history-row.th-capture-is-correction {
    background: #fff5e6;
    border-color: #f5c97a;
}
.th-capture-history-when {
    color: var(--th-muted);
    font-size: 0.8125em;
    margin-bottom: 0.25rem;
}
.th-capture-history-ref {
    word-break: break-all;
}
.th-capture-history-notes {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--th-border);
    font-size: 0.875em;
}

/* Annotations within a history row */
.th-capture-annotations {
    margin-top: 0.5rem;
    padding-left: 0.75rem;
    border-left: 2px dotted var(--th-border);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.th-capture-annotation {
    font-size: 0.8125em;
}
.th-capture-annotation-when {
    color: var(--th-muted);
}

/* Choice modal buttons (returned + open preauth) */
.th-capture-choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.th-button-block {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
}
.th-button-sub {
    font-weight: normal;
    font-size: 0.8125em;
    opacity: 0.85;
    margin-top: 0.125rem;
}

/* 2.8.0: de-emphasised "Release pre-auth" link in the followup-choice modal.
   The primary action (Capture payment) is the green block button above;
   release is a small text link beneath because full release is a rare path
   used only for cancelled-before-pickup reservations. */
.th-capture-release-link {
    margin-top: 0.5rem;
    align-self: center;
    text-align: center;
    font-size: 0.875em;
    padding: 0.25rem 0.5rem;
}
/* 2.8.0: per-history-row QR modal */
.th-capture-qr-modal {
    text-align: center;
}
.th-capture-qr-meta {
    margin-bottom: 0.75rem;
}
.th-capture-qr-canvas-wrap {
    display: flex;
    justify-content: center;
    background: #fff;
    padding: 0.75rem;
    border-radius: 4px;
}
.th-capture-qr-canvas-wrap canvas {
    max-width: 100%;
    height: auto;
}
.th-capture-qr-ref {
    margin-top: 0.75rem;
    word-break: break-all;
    font-size: 0.875em;
}

/* Scanner host inside the capture scan modal */
.th-capture-scan-host {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.th-capture-scan-mount {
    width: 100%;
    min-height: 240px;
    background: #000;
    border-radius: var(--th-radius);
    overflow: hidden;
}
.th-capture-scan-status {
    font-size: 0.875em;
    color: var(--th-muted);
    text-align: center;
}

/* ----- Row dots (capture-completeness signal) ----- */
.th-capture-dot {
    display: inline-block;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.15);
}
.th-capture-dot-red    { background: var(--th-danger); }
.th-capture-dot-yellow { background: var(--th-warning); }
.th-capture-dot-green  { background: var(--th-success); }

/* Required asterisk used in capture sections */
.th-capture-section .th-required {
    color: var(--th-danger);
    font-weight: 700;
    margin-left: 0.125rem;
}

/* Tighten the xs link button used for "Add note" */
.th-button-xs {
    padding: 0.125rem 0.375rem;
    font-size: 0.8125em;
}
.th-button-link {
    background: transparent;
    border: none;
    color: var(--th-primary);
    text-decoration: underline;
    cursor: pointer;
}
.th-button-link:hover { color: var(--th-primary-hover); }

/* ============================================================
 * 2.4.1 — Affected-items link in flags module
 * ============================================================ */
.th-flags-affected-link {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--th-link, #0d6efd);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}
.th-flags-affected-link:hover {
    text-decoration: underline;
}

/* Auto and broadcast badges (referenced from the row markup,
 * complete the styling started in 2.4.0). */
.th-badge-info {
    background: var(--th-info-bg, #cff4fc);
    color: var(--th-info-fg, #055160);
}
.th-badge-warning {
    background: var(--th-warning-bg, #fff3cd);
    color: var(--th-warning-fg, #856404);
}
.th-badge-secondary {
    background: var(--th-surface-2, #e9ecef);
    color: var(--th-text-muted, #6c757d);
}


/* 2.8.0: Suggested charge → clickable link + breakdown modal */
.th-button-link {
    background: none;
    border: none;
    color: var(--th-link, #0066cc);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.th-button-link:hover { text-decoration-style: solid; }
.th-suggested-charge-btn strong { font-size: 1.05em; }
.th-charge-breakdown-table { width: 100%; margin: 0.5rem 0; }
.th-charge-breakdown-table .th-text-right { text-align: right; }
.th-charge-breakdown-table .th-row-total th {
    border-top: 2px solid var(--th-border, #ccc);
    padding-top: 0.6rem;
    font-size: 1.05em;
}
.th-text-sm { font-size: 0.875em; }
.th-text-muted { color: var(--th-text-muted, #6c757d); }
.th-mt-2 { margin-top: 0.5rem; }
