/* =========================================================================
   BuildPro — single stylesheet (no external CSS so the app works offline)
   ========================================================================= */
:root {
    --ink: #1f2a37;
    --ink-2: #4b5563;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f5f6f8;
    --card: #ffffff;
    --brand: #e8a317;       /* safety amber */
    --brand-dark: #b97f0c;
    --slate: #1f2a37;
    --slate-2: #2c3a4b;
    --green: #15803d;  --green-bg: #dcfce7;
    --amber: #a16207;  --amber-bg: #fef3c7;
    --blue: #1d4ed8;   --blue-bg: #dbeafe;
    --red: #b91c1c;    --red-bg: #fee2e2;
    --grey: #4b5563;   --grey-bg: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; font-size: 15px; }
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-right { text-align: right; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 8px;
       border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important;
       background: var(--grey-bg); color: var(--ink); line-height: 1.2; }
.btn-primary { background: var(--brand); color: #1a1205; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-dark { background: var(--slate); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line); color: inherit; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 0; font: inherit; cursor: pointer; }
.btn-link.danger { color: var(--red); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=date],
input[type=search], input[type=file], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.help { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.inline-form { display: inline; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; border: 1px solid transparent; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.alert-error, .alert-danger { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: #bfdbfe; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue  { background: var(--blue-bg);  color: var(--blue); }
.badge-red   { background: var(--red-bg);   color: var(--red); }
.badge-grey  { background: var(--grey-bg);  color: var(--grey); }

/* ---------- Cards / tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions > * + * { margin-left: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; font-weight: 600; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .num { font-size: clamp(1.15rem, 2.2vw, 1.6rem); font-weight: 800; overflow-wrap: anywhere; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.accent { border-left: 4px solid var(--brand); }

.amt-pos { color: var(--green); font-weight: 700; white-space: nowrap; }
.amt-neg { color: var(--red); font-weight: 700; white-space: nowrap; }
td.cr, td.dr { white-space: nowrap; }
.grid > .card + .card { margin-top: 0; }
.balance-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 16px; }
.balance-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.balance-card h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.balance-card .row-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.balance-card .row-line:last-of-type { border-bottom: 0; }
.balance-card .total { font-size: 1.15rem; padding-top: 8px; border-top: 2px solid var(--ink); margin-top: 4px; }
.balance-card .note { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
tr.row-pending td { background: #fffbeb; }
tr.row-rejected td { color: var(--muted); text-decoration: line-through; }
tr.row-rejected td.actions, tr.row-rejected td:nth-last-child(2) { text-decoration: none; }
td.cr { color: var(--green); }
td.dr { color: var(--red); }
tfoot td { font-weight: 800; border-top: 2px solid var(--ink); }
.cat-bar { display: grid; grid-template-columns: 140px 1fr 120px; gap: 10px; align-items: center; padding: 4px 0; font-size: .88rem; }
.cat-bar .progress { height: 8px; }
.progress {height: 10px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #f5c451); }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination a.active { background: var(--slate); color: #fff; border-color: var(--slate); }

.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: 16px; }

/* ---------- Public site ---------- */
.site-header { background: var(--slate); color: #fff; position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 1.15rem; text-decoration: none !important; }
.brand img { border-radius: 8px; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a { color: #e5e7eb; font-weight: 500; }
.site-nav a.active, .site-nav a:hover { color: var(--brand); text-decoration: none; }
.site-nav .btn-primary { color: #1a1205; }
.site-nav .btn-outline { color: #fff; border-color: #4b5563; }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: currentColor; margin: 5px 0; }
.site-header .nav-toggle { color: #fff; }

.site-main { min-height: 60vh; padding-bottom: 40px; }
.hero { background: linear-gradient(135deg, rgba(31,42,55,.94), rgba(44,58,75,.86)), repeating-linear-gradient(45deg, #2c3a4b 0 12px, #26323f 12px 24px); color: #fff; padding: 64px 0 72px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); max-width: 720px; }
.hero p { color: #d1d5db; max-width: 620px; font-size: 1.05rem; }
.hero-search { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 14px; margin-top: 26px; display: grid; gap: 10px;
               grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; max-width: 900px; }
.section { padding: 48px 0 8px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.5rem; }

.services { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.service { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; border-top: 4px solid var(--brand); }
.service h3 { margin-bottom: 6px; }

.prop-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; color: inherit; }
.prop-card:hover { text-decoration: none; transform: translateY(-2px); transition: transform .15s; }
.prop-card .thumb { aspect-ratio: 16/10; background: #e5e7eb center/cover no-repeat; position: relative; }
.prop-card .thumb .badge { position: absolute; top: 10px; left: 10px; }
.prop-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.prop-card .price { font-weight: 800; font-size: 1.1rem; color: var(--slate); }
.prop-card .title { font-weight: 700; color: var(--ink); }
.prop-card .meta { color: var(--muted); font-size: .85rem; display: flex; gap: 12px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

.gallery { display: grid; gap: 8px; grid-template-columns: 2fr 1fr; }
.gallery .main { aspect-ratio: 16/10; border-radius: var(--radius); background: #e5e7eb center/cover no-repeat; }
.gallery .thumbs { display: grid; gap: 8px; grid-auto-rows: 1fr; }
.gallery .thumbs button { border: 0; padding: 0; border-radius: 8px; background: #e5e7eb center/cover no-repeat; cursor: pointer; min-height: 60px; }
.detail-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); margin-top: 24px; }
.features { columns: 2; padding-left: 18px; }

.site-footer { background: var(--slate); color: #cbd5e1; padding: 36px 0 18px; }
.site-footer a { color: #e5e7eb; }
.site-footer strong { color: #fff; display: block; margin-bottom: 6px; }
.footer-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.copyright { border-top: 1px solid #374151; margin-top: 18px; padding-top: 14px; font-size: .85rem; }

.auth-wrap { max-width: 440px; margin: 40px auto; }
.offline-banner { background: var(--amber-bg); color: var(--amber); text-align: center; padding: 8px; font-weight: 600; font-size: .9rem; }

/* ---------- Dashboard panel ---------- */
body.panel { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--slate); color: #cbd5e1; display: flex; flex-direction: column; padding: 16px 12px;
           position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; overflow-y: auto; }
.sidebar .brand { padding: 4px 8px 12px; }
.role-chip { margin: 0 8px 14px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #cbd5e1; font-weight: 500; }
.sidebar nav a:hover { background: var(--slate-2); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #1a1205; }
.logout-form { margin-top: 16px; }
.logout-form .btn { color: #e5e7eb; border-color: #4b5563; }
.panel-body { flex: 1; margin-left: 240px; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; min-height: 60px; position: sticky; top: 0; z-index: 40; }
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; color: var(--ink-2); font-size: .9rem; }
.panel-main { padding: 20px; max-width: 1280px; }
.sidebar-backdrop { display: none; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 18px; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline img { max-width: 260px; border-radius: 8px; margin-top: 8px; }
.img-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.img-grid figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.img-grid img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.img-grid figcaption { padding: 6px 8px; font-size: .8rem; display: flex; justify-content: space-between; gap: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--slate); flex-direction: column;
                align-items: stretch; padding: 12px 16px 18px; gap: 4px; border-top: 1px solid #374151; }
    .site-nav.open { display: flex; }
    .site-nav a { padding: 10px 4px; }
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
    .panel-body { margin-left: 0; }
    .topbar { padding: 0 12px; }
    .topbar .nav-toggle { color: var(--ink); }
    .panel-main { padding: 14px; }
    .user-name { display: none; }
    .features { columns: 1; }
}
@media (max-width: 560px) {
    .gallery { grid-template-columns: 1fr; }
    .gallery .thumbs { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 60px; }
}

/* Installed app (standalone) — respect notches */
@media (display-mode: standalone) {
    .site-header, .topbar { padding-top: env(safe-area-inset-top); }
}

@media print {
    .sidebar, .topbar, .site-header, .site-footer, .btn, .no-print, .tabs { display: none !important; }
    .print-only { display: block !important; }
    .amt-pos, .amt-neg, td.cr, td.dr { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .panel-body { margin: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; }
}
