:root {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: rgba(15,23,42,.62);
    --border: rgba(15,23,42,.10);
    --border2: rgba(15,23,42,.14);
    --shadow: 0 14px 40px rgba(15,23,42,.08);
    --shadow-sm: 0 8px 22px rgba(15,23,42,.07);
    --primary: #22304a;
    --primary2: #0f172a;
    --primary-ink: #ffffff;
    --radius-lg: 18px;
    --radius: 14px;
    --radius-sm: 12px;
    --focus: 0 0 0 4px rgba(34,48,74,.18);
}

html, body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-feature-settings: "ss01" 1,"cv02" 1;
}

/* Premium Top Navbar + Menu */
.dashboard-navbar {
    background: linear-gradient(180deg, rgba(15,23,42,.98), rgba(34,48,74,.98));
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 18px 46px rgba(15,23,42,.16);
}

.dashboard-menu {
    background: linear-gradient(180deg, rgba(34,48,74,.98), rgba(15,23,42,.98));
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.dashboard-title {
    color: #fff !important;
    letter-spacing: .02em;
    font-weight: 500 !important;
}

    .dashboard-title span {
        color: rgba(255,255,255,.85) !important;
    }

    .dashboard-title .app-title {
        font-weight: 500;
        white-space: nowrap;
    }

    .dashboard-title .app-context {
        max-width: none;
        font-weight: 400;
    }

.dashboard-user span {
    color: rgba(255,255,255,.92) !important;
}

.menu-item {
    border-radius: 999px !important;
    padding: .55rem 1rem !important;
    font-weight: 500 !important;
    letter-spacing: .01em;
    color: rgba(255,255,255,.88) !important;
    background: transparent;
}

    .menu-item:hover,
    .menu-item.active {
        background: rgba(255,255,255,.10) !important;
        color: #fff !important;
    }

.menu-icon {
    opacity: .92;
}

/* Submenu panel */
.master-submenu-panel {
    background: rgba(255,255,255,.96) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(15,23,42,.10) !important;
    border-radius: 16px !important;
    box-shadow: 0 24px 64px rgba(15,23,42,.18) !important;
    padding: 14px 14px !important;
    margin-top: 10px;
}

.submenu-grid {
    gap: 8px 14px !important;
}

.submenu-item {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: rgba(15,23,42,.85) !important;
    border-radius: 12px !important;
    padding: 10px 10px !important;
    border: 1px solid transparent;
}

    .submenu-item:hover {
        background: rgba(34,48,74,.08) !important;
        color: rgba(15,23,42,1) !important;
        border-color: rgba(34,48,74,.18) !important;
    }

/* Logout button */
.logout-btn {
    background: transparent !important;
    border: 1px solid rgba(255,255,255,.14) !important;
    border-radius: 999px !important;
    padding: .55rem 1rem !important;
}

    .logout-btn:hover {
        background: rgba(255,255,255,.10) !important;
    }

/* Layout containers used across the app */
.dashboard-content {
    padding: 20px;
}

.saas-page {
    padding: 18px 18px 40px 18px;
}

.saas-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

@media (max-width: 768px) {
    .saas-top {
        flex-direction: column;
        align-items: stretch;
    }

    .saas-actions {
        justify-content: flex-start;
    }
}

.saas-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Cards / panels */
.card,
.panel,
.wcard,
.sum-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

    .card.panel {
        padding: 14px;
    }

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-title {
    font-weight: 900;
    letter-spacing: -.01em;
}

.panel-sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Tables */
.table,
.tbl {
    background: var(--surface);
}

.tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

    .tbl thead th {
        font-weight: 900;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: rgba(15,23,42,.78);
        background: rgba(15,23,42,.03);
        border-bottom: 1px solid var(--border);
        padding: 12px 12px;
    }

    .tbl tbody td {
        border-bottom: 1px solid rgba(15,23,42,.08);
        padding: 12px 12px;
        vertical-align: middle;
    }

    .tbl tbody tr:hover td {
        background: rgba(34,48,74,.03);
    }

.table-wrap {
    overflow: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

    .table-wrap .tbl {
        border-radius: var(--radius-lg);
    }

/* Bootstrap tables (floors-table etc.) */
.floors-table {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
}

    .table-dark,
    .floors-table thead.table-dark {
        --bs-table-bg: rgba(15,23,42,.96);
    }

/* Inputs */
.form-control,
.form-select,
.select,
input[type="text"],
input[type="number"],
textarea {
    border-radius: 12px;
    border: 1px solid rgba(15,23,42,.14);
    box-shadow: none;
}

    .form-control:focus,
    .form-select:focus,
    .select:focus,
    textarea:focus {
        border-color: rgba(34,48,74,.45);
        box-shadow: var(--focus) !important;
    }

.form-label {
    font-weight: 800;
    color: rgba(15,23,42,.78);
}

/* Buttons */
.btn {
    border-radius: 14px;
    font-weight: 800;
}

.btn-primary {
    background: linear-gradient(180deg,var(--primary),var(--primary2));
    border-color: transparent;
}

    .btn-primary:hover {
        filter: brightness(1.02);
    }

/* Ensure secondary/success buttons don't blend into the page background */
.btn-secondary {
    background: rgba(34,48,74,.12);
    border-color: rgba(34,48,74,.18);
    color: rgba(15,23,42,.92);
}

    .btn-secondary:hover {
        background: rgba(34,48,74,.18);
        border-color: rgba(34,48,74,.26);
        color: rgba(15,23,42,.95);
    }

.btn-success {
    background: linear-gradient(180deg,#167a4a,#0f5f39) !important;
    border-color: transparent !important;
    color: #fff !important;
}

    .btn-success:hover {
        filter: brightness(1.03);
        color: #fff;
    }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border2);
    color: rgba(15,23,42,.85);
}

    .btn-ghost:hover {
        background: rgba(34,48,74,.05);
    }

/* Existing reusable add button (keep compatible) */
.btn-master-add {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(180deg,var(--primary),var(--primary2));
    color: var(--primary-ink);
    font-weight: 800;
    font-size: 13px;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

    .btn-master-add:hover {
        transform: translateY(-1px);
        box-shadow: 0 14px 40px rgba(15,23,42,.12);
        color: var(--primary-ink);
    }

    .btn-master-add .btn-ic {
        width: 22px;
        height: 22px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,.16);
    }

/* Search pill */
.search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 10px 26px rgba(15,23,42,.06);
}

    .search input {
        border: 0;
        outline: none;
        box-shadow: none !important;
        padding: 0;
        min-width: 240px;
        background: transparent;
    }

