:root {
    --bg: #f4f7fb;
    --ink: #172033;
    --muted: #69758a;
    --line: #e2e8f0;
    --panel: #ffffff;
    --primary: #185abc;
    --primary-dark: #123f86;
    --accent: #0f766e;
    --success: #15803d;
    --warning: #d97706;
    --danger: #dc2626;
    --sidebar: #111827;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a { text-decoration: none; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 278px;
    min-height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--sidebar);
    color: #fff;
    padding: 22px 18px;
    flex-direction: column;
    gap: 22px;
    transition: width .2s ease, padding .2s ease;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    min-height: 42px;
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f766e, #2563eb);
    color: #fff;
}
.sidebar .nav-link,
.mobile-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.76);
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 600;
    white-space: nowrap;
}
.sidebar button.nav-link,
.mobile-nav button.nav-link {
    width: 100%;
    border: 0;
    text-align: left;
}
.sidebar-submenu {
    margin: 2px 0 6px 34px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,.12);
}
.sidebar-submenu .nav-link {
    padding: 9px 12px;
    font-size: 14px;
}
.mobile-nav .sidebar-submenu {
    border-left-color: var(--line);
}
.sidebar .nav-link:hover,
.mobile-nav .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}
.sidebar .nav-link i,
.mobile-nav .nav-link i { width: 20px; text-align: center; }
.mobile-nav .nav-link { color: var(--ink); }
.mobile-nav .nav-link:hover { color: var(--primary); background: #eef4ff; }

.content {
    flex: 1;
    margin-left: 278px;
    padding: 22px;
    width: calc(100% - 278px);
    transition: margin-left .2s ease, width .2s ease;
}
body.sidebar-collapsed .sidebar {
    width: 86px;
    padding-inline: 14px;
}
body.sidebar-collapsed .content {
    margin-left: 86px;
    width: calc(100% - 86px);
}
body.sidebar-collapsed .brand {
    justify-content: center;
}
body.sidebar-collapsed .brand span:not(.brand-mark),
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar .sidebar-toggle .fa-chevron-down {
    display: none;
}
body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding-inline: 12px;
}
body.sidebar-collapsed .sidebar-submenu {
    display: none;
}
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}
.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.page-title {
    font-size: 26px;
    font-weight: 800;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.notification-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--danger);
    position: absolute;
    top: 9px;
    right: 10px;
}
.notification-menu { min-width: 300px; }
.user-pill {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    font-weight: 700;
}
.profile-avatar {
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
    font-weight: 800;
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
}
.profile-avatar-lg {
    width: 82px;
    height: 82px;
    font-size: 24px;
}
.profile-summary {
    display: flex;
    align-items: center;
    gap: 18px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}
