/* EstateOS - application styles (Bootstrap 5 based, light + dark) */
:root {
  --brand: #2563eb;
  --brand-2: #0f172a;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 60px;
  --radius: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="light"] {
  --app-bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-hover: rgba(255,255,255,.06);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
}
[data-bs-theme="dark"] {
  --app-bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --sidebar-bg: #070b16;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-hover: rgba(255,255,255,.05);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  --bs-body-bg: #0b1120;
}
html, body { height: 100%; }
body.app-body { background: var(--app-bg); color: var(--text); font-family: var(--font); font-size: .9rem; }
a { color: var(--brand); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 85%, #000); --bs-btn-active-bg: color-mix(in srgb, var(--brand) 75%, #000); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.form-control:focus, .form-select:focus { border-color: color-mix(in srgb, var(--brand) 60%, #fff); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 18%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040; transition: width .2s ease, transform .2s ease; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.05rem; flex-shrink: 0; }
.brand-logo { height: 34px; width: 34px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.brand-name { color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-link-item { display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-size: .86rem; white-space: nowrap; }
.nav-link-item i { font-size: 1.02rem; width: 20px; text-align: center; opacity: .85; }
.nav-link-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link-item.active { background: color-mix(in srgb, var(--brand) 85%, transparent); color: #fff; }
.nav-link-item.top { margin-bottom: 6px; }
.nav-group { margin-top: 4px; }
.nav-group-toggle { width: 100%; background: none; border: 0; color: var(--sidebar-muted); text-transform: uppercase; font-size: .68rem; font-weight: 700; letter-spacing: .08em; display: flex; justify-content: space-between; align-items: center; padding: 10px 11px 6px; }
.nav-group-toggle i { transition: transform .2s; }
.nav-group:not(.open) .nav-group-items { display: none; }
.nav-group:not(.open) .nav-group-toggle i { transform: rotate(-90deg); }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot .btn { color: var(--sidebar-muted) !important; font-size: .8rem; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin .2s ease; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-name, body.sidebar-collapsed .nav-link-item span, body.sidebar-collapsed .nav-group-toggle span, body.sidebar-collapsed .sidebar-foot span { display: none; }
body.sidebar-collapsed .nav-group-items { display: block !important; }
body.sidebar-collapsed .nav-group-toggle { justify-content: center; padding: 6px 0; }
body.sidebar-collapsed .nav-group-toggle i { display: none; }
body.sidebar-collapsed .nav-group { border-top: 1px solid rgba(255,255,255,.06); }
body.sidebar-collapsed .nav-link-item { justify-content: center; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: 280px !important; }
  .main { margin-left: 0 !important; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 1035; }
  body.sidebar-collapsed .brand-name, body.sidebar-collapsed .nav-link-item span { display: inline; }
}

/* topbar */
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 1020; }
.global-search { position: relative; flex: 1; max-width: 560px; }
.global-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 40px 0 36px; color: var(--text); outline: none; }
.global-search input:focus { border-color: var(--brand); background: var(--surface); }
.global-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: var(--border); color: var(--muted); font-size: .7rem; }
.search-pop { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; max-height: 420px; overflow: auto; z-index: 2000; }
.search-pop a { display: flex; gap: 10px; padding: 9px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.search-pop a:hover, .search-pop a.active { background: var(--surface-2); }
.search-pop .grp { font-size: .7rem; text-transform: uppercase; color: var(--muted); padding: 8px 14px 4px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.btn-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); border: 0; background: transparent; font-size: 1.1rem; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.notif-dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: #ef4444; color: #fff; font-size: .62rem; display: grid; place-items: center; padding: 0 4px; }
.notif-menu { width: 360px; max-width: 92vw; }
.notif-list { max-height: 380px; overflow: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notif-item.unread { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.notif-item:hover { background: var(--surface-2); }
.user-chip { display: flex; align-items: center; gap: 8px; border: 0; padding: 4px 8px; border-radius: 10px; }
.user-chip:hover { background: var(--surface-2); }
.user-chip img, .avatar-initial { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-initial { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); display: grid; place-items: center; font-weight: 700; }

/* content */
.content { padding: 22px 24px 40px; }
@media (max-width: 575.98px) { .content { padding: 16px 12px 40px; } .topbar { padding: 0 10px; } }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .85rem; }
.crumbs { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 14px 18px; font-weight: 600; }
.card-body { padding: 18px; }
.stat-card { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; height: 100%; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-card .label { color: var(--muted); font-size: .78rem; font-weight: 500; }
.stat-card .value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-card .delta { font-size: .75rem; }
.tint-blue { background: #dbeafe; color: #1d4ed8; } .tint-green { background: #dcfce7; color: #15803d; } .tint-amber { background: #fef3c7; color: #b45309; }
.tint-red { background: #fee2e2; color: #b91c1c; } .tint-violet { background: #ede9fe; color: #6d28d9; } .tint-cyan { background: #cffafe; color: #0e7490; } .tint-slate { background: #e2e8f0; color: #334155; } .tint-pink { background: #fce7f3; color: #be185d; }
[data-bs-theme="dark"] .tint-blue { background: #1e3a8a55; color: #93c5fd; } [data-bs-theme="dark"] .tint-green { background: #14532d55; color: #86efac; } [data-bs-theme="dark"] .tint-amber { background: #78350f55; color: #fcd34d; }
[data-bs-theme="dark"] .tint-red { background: #7f1d1d55; color: #fca5a5; } [data-bs-theme="dark"] .tint-violet { background: #4c1d9555; color: #c4b5fd; } [data-bs-theme="dark"] .tint-cyan { background: #164e6355; color: #67e8f9; } [data-bs-theme="dark"] .tint-slate { background: #33415555; color: #cbd5e1; } [data-bs-theme="dark"] .tint-pink { background: #83184355; color: #f9a8d4; }

/* tables */
.table-card .table { margin: 0; }
.table { --bs-table-bg: transparent; color: var(--text); }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); padding: 10px 12px; }
.table thead th a { color: inherit; text-decoration: none; }
.table td { border-color: var(--border); vertical-align: middle; padding: 10px 12px; }
.table-hover tbody tr:hover > * { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.table .row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.table .row-link:hover { color: var(--brand); }
.badge-status { font-weight: 600; font-size: .7rem; letter-spacing: .02em; padding: .38em .7em; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search-box { position: relative; min-width: 220px; flex: 1; max-width: 340px; }
.toolbar .search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search-box input { padding-left: 32px; }
.filters-panel { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.bulk-bar { display: none; padding: 8px 14px; background: color-mix(in srgb, var(--brand) 8%, transparent); border-bottom: 1px solid var(--border); }
.bulk-bar.show { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: 8px; opacity: .5; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--text); }

/* forms */
.form-section { margin-bottom: 18px; }
.form-section-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-label { font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.form-label .req { color: #ef4444; }
.form-text { font-size: .74rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end; border-radius: 0 0 var(--radius) var(--radius); z-index: 5; }

/* details */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 20px; }
.detail-grid .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.detail-grid .v { font-weight: 500; word-break: break-word; }
.detail-grid .wide { grid-column: 1 / -1; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; font-size: .84rem; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.nav-tabs { border-bottom: 1px solid var(--border); }
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 10px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item .dot { position: absolute; left: -28px; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; background: var(--surface); border: 2px solid var(--border); }
.timeline-item .meta { font-size: .74rem; color: var(--muted); }

/* kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { flex: 0 0 290px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.kanban-col-head { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .85rem; }
.kanban-col-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 80px; }
.kanban-col-body.drag-over { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .5; }
.kanban-card .name { font-weight: 600; }

/* inventory grid */
.inv-legend span { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: .78rem; }
.inv-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.inv-tower { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.inv-floor { display: flex; gap: 6px; align-items: stretch; margin-bottom: 6px; }
.inv-floor-label { width: 64px; flex-shrink: 0; font-size: .72rem; color: var(--muted); display: flex; align-items: center; font-weight: 600; }
.inv-unit { flex: 1 0 64px; max-width: 110px; min-height: 46px; border-radius: 8px; border: 0; color: #fff; font-size: .74rem; font-weight: 700; line-height: 1.15; padding: 4px; cursor: pointer; transition: transform .1s; }
.inv-unit small { display: block; font-weight: 500; opacity: .9; font-size: .64rem; }
.inv-unit:hover { transform: scale(1.06); }
.st-available { background: #16a34a; } .st-reserved { background: #f59e0b; } .st-booked { background: #2563eb; } .st-sold { background: #334155; }
.st-on_hold { background: #a855f7; } .st-under_construction { background: #0891b2; } .st-possession_ready { background: #059669; }

/* misc */
.chart-box { position: relative; height: 280px; }
.mini-list .item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.mini-list .item:last-child { border-bottom: 0; }
.progress { height: 8px; border-radius: 6px; background: var(--border); }
.progress-bar { background: var(--brand); }
.select-search { position: relative; }
.ss-results { position: absolute; z-index: 1060; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 100%; max-height: 240px; overflow: auto; box-shadow: var(--shadow); }
.ss-results div { padding: 7px 10px; cursor: pointer; }
.ss-results div:hover, .ss-results div.active { background: var(--surface-2); }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.dropzone.drag { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, transparent); }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.gallery img { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; }
.loading-overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 70%, transparent); display: grid; place-items: center; z-index: 10; border-radius: inherit; }
.assistant-panel { position: fixed; right: 18px; bottom: 18px; width: 380px; max-width: calc(100vw - 36px); height: 540px; max-height: calc(100vh - 100px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: none; flex-direction: column; z-index: 1080; }
.assistant-panel.show { display: flex; }
.assistant-log { flex: 1; overflow-y: auto; padding: 14px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; margin-bottom: 8px; white-space: pre-wrap; font-size: .85rem; }
.msg.user { background: var(--brand); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { background: radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--brand) 70%, #000) 0%, var(--brand-2) 60%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }
@media print {
  .sidebar, .topbar, .no-print, .toast-container, .assistant-panel { display: none !important; }
  .main { margin: 0 !important; } .content { padding: 0 !important; } .card { box-shadow: none; border: 0; }
}
