:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --line: #e2e8f0;
    --input-bg: #ffffff;
    --input-text: #1e293b;
}

body.dark-mode {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --line: #334155;
    --input-bg: #0f172a;
    --input-text: #f8fafc;
}
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}
body {
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.2s, color 0.2s;
}
/* Top row holding Title and Logout */
.topbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
}

/* Larger title */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.5px;
    color: #ffffff;
    
    /* Solid Black Background Badge */
    background: #000000; /* Or rgba(0, 0, 0, 0.85) for a sleek dark tint */
    border: 1px solid rgba(255, 255, 255, 0.2); /* Subtle light border for separation */
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Position logout button cleanly on the top-right */
.topbar-header .logout-icon-btn,
a.logout-icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border: 1px solid #dc2626 !important;
    text-decoration: none !important;
    transition: all 0.2s ease-in-out !important;
}

.topbar-header .logout-icon-btn:hover,
a.logout-icon-btn:hover {
    background-color: #b91c1c !important;
    border-color: #b91c1c !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* Card & Table Containers */
.card, .stat {
    background-color: var(--card-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* Stats Layout Grid */
/* Stats Layout Grid */
.stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    width: 100%;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}
/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
/* Secondary text / subtitles / labels */
.subtitle, .label, .stat .label, td {
    color: var(--text-muted);
}

/* Stat card values and table headings */
.stat .value, th, td, h1, h2, h3 {
    color: var(--text) !important;
}

/* Date Pickers & Inputs in Dark Mode */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode select {
    background-color: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--line);
}
/* Base Light Theme */
/* Base Light Theme */
:root {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --line: #e2e8f0;
    --brand: #0d9488;
    --input-bg: #ffffff;
    --input-text: #0f172a;
}

/* Dark Theme Overrides */
body.dark-mode {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --line: #334155;
    --input-bg: #0f172a;
    --input-text: #f8fafc;
}

/* Dark Theme Overrides */
body.dark-mode {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --slate: #94a3b8;
    --line: #334155;
}

body {
    background-color: var(--bg);
    color: var(--text);
}

.card, .topbar, .footer {
    background-color: var(--card);
}
:root {
    --ink: #17242b;
    --slate: #4d626c;
    --paper: #f6f4ef;
    --card: #ffffff;
    --line: #dde3e2;
    --teal: #0e6e63;
    --teal-dark: #0a534a;
    --amber: #c07a1f;
    --danger: #b3402f;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.5;
}

.topbar {
    background: var(--teal-dark);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.brand { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.2px; }

.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.nav a {
    color: #d9efe9;
    text-decoration: none;
    font-size: 0.92rem;
    padding: 4px 2px;
}
.nav a:hover, .nav a:focus { color: #fff; text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 22px 16px 60px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.subtitle { color: var(--slate); margin: 0 0 20px; font-size: 0.95rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
/* Prevent awkward text line wrapping in table columns */
table th, table td {
    padding: 10px 12px;
    white-space: nowrap;
    vertical-align: middle;
}

table th {
    font-weight: 700;
}

/* Allow tenant names to wrap naturally if long */
table td:nth-child(2) {
    white-space: normal;
}

/* Keep Action buttons aligned horizontally */
table td:last-child {
    display: flex;
    gap: 6px;
    align-items: center;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--teal);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--slate); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--slate); font-weight: 600; font-size: 0.82rem; text-transform: none; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

form .field { margin-bottom: 14px; }
label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 5px; color: var(--slate); }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=tel], select, textarea {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
    border-color: var(--teal);
}

