/* ═══════════════════════════════════════════════════════════
   35224 Williams Gap Road — Balcony Replacement Project
   Design system adapted from the MB dark-dashboard aesthetic
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-primary:    #0b0f14;
    --bg-secondary:  #0f1720;
    --bg-tertiary:   #151e2b;
    --bg-card:       #111a27;
    --bg-elevated:   #1a2535;
    --bg-hover:      #1e293b;

    --accent:        #4cc9f0;
    --accent-dim:    rgba(76, 201, 240, 0.15);
    --accent-glow:   rgba(76, 201, 240, 0.35);
    --secondary:     #7c3aed;

    --success:  #10b981;
    --success-dim: rgba(16,185,129,0.15);
    --warning:  #f59e0b;
    --warning-dim: rgba(245,158,11,0.15);
    --danger:   #ef4444;
    --danger-dim: rgba(239,68,68,0.15);
    --info:     #3b82f6;

    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    --border:        #1e293b;
    --border-subtle: #2a3556;

    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;

    --nav-height: 56px;
    /* .main-content's own top/horizontal padding, exposed as variables so
       pages that need an edge-to-edge "full bleed" section (e.g. the login
       screen) can cancel it out with a matching negative margin instead of
       a hardcoded value that breaks once the padding changes on mobile. */
    --content-pad-y: 32px;
    --content-pad-x: 24px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100%;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    /* Tells the browser to render native controls (select dropdown popups,
       scrollbars, etc.) using dark-theme-aware colors instead of defaulting
       to a plain white popup with low-contrast text. */
    color-scheme: dark;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══ TOP NAVBAR ═══ */
.top-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}
.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    font-weight: 700;
    font-size: 15px;
    padding: 0 10px 0 0;
    white-space: nowrap;
    transition: opacity .15s ease;
}
.brand:hover { opacity: .85; }
.brand i { font-size: 18px; }
.brand-sub { color: var(--text-muted); font-weight: 400; font-size: 12px; display: block; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .12s ease;
    white-space: nowrap;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; transform: translateY(-1px); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

.nav-dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 1100;
}
.nav-dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }

.role-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--accent);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 2px 10px;
    border-radius: 20px;
}
.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background .15s ease, color .15s ease, transform .12s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--accent); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }

/* ═══ LAYOUT ═══ */
.app-body { margin-top: var(--nav-height); min-height: calc(100vh - var(--nav-height)); display: flex; }
.main-content { flex: 1; min-width: 0; max-width: 1200px; margin: 0 auto; padding: var(--content-pad-y) var(--content-pad-x) 64px; }

