/* =========================================================
   SUB METER MANAGER — COMPLETE STYLESHEET
========================================================= */

/* -------------------------
   ROOT VARIABLES
-------------------------- */

:root {
    --primary: #0f766e;
    --primary-dark: #0a5d57;
    --primary-light: #ccfbf1;
    --primary-soft: #f0fdfa;

    --secondary: #2563eb;
    --secondary-soft: #eff6ff;

    --purple: #7c3aed;
    --purple-soft: #f5f3ff;

    --orange: #ea580c;
    --orange-soft: #fff7ed;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-soft: #fef2f2;

    --success: #16a34a;
    --success-soft: #f0fdf4;

    --warning: #d97706;
    --warning-soft: #fffbeb;

    --background: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;

    --text: #172033;
    --text-light: #64748b;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --sidebar-width: 265px;
    --topbar-height: 82px;

    --radius-small: 10px;
    --radius: 16px;
    --radius-large: 24px;

    --shadow-small:
        0 4px 16px rgba(15, 23, 42, 0.05);

    --shadow:
        0 12px 35px rgba(15, 23, 42, 0.08);

    --shadow-large:
        0 25px 70px rgba(15, 23, 42, 0.16);

    --transition: 180ms ease;
}


/* -------------------------
   RESET
-------------------------- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
    line-height: 1.5;
    overflow-x: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

input,
select,
textarea {
    width: 100%;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

.hidden {
    display: none !important;
}


/* -------------------------
   COMMON TYPOGRAPHY
-------------------------- */

h1,
h2,
h3,
h4 {
    line-height: 1.2;
    color: var(--text);
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.7rem;
}

h3 {
    font-size: 1.05rem;
}

p {
    color: var(--text-light);
}

small {
    color: var(--text-light);
}

.eyebrow,
.topbar-label {
    display: block;
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}


/* -------------------------
   BUTTONS
-------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    transition:
        transform var(--transition),
        background var(--transition),
        border-color var(--transition),
        box-shadow var(--transition);
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.button-primary {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-outline {
    color: var(--text);
    background: #ffffff;
    border-color: var(--border-dark);
}

.button-outline:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.button-danger {
    color: #ffffff;
    background: var(--danger);
}

.button-danger:hover {
    background: var(--danger-dark);
}

.button-full {
    width: 100%;
}

.text-button {
    padding: 6px;
    border: 0;
    color: var(--primary);
    background: transparent;
    font-size: 0.85rem;
    font-weight: 700;
}

.text-button:hover {
    text-decoration: underline;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    color: var(--text);
    background: transparent;
    font-size: 1.45rem;
    transition: background var(--transition);
}

.icon-button:hover {
    background: var(--surface-soft);
}


/* =========================================================
   LOGIN SCREEN
========================================================= */

.login-screen {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    overflow: hidden;
    background:
        radial-gradient(
            circle at top left,
            rgba(45, 212, 191, 0.22),
            transparent 35%
        ),
        radial-gradient(
            circle at bottom right,
            rgba(37, 99, 235, 0.16),
            transparent 38%
        ),
        linear-gradient(135deg, #ecfeff 0%, #f8fafc 55%, #eff6ff 100%);
}

.login-decoration {
    position: absolute;
    border-radius: 999px;
    filter: blur(2px);
    pointer-events: none;
}

.decoration-one {
    top: -140px;
    left: -140px;
    width: 350px;
    height: 350px;
    background: rgba(20, 184, 166, 0.13);
}

.decoration-two {
    right: -120px;
    bottom: -160px;
    width: 380px;
    height: 380px;
    background: rgba(37, 99, 235, 0.11);
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-large);
    backdrop-filter: blur(18px);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.login-brand h1 {
    font-size: 1.15rem;
}

.login-brand p {
    margin-top: 3px;
    font-size: 0.83rem;
}

.brand-logo {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 17px;
    color: #ffffff;
    background:
        linear-gradient(135deg, var(--primary), #14b8a6);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.25);
}

.brand-logo span {
    font-weight: 900;
    letter-spacing: -0.04em;
}

.brand-logo-small {
    width: 44px;
    height: 44px;
    border-radius: 13px;
}

.login-heading {
    padding: 28px 0 20px;
}

.login-heading h2 {
    margin-bottom: 8px;
}

.login-heading p {
    font-size: 0.92rem;
}

.login-form {
    display: grid;
    gap: 18px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 74px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    transform: translateY(-50%);
    padding: 7px 10px;
    border: 0;
    border-radius: 8px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 0.75rem;
    font-weight: 800;
}

.login-security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 22px;
    padding: 13px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    background: var(--success-soft);
}

.security-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #ffffff;
    background: var(--success);
    font-size: 0.75rem;
    font-weight: 900;
}

