/* Panama HQ - High-contrast outdoor theme */

:root {
    --brand-name: "Panama HQ";
    --primary: #1a5276;
    --primary-light: #2980b9;
    --accent: #e67e22;
    --success: #27ae60;
    --danger: #c0392b;
    --warning: #f39c12;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-muted: #555;
    --border: #333;
    --border-light: #ccc;
    --radius: 8px;
    --shadow: 0 2px 4px rgba(0,0,0,0.15);
    --tap-min: 48px;
    --font-base: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: var(--font-base);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: 80px;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

.header h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-back {
    background: none;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    width: var(--tap-min);
    height: var(--tap-min);
    border-radius: var(--radius);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back:active { background: rgba(255,255,255,0.2); }

.header-actions {
    display: flex;
    gap: 8px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 3px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    min-height: var(--tap-min);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    border-right: 1px solid var(--border-light);
    transition: background 0.15s;
}

.bottom-nav a:last-child { border-right: none; }
.bottom-nav a.active { color: var(--primary); background: #e8f0fe; }
.bottom-nav a:active { background: #e8e8e8; }
.bottom-nav .nav-icon { font-size: 1.4rem; margin-bottom: 2px; }

/* Main content */
.main { padding: 16px; max-width: 900px; margin: 0 auto; }

/* Cards */
.card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary);
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--tap-min);
    min-width: var(--tap-min);
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    background: var(--surface);
    color: var(--text);
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:active { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 2px solid var(--border-light);
}

th {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

th:hover { background: var(--primary-light); }

tr:hover { background: #f0f0f0; }

td a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

td a:hover { text-decoration: underline; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid;
}

.badge-to-review { background: #fff3cd; color: #856404; border-color: #856404; }
.badge-shortlist { background: #d4edda; color: #155724; border-color: #155724; }
.badge-toured { background: #cce5ff; color: #004085; border-color: #004085; }
.badge-offer { background: #f8d7da; color: #721c24; border-color: #721c24; }
.badge-rejected { background: #e2e3e5; color: #383d41; border-color: #383d41; }

.badge-open { background: #fff3cd; color: #856404; border-color: #856404; }
.badge-done { background: #d4edda; color: #155724; border-color: #155724; }

.badge-high { background: #f8d7da; color: #721c24; border-color: #721c24; }
.badge-medium { background: #fff3cd; color: #856404; border-color: #856404; }
.badge-low { background: #e2e3e5; color: #383d41; border-color: #383d41; }

.badge-active { background: #d4edda; color: #155724; border-color: #155724; }
.badge-closed { background: #e2e3e5; color: #383d41; border-color: #383d41; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    min-height: var(--tap-min);
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.3);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23333'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* Checklist */
.checklist-grid {
    display: grid;
    gap: 8px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: var(--tap-min);
}

.checklist-item label {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.checklist-btns {
    display: flex;
    gap: 4px;
}

.checklist-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    transition: all 0.15s;
}

.checklist-btn.yes.active { background: var(--success); color: #fff; border-color: var(--success); }
.checklist-btn.no.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.checklist-btn:active { transform: scale(0.95); }

.checklist-notes {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: none;
}

/* Scoring */
.scoring-grid {
    display: grid;
    gap: 12px;
}

.scoring-item {
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
}

.scoring-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.scoring-name { font-weight: 700; }
.scoring-weight { font-size: 0.8rem; color: var(--text-muted); }

.scoring-stars {
    display: flex;
    gap: 4px;
}

.star-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--surface);
    color: var(--text-muted);
    transition: all 0.15s;
}

.star-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.star-btn:active { transform: scale(0.95); }

.score-total {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    padding: 16px;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    margin-top: 12px;
}

/* Tabs */
.tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 3px solid var(--border);
    margin-bottom: 16px;
    gap: 0;
}

.tab-btn {
    flex-shrink: 0;
    padding: 12px 16px;
    min-height: var(--tap-min);
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:active { background: #f0f0f0; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-upload-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--border-light);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    gap: 4px;
    min-height: 120px;
}

.photo-upload-btn .icon { font-size: 2rem; }
.photo-upload-btn:active { background: #f0f0f0; }

/* Photo lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 95%;
    max-height: 90%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: var(--tap-min);
    height: var(--tap-min);
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
}

/* Amenity checklist */
.amenity-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.amenity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    min-height: var(--tap-min);
    cursor: pointer;
}

.amenity-item.checked {
    background: #d4edda;
    border-color: var(--success);
}

.amenity-checkbox {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.amenity-item.checked .amenity-checkbox {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.amenity-label { font-weight: 600; font-size: 0.9rem; }

/* Activity timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--border-light);
}

.timeline-item {
    position: relative;
    padding: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 16px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-type {
    font-weight: 700;
    color: var(--primary);
}

.timeline-note { margin-top: 4px; }

/* Item list (furniture, appliances) */
.item-list {
    display: grid;
    gap: 12px;
}

.item-card {
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.item-name { font-weight: 700; }

.item-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.85rem;
}

.item-field label {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Save flash */
.save-flash {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.save-flash.show { opacity: 1; }

/* Toast */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}

.toast.show { opacity: 1; pointer-events: auto; }

/* Pipeline table */
.pipeline-card {
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Summary fields */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-field {
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.detail-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.detail-value:empty::after {
    content: '—';
    color: var(--border-light);
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
    min-height: 40px;
    padding: 6px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 1rem; margin-bottom: 16px; }

/* Sortable header */
th[data-sort]::after {
    content: ' \2195';
    opacity: 0.5;
}

th[data-sort].asc::after { content: ' \2191'; opacity: 1; }
th[data-sort].desc::after { content: ' \2193'; opacity: 1; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px solid var(--border);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .amenity-grid { grid-template-columns: 1fr; }
}

/* Inline editable */
.editable {
    cursor: pointer;
    border-bottom: 1px dashed var(--border-light);
    padding: 2px 4px;
    border-radius: 2px;
}

.editable:hover { background: #f0f0f0; }

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Utility */
.hidden { display: none !important; }

/* Auth screen */
#auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    padding: 16px;
}

.auth-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.auth-title {
    text-align: center;
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    border-bottom: 3px solid var(--border);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    min-height: var(--tap-min);
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-error {
    color: var(--danger);
    font-weight: 600;
    text-align: center;
    margin-top: 12px;
    min-height: 1.5em;
}