/* ═══ Sidebar ═══ */
.sidebar {
    width: 220px; min-width: 220px; flex-shrink: 0;
    background: var(--bg-secondary); border-right: 1px solid var(--border);
    padding: 20px 0; position: sticky; top: var(--nav-height);
    height: calc(100vh - var(--nav-height)); overflow-y: auto;
}
.sidebar-header {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); padding: 0 20px 10px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    border-right: 2px solid transparent; transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-link.active { color: var(--accent); background: var(--accent-dim); border-right-color: var(--accent); }
.sidebar-link i { width: 16px; text-align: center; font-size: 12px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.page-header .subtitle { font-size: 13px; color: var(--text-muted); }
.page-header .subtitle i { margin-right: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px; font-size: 13px; font-weight: 600; letter-spacing: .01em;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease, border-color .15s ease;
    font-family: inherit; position: relative;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.btn-primary {
    background: linear-gradient(180deg, #6fd9f7, #2ea9d6 60%, #1c87b0);
    color: #04121a; border: 1px solid #1a7fa8;
    box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 -2px 6px rgba(0,0,0,.25) inset, 0 6px 14px rgba(76,201,240,.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 -2px 6px rgba(0,0,0,.25) inset, 0 10px 22px rgba(76,201,240,.45);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 -1px 3px rgba(0,0,0,.3) inset, 0 3px 8px rgba(76,201,240,.3);
}
.btn-ghost {
    background: linear-gradient(180deg, var(--bg-hover), var(--bg-elevated));
    color: var(--text-primary); border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.04);
}
.btn-ghost:hover {
    background: linear-gradient(180deg, #26344a, var(--bg-hover)); color: #fff; border-color: var(--accent);
    transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.4), 0 0 0 1px var(--accent-dim);
}
.btn-ghost:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger {
    background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,.35);
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.btn-danger:hover { background: rgba(239,68,68,.25); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(239,68,68,.2); }
.btn-success {
    background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,.35);
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.btn-success:hover { background: rgba(16,185,129,.25); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(16,185,129,.2); }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ═══ Cards ═══ */
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 22px; box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.card + .card { margin-top: 20px; }
.card h2 {
    font-size: 16px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 9px;
    letter-spacing: .005em; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.card h2 i { color: var(--accent); font-size: 14px; }

/* Balcony cards grid */
.balcony-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-bottom: 28px; }
.balcony-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.balcony-card:hover { transform: translateY(-4px); border-color: var(--border-subtle); box-shadow: var(--shadow-md); }
.balcony-card-thumb { height: 150px; background: var(--bg-tertiary) center/cover no-repeat; position: relative; }
.balcony-card-thumb .no-photo { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 12px; flex-direction: column; gap: 6px; }
.balcony-card-thumb .no-photo i { font-size: 22px; }
.balcony-card-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.balcony-card-body h3 { font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.balcony-card-meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; }
.balcony-card-total { font-size: 20px; font-weight: 800; font-family: var(--mono); color: var(--text-primary); }
.balcony-card-progress { height: 6px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.balcony-card-progress > div { height: 100%; background: var(--accent); }
.balcony-card-footer { margin-top: auto; }

/* Dashboard stat row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px 18px; display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-subtle); }
.stat-card i { font-size: 22px; color: var(--accent); }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }

/* ═══ Badges / status ═══ */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 12px;
    font-size: 11px; font-weight: 700; white-space: nowrap; text-transform: capitalize;
    border: 1px solid rgba(255,255,255,.06);
}
.badge-not_started { background: rgba(100,116,139,.18); color: var(--text-muted); border: 1px solid rgba(100,116,139,.3); }
.badge-in_progress { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,.35); }
.badge-complete { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,.35); }
.badge-proposed { background: var(--info); color: #fff; opacity: .9; border: 1px solid rgba(255,255,255,.15); }
.badge-approved { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,.35); }
.badge-rejected { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,.35); }
.badge-admin { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(76,201,240,.35); }
.badge-contractor { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,.35); }
.badge-viewer { background: rgba(100,116,139,.18); color: var(--text-muted); border: 1px solid rgba(100,116,139,.3); }

/* status select used as a styled dropdown badge */
select.status-select {
    font-size: 11px; font-weight: 700; border-radius: 12px; padding: 5px 12px;
    border: 1px solid var(--border-subtle); background: linear-gradient(180deg, var(--bg-hover), var(--bg-tertiary));
    color: var(--text-primary); cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.3);
    transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
select.status-select:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.35); transform: translateY(-1px); }
select.status-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ═══ Tabs ═══ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
    padding: 11px 16px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
    background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-dim); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ Tables ═══ */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr { transition: background .12s ease; }
table.data-table tbody tr:hover { background: var(--bg-hover); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-subtle); border-bottom: none; }
table.data-table input, table.data-table select {
    width: 100%; background: transparent; border: 1px solid transparent; color: var(--text-primary);
    font-family: inherit; font-size: 13px; padding: 4px 6px; border-radius: 4px;
}
table.data-table input:hover, table.data-table select:hover { border-color: var(--border); }
table.data-table input:focus, table.data-table select:focus { border-color: var(--accent); outline: none; background: var(--bg-tertiary); }
table.data-table input.num { text-align: right; font-family: var(--mono); }
table.data-table td.cell-num { text-align: right; font-family: var(--mono); }
.line-total { font-family: var(--mono); font-weight: 700; text-align: right; display: block; }
.saved-flash { color: var(--success); font-size: 11px; opacity: 0; transition: opacity .3s; }
.saved-flash.show { opacity: 1; }
.row-actions { display: flex; gap: 2px; white-space: nowrap; }

/* ═══ Price verification ═══ */
.verify-wrap { display: flex; align-items: center; gap: 6px; white-space: nowrap; flex-wrap: wrap; }
.badge-verified { background: var(--success-dim); color: var(--success); }
.badge-unverified { background: rgba(100,116,139,.18); color: var(--text-muted); }
.verify-btn {
    background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: var(--radius-sm); padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}