.login-security-note p {
    color: #166534;
    font-size: 0.78rem;
}


/* =========================================================
   APPLICATION LAYOUT
========================================================= */

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    background:
        linear-gradient(180deg, #0b2431 0%, #102c38 58%, #0d2530 100%);
    box-shadow: 8px 0 35px rgba(15, 23, 42, 0.08);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand strong {
    color: #ffffff;
    font-size: 0.92rem;
}

.sidebar-brand small {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 0.72rem;
}

.close-sidebar {
    display: none;
    color: #ffffff;
}

.sidebar-navigation {
    display: grid;
    gap: 7px;
    padding: 20px 14px;
    overflow-y: auto;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 11px;
    color: #b8c7d2;
    background: transparent;
    font-size: 0.88rem;
    font-weight: 650;
    text-align: left;
    transition:
        color var(--transition),
        background var(--transition),
        transform var(--transition);
}

.nav-button:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
    transform: translateX(2px);
}

.nav-button.active {
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            rgba(20, 184, 166, 0.28),
            rgba(13, 148, 136, 0.16)
        );
    box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 26px;
    height: 26px;
    color: #5eead4;
    font-size: 1.15rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
}

.admin-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 39px;
    height: 39px;
    border-radius: 12px;
    color: #ffffff;
    background: rgba(45, 212, 191, 0.22);
    font-size: 0.9rem;
    font-weight: 900;
}

.admin-profile strong,
.admin-profile small {
    display: block;
}

.admin-profile strong {
    color: #ffffff;
    font-size: 0.82rem;
}

.admin-profile small {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.69rem;
}

.sidebar-footer .button-outline {
    color: #dbeafe;
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

.main-wrapper {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 30px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 13px;
}

.topbar-right {
    gap: 28px;
}

.topbar h1 {
    font-size: 1.25rem;
}

.topbar-label {
    margin-bottom: 2px;
    font-size: 0.59rem;
}

.mobile-menu {
    display: none;
}

.sync-status,
.topbar-date {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-status small,
.sync-status strong,
.topbar-date small,
.topbar-date strong {
    display: block;
}

.sync-status small,
.topbar-date small {
    color: var(--text-muted);
    font-size: 0.65rem;
}

.sync-status strong,
.topbar-date strong {
    color: var(--text);
    font-size: 0.78rem;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 5px var(--warning-soft);
}

.sync-status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 0 5px var(--success-soft);
}

.main-content {
    width: 100%;
    max-width: 1700px;
    margin: 0 auto;
    padding: 28px 30px 50px;
}

.page {
    display: none;
    animation: pageFade 220ms ease;
}

.page.active {
    display: block;
}

@keyframes pageFade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-overlay {
    display: none;
}


/* =========================================================
   PAGE HEADERS AND CARDS
========================================================= */

.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-intro h2 {
    margin-bottom: 7px;
}

.page-intro p {
    max-width: 650px;
    font-size: 0.9rem;
}

.intro-actions {
    display: flex;
    gap: 10px;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-small);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1rem;
}

.badge,
.count-badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
}

.badge {
    padding: 6px 10px;
    color: var(--primary);
    background: var(--primary-light);
}

.count-badge {
    min-width: 24px;
    height: 24px;
    margin-left: 5px;
    color: #ffffff;
    background: var(--primary);
}

.status-badge {
    padding: 7px 11px;
}

.status-badge.connected {
    color: #166534;
    background: var(--success-soft);
}

.status-badge.disconnected {
    color: #991b1b;
    background: var(--danger-soft);
}