.btn {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 0.96rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: #fff; color: var(--teal-dark); border: 1px solid var(--teal); }
.btn.secondary:hover { background: #eef6f4; }
.btn.danger { background: var(--danger); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge.pending { background: #fbe9d2; color: var(--amber); }
.badge.sent { background: #d9efe9; color: var(--teal-dark); }
.badge.paid { background: #dcedd4; color: #2f6e2f; }
.badge.partial { background: #fde0d0; color: #b3402f; }
.badge.unpaid { background: #f6dcd6; color: var(--danger); }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.94rem;
}
.alert.success { background: #dcedd4; color: #2f6e2f; }
.alert.error { background: #f6dcd6; color: var(--danger); }

.login-wrap {
    max-width: 360px;
    margin: 10vh auto 0;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checkbox-row input { width: auto; }

.footer { text-align: center; color: var(--slate); font-size: 0.82rem; padding: 20px; }

.empty-state { text-align: center; color: var(--slate); padding: 30px 10px; }

@media (max-width: 560px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .container { padding: 16px 12px 50px; }
}
/* Navigation Links Styling */
nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 1.05rem;       /* Larger text size */
    font-weight: 700;         /* Bold weight */
    padding: 8px 14px;
    border-radius: 6px;
    position: relative;
    transition: all 0.2s ease-in-out;
}

/* Hover State */
nav a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Active Tab Highlight */
nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

/* Bottom Bar Indicator for Active Tab */
nav a.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 12px;
    right: 12px;
    height: 3px;
    background-color: #00ffc4; /* Bright indicator bar */
    border-radius: 2px;
}
/* Base navigation link styling */
.nav a {
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 6px;
    position: relative;
    transition: all 0.25s ease-in-out;
}

/* Unique tab colors (Normal state) */
.nav a[href="index.php"] { color: #38bdf8; }         /* Dashboard - Sky Blue */
.nav a[href="units.php"] { color: #fbbf24; }         /* Units - Amber / Yellow */
.nav a[href="readings.php"] { color: #34d399; }      /* Readings - Emerald Green */
.nav a[href="billing.php"] { color: #c084fc; }       /* Bills - Purple / Violet */
.nav a[href="messages.php"] { color: #f472b6; }      /* Send Messages - Pink */
/* Logout Icon Button */
.logout-icon-btn,
a[href="logout.php"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background-color: #ffffff;
    color: #dc2626;
    border: 1px solid #ffffff;
    transition: all 0.2s ease-in-out;
}

.logout-icon-btn:hover,
a[href="logout.php"]:hover {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    transform: translateY(-1px);
}

/* Active tab highlight & color indicator */
.nav a.active {
    background: rgba(255, 255, 255, 0.15);
}

.nav a.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 10px;
    right: 10px;
    height: 3px;
    border-radius: 2px;
    background-color: currentColor;                 /* Matches the tab's unique color */
    box-shadow: 0 0 8px currentColor;                /* Subtle glow effect */
}
/* Footer Layout & Bottom Right Note */
.footer {
    width: 100%;
    padding: 16px 24px;
    margin-top: 40px;
    border-top: 1px solid var(--line);
    background-color: var(--card);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--slate);
}

.footer-title {
    text-align: left;
}

.footer-credit {
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    opacity: 0.85;
}

.footer-credit strong {
    color: var(--brand, #0d9488);
}
/* Full-height page container setup */
html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Expand main content container so footer sits at screen bottom */
main, .login-wrap {
    flex: 1 0 auto;
}

/* Footer layout and styling */
.footer {
    width: 100%;
    padding: 16px 24px;
    background-color: var(--card, #ffffff);
    border-top: 1px solid var(--line, #e2e8f0);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--slate, #64748b);
}

.footer-credit strong {
    color: #0d9488; /* Teal brand accent */
}
/* ==========================================
   Print Stylesheet
   ========================================== */
@media print {
    /* Hide non-printable UI elements */
    .topbar-header,
    nav,
    .btn,
    .btn-row,
    form,
    .action-btns,
    .no-print {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 12pt;
        margin: 0;
        padding: 0;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 10px;
    }

    th, td {
        border: 1px solid #333333 !important;
        padding: 8px !important;
        color: #000000 !important;
        text-align: left;
    }

    th {
        background-color: #f2f2f2 !important;
        font-weight: bold;
    }

    /* Keep badges readable in black and white */
    .badge {
        border: 1px solid #000000 !important;
        color: #000000 !important;
        background: transparent !important;
        padding: 2px 6px;
    }
}