.verify-btn:hover { background: var(--bg-hover); color: var(--text-primary); transform: translateY(-1px); }
.verify-btn:active { transform: translateY(0); }
.verify-btn.is-verified { border-color: rgba(16,185,129,.4); color: var(--success); }
.source-text {
    display: block; font-size: 11px; color: var(--text-muted); margin-top: 3px;
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ═══ Modal ═══ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(2px); z-index: 9000;
    display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; animation: fadeIn .15s ease; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
    width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.02);
}
.modal-header {
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--accent); }
.modal-close {
    background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm); transition: background .15s ease, color .15s ease;
}
.modal-close:hover { color: var(--danger); background: var(--danger-dim); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══ Forms ═══ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 12px; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; font-family: inherit; outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: var(--border-subtle); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent); background: var(--bg-tertiary); box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group textarea { resize: vertical; min-height: 70px; }

/* File inputs — restyle the native "Choose File" button to match the app's design */
.form-group input[type="file"] {
    padding: 7px 10px; cursor: pointer; font-size: 13px; color: var(--text-secondary);
}
.form-group input[type="file"]::file-selector-button,
.form-group input[type="file"]::-webkit-file-upload-button {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px; margin-right: 12px;
    font-family: inherit; font-size: 12px; font-weight: 700; letter-spacing: .01em;
    color: var(--text-primary); cursor: pointer;
    background: linear-gradient(180deg, var(--bg-hover), var(--bg-elevated));
    border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.04);
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.form-group input[type="file"]:hover::file-selector-button,
.form-group input[type="file"]:hover::-webkit-file-upload-button {
    background: linear-gradient(180deg, #26344a, var(--bg-hover)); color: #fff; border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,.4), 0 0 0 1px var(--accent-dim);
}
.form-group input[type="file"]:active::file-selector-button,
.form-group input[type="file"]:active::-webkit-file-upload-button { transform: translateY(1px); }

/* ═══ Checklist ═══ */
.checklist { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); border-radius: var(--radius-sm); transition: background .12s ease; }
.checklist li:hover { background: var(--bg-hover); }
.checklist li:last-child { border-bottom: none; }
.checklist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.checklist .task-text { flex: 1; font-size: 13px; }
.checklist li.done .task-text { color: var(--text-muted); text-decoration: line-through; }
.checklist .done-meta { font-size: 11px; color: var(--text-muted); }
.checklist-edit-input {
    flex: 1; font-size: 13px; font-family: var(--sans); color: var(--text-primary);
    background: var(--bg-tertiary); border: 1px solid var(--accent); border-radius: var(--radius-sm);
    padding: 4px 8px;
}

/* ═══ Comments ═══ */
.comment { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; }
.comment-author { font-weight: 700; }
.comment-time { color: var(--text-muted); }
.comment-body { font-size: 13px; color: var(--text-secondary); white-space: pre-wrap; }

/* ═══ Photo gallery ═══ */
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo-gallery a { display: block; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); aspect-ratio: 4/3; }
.photo-gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.photo-gallery a:hover img { transform: scale(1.04); }
.lightbox-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9000;
    display: none; align-items: center; justify-content: center; padding: 40px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); }