/* =========================================================
   STAT CARDS
========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    min-height: 122px;
    padding: 19px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-small);
}

.stat-card > div:last-child {
    min-width: 0;
}

.stat-card span,
.stat-card strong,
.stat-card small {
    display: block;
}

.stat-card span {
    color: var(--text-light);
    font-size: 0.76rem;
    font-weight: 650;
}

.stat-card strong {
    margin: 5px 0 3px;
    overflow: hidden;
    color: var(--text);
    font-size: 1.55rem;
    line-height: 1.1;
    text-overflow: ellipsis;
}

.stat-card small {
    color: var(--text-muted);
    font-size: 0.67rem;
}

.stat-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 47px;
    height: 47px;
    border-radius: 14px;
    font-size: 1.25rem;
    font-weight: 900;
}

.stat-teal .stat-icon {
    color: var(--primary);
    background: var(--primary-light);
}

.stat-blue .stat-icon {
    color: var(--secondary);
    background: var(--secondary-soft);
}

.stat-purple .stat-icon {
    color: var(--purple);
    background: var(--purple-soft);
}

.stat-orange .stat-icon {
    color: var(--orange);
    background: var(--orange-soft);
}


/* =========================================================
   DASHBOARD
========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-meter-card,
.reminder-card {
    min-height: 330px;
}

.meter-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    padding: 20px 22px;
}

.meter-summary-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.meter-summary-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

.meter-summary-name {
    overflow: hidden;
    font-size: 0.85rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meter-summary-units {
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 900;
}

.usage-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 99px;
    background: #e2e8f0;
}

.usage-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background:
        linear-gradient(90deg, var(--primary), #2dd4bf);
}

.meter-summary-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 9px;
    color: var(--text-muted);
    font-size: 0.67rem;
}

.reminder-list {
    display: grid;
    gap: 11px;
    padding: 18px 20px;
}

.reminder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-soft);
}

.reminder-date-box {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 45px;
    height: 45px;
    border-radius: 12px;
    color: var(--primary);
    background: var(--primary-light);
    font-size: 0.78rem;
    font-weight: 900;
}

.reminder-content {
    min-width: 0;
}

.reminder-content strong,
.reminder-content span {
    display: block;
}

.reminder-content strong {
    overflow: hidden;
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-content span {
    margin-top: 2px;
    color: var(--text-light);
    font-size: 0.7rem;
}


/* =========================================================
   TABLES
========================================================= */

.table-card {
    overflow: hidden;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 17px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--text-light);
    background: var(--surface-soft);
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

td {
    color: var(--text);
    font-size: 0.79rem;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.table-meter-name {
    font-weight: 800;
}

.table-unit-value {
    color: var(--primary);
    font-weight: 900;
}

.table-note {
    display: block;
    max-width: 230px;
    overflow: hidden;
    color: var(--text-light);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-status {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    color: #166534;
    background: var(--success-soft);
    font-size: 0.65rem;
    font-weight: 800;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

.table-action {
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-light);
    background: #ffffff;
    font-size: 0.68rem;
    font-weight: 800;
}

.table-action:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.table-action.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-soft);
}


/* =========================================================
   EMPTY STATES
========================================================= */

.empty-state {
    display: grid;
    place-items: center;
    padding: 40px 20px;
    text-align: center;
}

.empty-state h3,
.empty-state h4 {
    margin-bottom: 6px;
}

.empty-state p {
    max-width: 390px;
    font-size: 0.8rem;
}

.empty-state.compact {
    padding: 24px 18px;
}

.empty-state.large {
    min-height: 280px;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 55px;
    height: 55px;
    margin-bottom: 12px;
    border-radius: 16px;
    color: var(--primary);
    background: var(--primary-light);
    font-size: 1.4rem;
    font-weight: 900;
}


/* =========================================================
   FORMS
========================================================= */

.form-card {
    padding: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    min-width: 0;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-size: 0.77rem;
    font-weight: 800;
}

.optional {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    min-height: 45px;
    padding: 10px 12px;
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    outline: none;
    color: var(--text);
    background: #ffffff;
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        background var(--transition);
}