.panel h2 {
    font-size: 16px;
    font-weight: 800;
    margin: 0 0 16px;
}
.chart-panel { padding: 20px; min-height: 340px; }
.chart-panel canvas { max-height: 280px; }
.narrow-panel { max-width: 980px; padding: 24px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 104px;
}
.stat-card .icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--primary);
}
.stat-card p { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; font-size: 24px; }
.broker-action {
    min-height: 140px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    color: var(--ink);
}
.broker-action:hover {
    color: var(--primary);
    border-color: #b7cff8;
}
.broker-action span {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #eef4ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.broker-action strong { font-size: 18px; }
.broker-action small { color: var(--muted); font-weight: 600; }

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.searchbox {
    min-width: 260px;
    flex: 1;
    position: relative;
}
.searchbox i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}
.searchbox .form-control { padding-left: 40px; }
.status-filter,
.broker-filter,
.facing-filter,
.project-filter { max-width: 260px; }
.module-table th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    background: #f8fafc;
    white-space: nowrap;
}
.module-table td { white-space: nowrap; }
.module-table th,
.module-table td { padding: 14px 16px; }
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}
.table-footer-top {
    border-top: 0;
    border-bottom: 1px solid var(--line);
}
.pagination-wrap .btn { min-width: 38px; }
.badge {
    border-radius: 999px;
    padding: 7px 10px;
    font-weight: 800;
}
.badge-Available, .plot-Available { background: #dcfce7; color: #166534; }
.badge-Advanced-Booked, .plot-Advanced-Booked { background: #fef3c7; color: #92400e; }
.badge-Sold, .plot-Sold { background: #fee2e2; color: #991b1b; }
.doc-status {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.doc-status.uploaded {
    background: #dcfce7;
    color: #166534;
}
.doc-status.missing {
    background: #f1f5f9;
    color: var(--muted);
}

.project-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.project-tile {
    min-height: 160px;
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .05);
}
.project-tile:hover,
.project-tile.active {
    border-color: var(--primary);
    box-shadow: 0 14px 34px rgba(24, 90, 188, .14);
}
.project-tile-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef4ff;
    color: var(--primary);
}
.project-tile strong {
    font-size: 18px;
    line-height: 1.25;
}
.project-tile small {
    color: var(--muted);
    min-height: 18px;
}
.project-tile-counts {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}
.project-tile-counts em {
    font-style: normal;
    color: var(--success);
    font-weight: 800;
}
.plot-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.plot-tile {
    border: 1px solid currentColor;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.plot-tile strong { font-size: 18px; }
.plot-tile em {
    font-style: normal;
    font-size: 12px;
    line-height: 1.25;
    color: currentColor;
    opacity: .82;
}
.plot-tile small { font-weight: 700; }
.empty-plot-message {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}
.modal-dialog-scrollable {
    height: calc(100vh - 3.5rem);
}
.modal-dialog-scrollable .modal-content {
    max-height: 100%;
}
.modal-content {
    border-radius: 8px;
    border: 0;
    overflow: hidden;
}
.modal-content form {
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}
.modal-header,
.modal-footer {
    flex: 0 0 auto;
}
.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.form-control, .form-select, .btn { border-radius: 8px; }
.password-field {
    position: relative;
}
.password-field .form-control {
    padding-right: 46px;
}
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover,
.password-toggle:focus {
    background: #eef4ff;
    color: var(--primary);
}
.sales-installments,
.advance-payments {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}
.installment-tools,
.installment-row,
.advance-payment-row {
    display: grid;
    gap: 10px;
    align-items: center;
}
.installment-tools {
    grid-template-columns: minmax(130px, 170px) auto auto;
    margin-bottom: 12px;
}
.installment-row,
.advance-payment-row {
    grid-template-columns: minmax(130px, 160px) minmax(130px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) 48px;
    margin-top: 10px;
}
.installment-label {
    color: var(--muted);
    font-weight: 800;
}
.amount-in-words {
    min-height: 18px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
}
.invoice-transaction-list {
    text-align: left;
}
.invoice-buyer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    color: var(--text);
}
.invoice-transaction-list .btn {
    margin-left: 4px;
}
.brokerage-payment-form {
    display: grid;
    grid-template-columns: 1fr 180px auto;
    gap: 10px;
    margin: 14px 0;
}
.btn { font-weight: 700; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.login-page {
    background: #eef3f8;
}
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 520px) 1fr;
}
.login-panel {
    background: #fff;
    padding: min(7vw, 72px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 34px;
}
.login-brand h1 { margin: 0; font-weight: 900; }
.login-brand p { margin: 0; color: var(--muted); }
.login-art {
    color: #fff;
    display: flex;
    align-items: end;
    padding: min(7vw, 72px);
    background:
        linear-gradient(180deg, rgba(17,24,39,.2), rgba(17,24,39,.78)),
        url('https://images.unsplash.com/photo-1560518883-ce09059eeffa?auto=format&fit=crop&w=1600&q=80') center/cover;
}
.login-art h2 {
    max-width: 720px;
    font-size: clamp(32px, 4vw, 62px);
    line-height: 1.05;
    font-weight: 900;
}

@media (max-width: 1199px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
    .content { margin-left: 0; width: 100%; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-wrap { grid-template-columns: 1fr; }
    .login-art { min-height: 280px; }
}
@media (max-width: 575px) {
    .topbar { align-items: flex-start; }
    .topbar-actions { margin-left: 0 !important; }
    .page-title { font-size: 21px; }
    .stats-grid { grid-template-columns: 1fr; }
    .toolbar { align-items: stretch; }
    .searchbox, .status-filter, .broker-filter, .facing-filter, .project-filter, .toolbar .btn { width: 100%; max-width: none; }
    .table-footer { flex-direction: column; align-items: stretch; }
    .plot-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-panel { padding: 28px; }
    .modal-dialog {
        margin: 10px;
    }
    .modal-dialog-scrollable {
        height: calc(100vh - 20px);
    }
    .modal-body {
        padding: 16px;
    }
    .installment-tools,
    .installment-row,
    .advance-payment-row {
        grid-template-columns: 1fr;
    }
    .profile-summary {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    .sidebar, .topbar, .toolbar, .btn, .offcanvas { display: none !important; }
    .content { margin: 0; width: 100%; padding: 0; }
    .panel { box-shadow: none; border-color: #bbb; }
}