.search-ic {
    opacity: .65;
}

/* Chips / badges */
.chips-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.chip {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 800;
    font-size: 12px;
    color: rgba(15,23,42,.78);
}

.chip-soft {
    background: rgba(34,48,74,.05);
}

.badge {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15,23,42,.03);
    color: rgba(15,23,42,.82);
    font-weight: 900;
    padding: 7px 11px;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: rgba(15,23,42,.03);
    font-weight: 900;
    font-size: 12px;
}

/* Alerts */
.alert {
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 30px rgba(15,23,42,.08);
}

/* Pagination */
.pagination .page-link {
    border-radius: 12px;
    font-weight: 800;
}

.pagination .page-item.active .page-link {
    background: linear-gradient(180deg,var(--primary),var(--primary2));
    border-color: transparent;
}

/* Wizard / sections */
.divider {
    background: rgba(15,23,42,.08);
}

/* Small utilities */
.mono {
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--muted) !important;
}

/* Responsive tables */
@media (max-width: 768px) {
    .floors-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

        .floors-header > div {
            flex-wrap: wrap;
        }

        .floors-header input.form-control {
            width: 100% !important;
            margin-left: 0 !important;
        }

    .tbl thead {
        display: none;
    }

    .tbl tbody tr {
        display: block;
        border-bottom: 1px solid var(--border);
    }

    .tbl tbody td {
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }
}

/* Responsive header/menu improvements */
@media (max-width: 900px) {
    .dashboard-navbar {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 10px 1rem;
        gap: 8px;
    }

    .dashboard-title {
        flex: 1 1 100%;
        gap: 6px;
    }

        .dashboard-title .app-context {
            max-width: 100%;
        }

    .dashboard-user {
        margin-left: auto;
    }

    .dashboard-menu {
        padding: 0 .75rem;
        gap: .4rem;
    }

    .menu-item {
        padding: .45rem .75rem !important;
        font-size: 14px;
    }
}

@media (max-width: 520px) {
    .dashboard-title {
        align-items: flex-start;
    }

        .dashboard-title .app-title {
            white-space: normal;
        }

        .dashboard-title .app-context {
            white-space: normal;
        }

    .dashboard-user {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Dropdown panel sizing + internal scroll so it stays usable on all screens */
.master-submenu-panel {
    max-height: min(60vh, 520px);
}

@media (max-width: 900px) {
    .master-submenu-panel {
        left: 0;
        right: 0;
        width: auto;
        max-width: calc(100vw - 2rem);
    }

    .submenu-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 520px) {
    .submenu-grid {
        grid-template-columns: 1fr;
    }
}