.form-group textarea {
    min-height: 105px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.11);
}

.form-group input[readonly] {
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 900;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.67rem;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.form-message {
    min-height: 18px;
    margin-top: 8px;
    font-size: 0.77rem;
    font-weight: 700;
}

.form-message.error {
    color: var(--danger);
}

.form-message.success {
    color: var(--success);
}

.total-units-field {
    position: relative;
}

.total-units-field input {
    padding-right: 75px;
    font-size: 1.15rem;
}

.total-units-field span {
    position: absolute;
    top: 50%;
    right: 13px;
    transform: translateY(-50%);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 900;
}

.information-box,
.warning-box {
    margin-top: 17px;
    padding: 13px 15px;
    border-radius: 11px;
    font-size: 0.77rem;
}

.information-box {
    color: #155e75;
    border: 1px solid #bae6fd;
    background: #f0f9ff;
}

.warning-box {
    color: #92400e;
    border: 1px solid #fde68a;
    background: var(--warning-soft);
}


/* =========================================================
   NEW READING
========================================================= */

.reading-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 20px;
}

.reading-help {
    display: grid;
    align-content: start;
    gap: 12px;
}

.help-card {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-small);
}

.help-number {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    color: var(--primary);
    background: var(--primary-light);
    font-size: 0.7rem;
    font-weight: 900;
}

.help-card h3 {
    margin-bottom: 5px;
    font-size: 0.84rem;
}

.help-card p {
    font-size: 0.73rem;
}


/* =========================================================
   FILTERS
========================================================= */

.filter-card {
    margin-bottom: 20px;
    padding: 17px 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns:
        minmax(200px, 1.3fr)
        minmax(160px, 0.8fr)
        minmax(160px, 0.8fr)
        auto;
    align-items: end;
    gap: 13px;
}

.report-filter-grid {
    grid-template-columns:
        minmax(180px, 1fr)
        minmax(150px, 0.7fr)
        auto;
}

.filter-button-group {
    display: flex;
    align-items: flex-end;
}


/* =========================================================
   MANAGE METERS
========================================================= */

.meter-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px 18px;
}

.meter-toolbar p {
    font-size: 0.75rem;
}

.meters-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 17px;
}

.meter-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-small);
    transition:
        transform var(--transition),
        box-shadow var(--transition);
}

.meter-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.meter-card.archived {
    opacity: 0.72;
    background: #f8fafc;
}

.meter-card::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    content: "";
    background:
        linear-gradient(90deg, var(--primary), #2dd4bf);
}

.meter-card.archived::before {
    background: var(--text-muted);
}

.meter-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.meter-card-title {
    min-width: 0;
}