.lightbox-close { position: absolute; top: 20px; right: 28px; color: #fff; font-size: 28px; cursor: pointer; background: none; border: none; }

/* ═══ Schedule: status colors (shared by calendar chips + Gantt bars) ═══ */
.status-swatch, .cal-event-chip, .gantt-bar-actual { }
/* Timeliness palette: gray (not due) -> blue (on track) -> amber (at risk) ->
   gold (finished early, bonus-eligible) -> green (on time) -> orange (late,
   penalty applied) -> deep red (never started, past due). */
.status-planned            { background: rgba(100,116,139,.18); color: var(--text-secondary); border-color: rgba(100,116,139,.4); }
.status-in_progress_on_track { background: rgba(59,130,246,.18); color: var(--info); border-color: rgba(59,130,246,.5); }
.status-in_progress_at_risk  { background: var(--warning-dim); color: var(--warning); border-color: rgba(245,158,11,.5); }
.status-done_early         { background: rgba(251,191,36,.18); color: #fbbf24; border-color: rgba(251,191,36,.5); }
.status-done_on_time       { background: var(--success-dim); color: var(--success); border-color: rgba(16,185,129,.5); }
.status-done_late          { background: rgba(249,115,22,.18); color: #f97316; border-color: rgba(249,115,22,.5); }
.status-overdue            { background: rgba(185,28,28,.22); color: #f87171; border-color: rgba(185,28,28,.6); }

.sched-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; font-size: 12px; color: var(--text-secondary); align-items: center; }
.sched-legend .swatch { display: inline-flex; align-items: center; gap: 6px; }
.sched-legend .swatch-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ═══ Calendar ═══ */
.cal-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cal-nav-btn {
    background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
    width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { background: var(--bg-hover); }
.cal-month-label { font-size: 1.1rem; min-width: 180px; text-align: center; }
.cal-today-btn {
    margin-left: auto; background: var(--accent-dim); border: 1px solid var(--border);
    color: var(--accent); padding: 6px 16px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
}
.cal-today-btn:hover { background: var(--bg-hover); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 2px; }
.cal-weekdays > div { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 8px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-day {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    min-height: 92px; padding: 6px; position: relative; cursor: pointer;
    min-width: 0; overflow: hidden; box-sizing: border-box;
}
.cal-day:hover { background: var(--bg-hover); }
.cal-day-empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day-empty:hover { background: transparent; }
.cal-day-num { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.cal-day-today { border-color: var(--accent); }
.cal-day-today .cal-day-num { color: var(--accent); }
.cal-day-events { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-event-chip {
    font-size: 10px; line-height: 1.3; padding: 2px 5px; border-left: 2px solid; border-radius: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; cursor: pointer; display: block;
}
.cal-event-chip:hover { filter: brightness(1.25); text-decoration: none; }
.cal-event-more { font-size: 10px; color: var(--accent); font-weight: 700; padding: 1px 5px; }
.cal-day-detail { margin-top: 16px; }
.cal-day-detail .task-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cal-day-detail .task-row:last-child { border-bottom: none; }

/* ═══ Gantt ═══ */
.gantt-scroll { overflow-x: auto; }
.gantt-chart { min-width: 760px; position: relative; }
.gantt-header { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.gantt-label-col { width: 260px; min-width: 260px; flex-shrink: 0; }
.gantt-timeline-col { flex: 1; position: relative; display: flex; }
.gantt-month-tick { border-left: 1px solid var(--border); font-size: 10px; color: var(--text-muted); padding: 4px 0 4px 4px; text-transform: uppercase; letter-spacing: .04em; }
.gantt-group-title { font-size: 12px; font-weight: 700; color: var(--text-secondary); padding: 10px 0 4px; display: flex; align-items: center; gap: 8px; }
.gantt-row { display: flex; align-items: center; min-height: 34px; border-bottom: 1px solid var(--border); }
.gantt-row-label { width: 260px; min-width: 260px; flex-shrink: 0; font-size: 12px; padding-right: 10px; }
.gantt-track { flex: 1; position: relative; height: 22px; background: var(--bg-tertiary); border-radius: 4px; }
.gantt-bar-planned {
    position: absolute; top: 0; height: 100%; border-radius: 4px; border: 1px dashed var(--border-subtle);
    background: rgba(100,116,139,.12); box-sizing: border-box; cursor: grab;
}
.gantt-bar-actual {
    position: absolute; top: 3px; height: calc(100% - 6px); border-radius: 3px; box-sizing: border-box;
    display: flex; align-items: center; padding: 0 6px; font-size: 10px; font-weight: 700; color: #04121a; white-space: nowrap; overflow: hidden;
    cursor: grab;
}
.gantt-bar-planned.dragging, .gantt-bar-actual.dragging {
    cursor: grabbing; opacity: .8; z-index: 6; box-shadow: 0 0 0 2px var(--accent);
}
.gantt-resize-handle {
    position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2;
}
.gantt-resize-handle.left { left: -3px; }
.gantt-resize-handle.right { right: -3px; }
.gantt-bar-actual.status-in_progress_on_track { background: var(--info); color: #fff; }
.gantt-bar-actual.status-in_progress_at_risk { background: var(--warning); }
.gantt-bar-actual.status-done_early { background: #fbbf24; }
.gantt-bar-actual.status-done_on_time { background: var(--success); }
.gantt-bar-actual.status-done_late { background: #f97316; }
.gantt-bar-actual.status-overdue { background: #b91c1c; color: #fff; }
.gantt-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 5; }
.gantt-today-label { position: absolute; top: -18px; font-size: 10px; color: var(--accent); font-weight: 700; white-space: nowrap; transform: translateX(-50%); }

/* Inline Gantt row date editor */
.gantt-edit-toggle { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 11px; margin-left: 6px; }
.gantt-edit-toggle:hover { color: var(--accent); }
.gantt-edit-panel { display: none; flex-wrap: wrap; gap: 10px; padding: 8px 0 12px 0; border-bottom: 1px solid var(--border); }
.gantt-edit-panel.show { display: flex; }
.gantt-edit-panel label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: flex; flex-direction: column; gap: 3px; }
.gantt-edit-panel input[type=date] { background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-primary); border-radius: 4px; padding: 4px 6px; font-size: 12px; }

/* ═══ Process Map (flowchart) ═══ */
.process-map { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.flow-terminal {
    background: linear-gradient(180deg, var(--bg-hover), var(--bg-elevated)); border: 1px solid var(--border-subtle);
    border-radius: 999px; padding: 11px 30px; font-weight: 700; font-size: 13px; color: var(--text-primary);
    box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 8px;
}
.flow-terminal.start i { color: var(--accent); }
.flow-terminal.end { border-color: rgba(16,185,129,.4); color: var(--success); background: var(--success-dim); }
.flow-terminal.end i { color: var(--success); }

.flow-stage {
    width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px 20px; box-shadow: var(--shadow-sm); position: relative;
}
.flow-stage-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.flow-stage-num {
    width: 26px; height: 26px; min-width: 26px; border-radius: 50%; background: var(--accent-dim); color: var(--accent);
    font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.flow-stage-header h3 { font-size: 14px; font-weight: 700; }
.flow-stage ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.flow-stage li { font-size: 12.5px; color: var(--text-secondary); display: flex; gap: 8px; align-items: flex-start; line-height: 1.4; }
.flow-stage li i { color: var(--accent); margin-top: 3px; font-size: 10px; flex-shrink: 0; }

.flow-connector { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); padding: 4px 0; }
.flow-connector .flow-line { width: 2px; height: 16px; background: var(--border-subtle); }
.flow-connector i { font-size: 13px; }
.flow-connector .flow-yes-tag {
    font-size: 10px; font-weight: 800; color: var(--success); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 1px;
}

.flow-decision-row { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.flow-decision-shape {
    width: 180px; height: 108px; flex-shrink: 0; background: var(--warning-dim); border: 2px solid var(--warning);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); display: flex; align-items: center; justify-content: center;
}
.flow-decision-shape span { font-size: 12px; font-weight: 700; color: var(--warning); text-align: center; padding: 0 32px; line-height: 1.3; }
.flow-branch-no { display: flex; align-items: center; flex: 1; min-width: 220px; }
.flow-branch-line {
    width: 26px; height: 0; border-top: 2px dashed var(--border-subtle); flex-shrink: 0; margin-right: 10px;
}
.flow-branch-card {
    background: var(--danger-dim); border: 1px dashed rgba(239,68,68,.4); border-radius: var(--radius-sm);
    padding: 10px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: var(--text-secondary); flex: 1;
}
.flow-branch-card i { color: var(--danger); margin-top: 2px; }
.flow-branch-card strong { color: var(--danger); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }

/* ═══ Misc ═══ */
.dim-table { width: 100%; font-size: 13px; }
.dim-table td { padding: 5px 0; }
.dim-table td:first-child { color: var(--text-muted); width: 45%; }
.empty-state { text-align: center; padding: 30px 20px; color: var(--text-muted); }
.empty-state i { font-size: 1.8rem; margin-bottom: 10px; display: block; }
.flash { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.flash-error { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.flash-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,.3); }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.grand-total { font-size: 24px; font-weight: 800; font-family: var(--mono); }
.help-note { font-size: 12px; color: var(--text-muted); background: var(--bg-tertiary); border: 1px dashed var(--border-subtle); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.activity-list { list-style: none; display: flex; flex-direction: column; gap: 0; }
.activity-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); display: flex; gap: 8px; }
.activity-list li:last-child { border-bottom: none; }
.activity-list .activity-time { color: var(--text-muted); white-space: nowrap; }

.login-wrap { min-height: calc(100vh - var(--nav-height)); display: flex; align-items: center; justify-content: center; background: var(--bg-primary); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; }
.login-card .brand { justify-content: center; font-size: 20px; margin-bottom: 4px; }
.login-card .brand-sub { text-align: center; margin-bottom: 24px; }

/* Responsive */
@media (max-width: 720px) {
    /* .main-content normally uses "margin: 0 auto" to center itself with a
       max-width on wide screens. In the mobile column layout below, those
       auto margins stop the element from stretching to fill its flex
       parent, so it instead shrink-wraps around its widest descendant
       (e.g. a grid trying to fit multiple 260px columns) and blows the
       whole page out sideways. Pinning width/margin here restores normal
       full-width block behavior so nothing can force the page to scroll
       horizontally. */
    .main-content { width: 100%; max-width: 100%; margin: 0; padding: 18px 14px 48px; }
    :root { --content-pad-y: 18px; --content-pad-x: 14px; }
    /* The nav can wrap to 2-3 rows on narrow screens, so its height is no
       longer fixed/predictable — switch it from fixed-to-viewport to a
       normal in-flow block instead of trying to guess a margin-top offset. */
    .top-nav { position: static; height: auto; padding: 10px 14px; flex-wrap: wrap; row-gap: 8px; box-shadow: none; }
    .nav-left { min-width: 0; }
    .brand span { min-width: 0; }
    .brand-sub { white-space: normal; }
    .nav-center {
        order: 3; width: 100%; justify-content: flex-start;
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        gap: 2px; padding-top: 6px; border-top: 1px solid var(--border);
    }
    .nav-center .nav-link { padding: 8px 10px; }
    .nav-right { flex-wrap: wrap; row-gap: 6px; justify-content: flex-end; }
    .app-body { margin-top: 0; flex-direction: column; }
    .sidebar {
        width: 100%; min-width: 0; height: auto; position: static;
        display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
        padding: 10px 0; border-right: none; border-bottom: 1px solid var(--border);
    }
    .sidebar-header { display: none; }
    .sidebar-link { white-space: nowrap; border-right: none; border-bottom: 2px solid transparent; }
    .sidebar-link.active { border-right-color: transparent; border-bottom-color: var(--accent); }

    .page-header h1 { font-size: 21px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; justify-content: center; }

    .gantt-label-col, .gantt-row-label { width: 140px; min-width: 140px; }
    .cal-day { min-height: 58px; padding: 4px; }
    .cal-day-num { font-size: 10px; }
    .cal-event-chip { font-size: 9px; padding: 1px 3px; }
    .cal-month-label { min-width: 0; font-size: 1rem; }

    .tour-card { width: calc(100vw - 20px); left: 10px; right: 10px; bottom: 10px; transform: none; padding: 14px 16px; }
    .tour-card-actions { flex-wrap: wrap; }
    .tour-audio-controls { flex-wrap: wrap; }
    .tour-audio-controls select { max-width: 130px; }
}

@media (max-width: 480px) {
    .stats-row, .balcony-grid { grid-template-columns: 1fr; }
    .form-row .form-group { min-width: 0; flex: 1 1 100%; }
    .modal-body .form-row .form-group { flex: 1 1 100%; }
}

/* Print (used when printing a balcony page directly from the browser) */
@media print {
    .top-nav, .sidebar, .page-actions, .no-print { display: none !important; }
    .app-body { margin-top: 0; }
    body { background: #fff; color: #000; }
    .card { border: 1px solid #ccc; background: #fff; }
}

/* ═══ Guided product tour (site-wide, drives real navigation) ═══ */
.tour-card {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
    width: min(640px, calc(100vw - 32px)); z-index: 500;
    background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 18px 22px; animation: tourSlideUp .25s ease;
}
@keyframes tourSlideUp { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.tour-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tour-progress { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.tour-audio-controls { display: flex; align-items: center; gap: 6px; }
.tour-audio-controls select { font-size: 12px; padding: 4px 8px; max-width: 170px; }
.tour-card h3 { font-size: 15px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.tour-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 14px; }
.tour-card-actions { display: flex; justify-content: flex-end; gap: 10px; }

.tour-highlight {
    outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm);
    box-shadow: 0 0 24px var(--accent-glow); transition: outline-color .2s ease;
    scroll-margin: 140px;
}

.tour-pointer {
    position: fixed; z-index: 501; width: 0; height: 0; pointer-events: none;
    transition: left .5s ease, top .5s ease;
}
.tour-pointer i {
    position: absolute; left: -3px; top: -3px; font-size: 26px; color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow)) drop-shadow(1px 2px 1px rgba(0,0,0,.5));
}
.tour-pointer-ripple {
    position: absolute; left: -11px; top: -11px; width: 22px; height: 22px;
    border: 2px solid var(--accent); border-radius: 50%;
    animation: tourPointerRipple 1.6s ease-out infinite;
}
@keyframes tourPointerRipple {
    0% { transform: scale(.4); opacity: .9; }
    100% { transform: scale(2.4); opacity: 0; }
}