.meter-card-title h3 {
    overflow: hidden;
    margin-bottom: 4px;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meter-card-title p {
    font-size: 0.73rem;
}

.meter-status {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 900;
}

.meter-status.active {
    color: #166534;
    background: var(--success-soft);
}

.meter-status.archived {
    color: #475569;
    background: #e2e8f0;
}

.meter-details {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.meter-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding-bottom: 9px;
    border-bottom: 1px dashed var(--border);
    font-size: 0.75rem;
}

.meter-detail-row span {
    color: var(--text-light);
}

.meter-detail-row strong {
    text-align: right;
}

.meter-card-actions {
    display: flex;
    gap: 8px;
}

.meter-card-actions .button {
    min-height: 38px;
    flex: 1;
    padding: 8px 10px;
    font-size: 0.72rem;
}


/* =========================================================
   REPORTS
========================================================= */

.report-stats {
    margin-top: 0;
}

.report-chart-card {
    margin-bottom: 20px;
}

.report-chart {
    display: grid;
    min-height: 300px;
    align-items: end;
    grid-template-columns: repeat(12, minmax(35px, 1fr));
    gap: 12px;
    padding: 28px 24px 20px;
    overflow-x: auto;
}

.chart-column {
    display: flex;
    min-width: 38px;
    height: 230px;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.chart-value {
    color: var(--text);
    font-size: 0.62rem;
    font-weight: 900;
}

.chart-bar-wrapper {
    display: flex;
    width: 100%;
    height: 180px;
    align-items: flex-end;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.chart-bar {
    width: min(28px, 70%);
    min-height: 3px;
    border-radius: 7px 7px 2px 2px;
    background:
        linear-gradient(180deg, #2dd4bf, var(--primary));
    transition: height 350ms ease;
}

.chart-label {
    color: var(--text-light);
    font-size: 0.66rem;
    font-weight: 750;
}


/* =========================================================
   BACKUP
========================================================= */

.backup-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.backup-card {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    min-height: 145px;
    padding: 19px;
}

.backup-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    color: var(--primary);
    background: var(--primary-light);
    font-size: 0.9rem;
    font-weight: 900;
}

.backup-card span,
.backup-card h3,
.backup-card p {
    display: block;
}

.backup-card span {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.backup-card h3 {
    margin: 4px 0 7px;
    font-size: 0.9rem;
}

.backup-card p {
    font-size: 0.72rem;
}

.backup-actions-card {
    overflow: hidden;
}

.backup-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    padding: 20px 22px;
}

.backup-action-button {
    display: flex;
    min-height: 92px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 13px;
    text-align: left;
    background: var(--surface-soft);
    transition:
        border-color var(--transition),
        background var(--transition),
        transform var(--transition);
}

.backup-action-button:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.backup-action-button strong {
    margin-bottom: 5px;
    color: var(--text);
    font-size: 0.8rem;
}

.backup-action-button span {
    color: var(--text-light);
    font-size: 0.7rem;
}

.backup-actions-card > .form-message {
    padding: 0 22px 18px;
}


/* =========================================================
   SETTINGS
========================================================= */

.settings-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 20px;
}

.settings-card {
    padding-bottom: 22px;
}

.settings-card form,
.settings-card .system-status-list,
.settings-card > .information-box {
    margin-right: 22px;
    margin-left: 22px;
}

.settings-card form {
    display: grid;
    gap: 17px;
    padding-top: 20px;
}

.system-status-list {
    display: grid;
    padding-top: 10px;
}

.system-status-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.system-status-list span {
    color: var(--text-light);
    font-size: 0.74rem;
}

.system-status-list strong {
    font-size: 0.74rem;
    text-align: right;
}

.pin-settings-card {
    grid-column: 1 / -1;
}

.pin-settings-card form {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    align-items: end;
}

.pin-settings-card .form-message {
    grid-column: 1 / -1;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
}

.toggle-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 42px;
    height: 23px;
    border-radius: 99px;
    background: #cbd5e1;
    transition: background var(--transition);
}

.toggle-slider::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    content: "";
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.2);
    transition: transform var(--transition);
}

.toggle-control input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-control input:checked + .toggle-slider::after {
    transform: translateX(19px);
}

.setting-toggle {
    padding: 12px 0;
}


/* =========================================================
   MODALS
========================================================= */

.modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    max-height: calc(100vh - 40px);
    padding: 24px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: var(--shadow-large);
    animation: modalOpen 180ms ease;
}

.modal-dialog-small {
    width: min(100%, 420px);
    text-align: center;
}

@keyframes modalOpen {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 22px;
    padding-bottom: 17px;
    border-bottom: 1px solid var(--border);
}

.modal-dialog form {
    display: grid;
    gap: 16px;
}

.modal-actions {
    margin-top: 5px;
}

.confirmation-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 17px;
    border-radius: 18px;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 1.5rem;
    font-weight: 900;
}

.modal-dialog-small h2 {
    margin-bottom: 9px;
}

.modal-dialog-small p {
    font-size: 0.83rem;
}

.modal-dialog-small .modal-actions {
    justify-content: center;
    margin-top: 22px;
}


/* =========================================================
   TOASTS
========================================================= */

.toast-container {
    position: fixed;
    z-index: 200;
    top: 20px;
    right: 20px;
    display: grid;
    width: min(360px, calc(100vw - 40px));
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--shadow);
    animation: toastIn 220ms ease;
    pointer-events: auto;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-content {
    flex: 1;
}

.toast-content strong,
.toast-content span {
    display: block;
}

.toast-content strong {
    margin-bottom: 2px;
    font-size: 0.78rem;
}

.toast-content span {
    color: var(--text-light);
    font-size: 0.7rem;
}

.toast-close {
    border: 0;
    color: var(--text-muted);
    background: transparent;
    font-size: 1rem;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(14px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* =========================================================
   PRINT AREA
========================================================= */

.print-area {
    display: none;
}

.print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #111827;
}

.print-header p {
    margin-top: 4px;
}

#printReportSummary {
    margin-bottom: 20px;
}


/* =========================================================
   RESPONSIVE — LARGE TABLETS
========================================================= */

@media (max-width: 1200px) {

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .backup-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .meters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pin-settings-card form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .pin-settings-card form .button {
        grid-column: 1 / -1;
        justify-self: end;
    }

}


/* =========================================================
   RESPONSIVE — TABLETS
========================================================= */

@media (max-width: 950px) {

    :root {
        --sidebar-width: 275px;
    }

    .sidebar {
        transform: translateX(-102%);
        transition: transform 220ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        z-index: 45;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .close-sidebar,
    .mobile-menu {
        display: inline-flex;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .dashboard-grid,
    .reading-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-meter-card,
    .reminder-card {
        min-height: auto;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .pin-settings-card {
        grid-column: auto;
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-button-group {
        align-items: stretch;
    }

    .filter-button-group .button {
        width: 100%;
    }

}


/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 650px) {

    :root {
        --topbar-height: 70px;
    }

    body {
        font-size: 15px;
    }

    .login-screen {
        padding: 14px;
    }

    .login-card {
        padding: 23px 19px;
        border-radius: 21px;
    }

    .login-brand {
        align-items: flex-start;
    }

    .brand-logo {
        width: 50px;
        height: 50px;
        border-radius: 15px;
    }

    .topbar {
        min-height: var(--topbar-height);
        padding: 11px 15px;
    }

    .topbar-right {
        gap: 0;
    }

    .sync-status {
        display: none;
    }

    .topbar-date small {
        display: none;
    }

    .topbar h1 {
        font-size: 1rem;
    }

    .main-content {
        padding: 20px 14px 40px;
    }

    .page-intro {
        align-items: stretch;
        flex-direction: column;
        margin-bottom: 18px;
    }

    .page-intro .button,
    .intro-actions {
        width: 100%;
    }

    .intro-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .backup-grid,
    .meters-grid,
    .form-grid,
    .filter-grid,
    .report-filter-grid,
    .backup-actions,
    .settings-layout,
    .pin-settings-card form {
        grid-template-columns: 1fr;
    }

    .form-group-full,
    .pin-settings-card .form-message,
    .pin-settings-card form .button {
        grid-column: auto;
    }

    .stats-grid {
        gap: 12px;
    }

    .stat-card {
        min-height: 105px;
    }

    .meter-summary-grid {
        grid-template-columns: 1fr;
        padding: 15px;
    }

    .card-header {
        align-items: flex-start;
        padding: 17px;
    }

    .form-card {
        padding: 18px;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .form-actions .button {
        width: 100%;
    }

    .meter-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .backup-actions {
        padding: 16px;
    }

    .settings-card form,
    .settings-card .system-status-list,
    .settings-card > .information-box {
        margin-right: 16px;
        margin-left: 16px;
    }

    .modal {
        padding: 10px;
    }

    .modal-dialog {
        max-height: calc(100vh - 20px);
        padding: 19px;
        border-radius: 18px;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
    }

}


/* =========================================================
   PRINT STYLES
========================================================= */

@media print {

    @page {
        size: A4;
        margin: 15mm;
    }

    body {
        color: #000000;
        background: #ffffff;
    }

    #loginScreen,
    #appShell,
    .modal,
    .toast-container {
        display: none !important;
    }

    .print-area {
        display: block !important;
    }

    .print-area table {
        width: 100%;
        border-collapse: collapse;
    }

    .print-area th,
    .print-area td {
        padding: 9px;
        border: 1px solid #cbd5e1;
        color: #000000;
        font-size: 10pt;
    }

    .print-area th {
        background: #f1f5f9 !important;
        print-color-adjust: exact;
    }

}