:root {
    --navy-900: #0c2d62;
    --navy-800: #123c7a;
    --navy-700: #1a4f9f;
    --grey-50: #f7f9fc;
    --grey-100: #eef2f6;
    --grey-200: #d9e1ea;
    --grey-500: #6b7785;
    --grey-700: #374556;
    --white: #ffffff;
    --success: #2bb673;
    --danger: #d64b4b;
    --shadow: 0 20px 50px rgba(12, 45, 98, 0.14);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--grey-700);
    background:
        radial-gradient(circle at top left, rgba(26, 79, 159, 0.16), transparent 30%),
        linear-gradient(135deg, #eef3f8 0%, #f8fafc 55%, #edf2f7 100%);
}

.hidden {
    display: none !important;
}

.login-body {
    min-height: 100vh;
    overflow: hidden;
}

.splash-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #071834 0%, #0c2d62 60%, #184d9c 100%);
    z-index: 5;
    animation: fadeOut 0.7s ease 2.8s forwards;
}

.splash-mark {
    width: 18px;
    height: 18px;
    position: absolute;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    filter: blur(1px);
    animation: pulseMark 1.6s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.splash-content {
    position: relative;
    text-align: center;
    color: var(--white);
}

.splash-logo {
    width: min(190px, 44vw);
    display: block;
    margin: 0 auto 1.5rem;
    border-radius: 12px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
    opacity: 0;
    transform-origin: center center;
    transform: translateY(0) scale(0.01);
    animation: logoFirstReveal 1.25s cubic-bezier(0.18, 0.88, 0.2, 1.02) 0.12s forwards;
}

.splash-text {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    animation: revealText 0.8s ease 1.2s forwards;
}

.splash-title {
    margin: 0;
    font-size: clamp(2.6rem, 7vw, 5rem);
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.splash-tagline {
    margin-top: 0.9rem;
    font-size: 1.1rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.82);
}

@keyframes pulseMark {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    70% {
        transform: scale(18);
        opacity: 0.35;
    }
    100% {
        transform: scale(26);
        opacity: 0;
    }
}

@keyframes logoFirstReveal {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.01);
    }
    45% {
        opacity: 0.95;
        transform: translateY(0) scale(0.28);
    }
    72% {
        opacity: 1;
        transform: translateY(0) scale(1.16);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes revealText {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card,
.panel,
.metric-tile {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(12, 45, 98, 0.08);
    box-shadow: var(--shadow);
}

.demo-credentials span,
.status-pill {
    padding: 0.65rem 0.95rem;
    border-radius: 999px;
    background: var(--grey-100);
    color: var(--navy-800);
    font-size: 0.9rem;
}

.login-card {
    width: min(420px, 100%);
    border-radius: 28px;
    padding: 2.2rem;
    display: grid;
    gap: 1rem;
}

.eyebrow {
    margin: 0;
    color: #000000;
    font-size: 0.89rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.muted {
    color: var(--grey-500);
    margin-top: 0.5rem;
}

.field {
    display: grid;
    gap: 0.45rem;
}

.field span {
    font-size: 0.95rem;
    color: var(--grey-700);
    font-weight: 600;
}

.field input {
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-sm);
    padding: 0.95rem 1rem;
    font-size: 1rem;
    background: var(--grey-50);
}

.field input:focus {
    outline: 2px solid rgba(26, 79, 159, 0.16);
    border-color: var(--navy-700);
}

.primary-button,
.ghost-button,
.menu-item,
.secondary-button,
.ghost-inline-button,
.table-button {
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.primary-button {
    padding: 0.95rem 1rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
}

.primary-button:hover,
.ghost-button:hover,
.menu-item:hover,
.secondary-button:hover,
.ghost-inline-button:hover,
.table-button:hover {
    transform: translateY(-1px);
}

.secondary-button,
.ghost-inline-button {
    padding: 0.95rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--grey-100);
    color: var(--navy-900);
    font-size: 1rem;
    font-weight: 600;
}

.ghost-inline-button {
    padding: 0.75rem 1rem;
}

.error-text {
    min-height: 1.25rem;
    margin: 0;
    color: var(--danger);
}

.demo-credentials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    color: var(--grey-500);
}

.demo-credentials p {
    width: 100%;
    margin: 0.2rem 0 0;
    color: var(--grey-700);
    font-weight: 700;
}

.app-body {
    min-height: 100vh;
}

.standalone-body {
    padding: 1.5rem;
    height: 100vh;
    overflow: hidden;
    background: #C0CEF7;
}

.standalone-shell {
    height: calc(100vh - 3rem);
    overflow: hidden;
}

.standalone-customer-panel {
    height: 100%;
    overflow: hidden;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 196px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #09214a 0%, #0e316a 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.1rem 0.95rem;
}

.sidebar-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.sidebar-logo {
    width: 100%;
    max-width: 150px;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.brand-dot,
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #6dc5ff;
    box-shadow: 0 0 18px rgba(109, 197, 255, 0.7);
}

.sidebar-brand h1,
.panel h3,
.topbar h2 {
    margin: 0;
}

.topbar h2 {
    color: #000000;
    font-size: 2.1rem;
}

.sidebar-brand p,
.sidebar-footer span {
    margin: 0.2rem 0 0;
    color: rgba(255, 255, 255, 0.7);
}

.menu {
    display: grid;
    gap: 0.6rem;
}

.menu-item {
    text-align: left;
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    background: transparent;
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.96rem;
}

.menu-item.active {
    background: var(--white);
    color: var(--navy-900);
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(7, 24, 52, 0.18);
}

.sidebar-footer {
    display: grid;
    gap: 0.8rem;
    padding-top: 1rem;
}

.sidebar-user {
    margin: 0;
    font-weight: 700;
}

.ghost-button {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
}

.content {
    padding: 2rem;
    display: grid;
    gap: 1.5rem;
    background: #C0CEF7;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.9rem;
    margin-left: auto;
}

.clock-card {
    min-width: 142px;
    padding: 0.4rem 0.7rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(12, 45, 98, 0.06);
    box-shadow: 0 8px 18px rgba(12, 45, 98, 0.1);
    text-align: right;
}

.live-clock {
    color: var(--navy-900);
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.live-date {
    margin-top: 0.1rem;
    color: var(--grey-500);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-tile {
    border-radius: var(--radius-lg);
    padding: 1.3rem;
    background: #133490;
    border: 1px solid rgba(19, 52, 144, 0.18);
}

.metric-tile span {
    display: block;
    color: rgba(255, 255, 255, 0.82);
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.metric-tile h3 {
    color: var(--white);
    font-size: 1.7rem;
    margin: 0;
}

.panel {
    border-radius: 28px;
    padding: 1.4rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.chart-panel {
    min-height: 380px;
    background: #C0C0C0;
}

.chart-title {
    font-size: 1.35rem;
}

.dashboard-chart-filters {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.dashboard-filter-input {
    min-width: 180px;
    height: 40px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--grey-200);
    border-radius: 10px;
    background: var(--grey-50);
    color: var(--grey-700);
    font-size: 0.92rem;
}

.dashboard-year-input {
    min-width: 110px;
}

.dashboard-filter-button {
    padding: 0.5rem 0.8rem;
    min-height: 40px;
}

.energy-chart {
    display: grid;
    gap: 0.9rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--grey-500);
    font-size: 0.92rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 999px;
}

.legend-swatch {
    display: inline-block;
    flex: 0 0 auto;
}

.legend-swatch.solar-bar {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--navy-700);
}

.legend-swatch.load-line {
    position: relative;
    width: 18px;
    height: 12px;
}

.legend-swatch.load-line::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 5px;
    height: 2px;
    background: var(--grey-500);
}

.legend-swatch.load-line::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 6px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--grey-500);
    box-shadow: 0 0 0 2px rgba(107, 119, 133, 0.18);
}

.legend-dot.solar {
    background: var(--navy-700);
}

.legend-dot.load {
    background: var(--grey-500);
}

.chart-canvas {
    width: 100%;
    height: 320px;
    display: block;
}

.chart-empty {
    min-height: 320px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(26, 79, 159, 0.06), rgba(107, 119, 133, 0.05));
    color: var(--grey-500);
    font-weight: 600;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

#dashboard-view.view.active {
    background: #97AFF2;
    border-radius: 24px;
    padding: 1rem;
}

#customers-view.view.active {
    height: calc(100vh - 168px);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid var(--grey-100);
    font-size: 0.95rem;
}

th {
    color: var(--grey-500);
    font-weight: 700;
    white-space: nowrap;
}

.customers-grid-table th,
.customers-grid-table td {
    min-width: 120px;
    vertical-align: top;
}

.customer-registry-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
    overflow: hidden;
}

.customer-registry-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding-bottom: 0.35rem;
    background: #97AFF2;
    backdrop-filter: blur(8px);
    border-radius: 18px 18px 0 0;
    padding: 0.5rem 0.5rem 0.35rem;
}

.customer-registry-topbar-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.customer-registry-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.customer-registry-logo {
    width: 132px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(12, 45, 98, 0.12);
}

.customer-registry-title {
    margin: 0;
    color: var(--navy-900);
    font-size: 1.15rem;
    font-weight: 700;
}

.customer-registry-actions {
    margin-bottom: 0;
}

.customer-table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: auto;
    border: 1px solid rgba(12, 45, 98, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
}

.customers-grid-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.customers-grid-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #103CC1;
    color: #E7EDFD;
}

.customers-grid-table th,
.customers-grid-table td {
    background: rgba(255, 255, 255, 0.98);
    white-space: nowrap;
}

.customer-sticky-col {
    position: sticky;
    z-index: 4;
    background: rgba(255, 255, 255, 0.99);
}

.customers-grid-table thead .customer-sticky-col {
    z-index: 7;
    background: #103CC1;
}

.customer-col-no {
    left: 0;
    min-width: 146px;
    width: 146px;
    max-width: 146px;
    box-shadow: 8px 0 18px rgba(12, 45, 98, 0.06);
}

.customer-col-name {
    left: 146px;
    min-width: 220px;
    width: 220px;
    max-width: 220px;
    box-shadow: 8px 0 18px rgba(12, 45, 98, 0.06);
}

.customer-col-address {
    min-width: 200px;
    width: 200px;
    max-width: 200px;
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.35;
}

.customer-action-button {
    white-space: nowrap;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-button {
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    background: var(--navy-700);
    color: var(--white);
    font-size: 0.88rem;
    font-weight: 600;
}

.table-button.secondary {
    background: var(--grey-100);
    color: var(--navy-900);
}

.table-button.danger {
    background: var(--danger);
    color: var(--white);
}

.customer-link-button {
    padding: 0;
    border: none;
    background: transparent;
    color: var(--navy-700);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

.customer-link-button:hover {
    color: var(--navy-900);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-badge.is-active {
    background: rgba(43, 182, 115, 0.12);
    color: #14824f;
}

.status-badge.is-inactive {
    background: rgba(214, 75, 75, 0.12);
    color: #b03636;
}

.muted-inline {
    color: var(--grey-500);
    white-space: nowrap;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.report-workspace {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1rem;
}

.report-menu-panel {
    align-self: start;
}

.report-menu {
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
}

.report-menu-item {
    width: 100%;
    text-align: left;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(12, 45, 98, 0.08);
    border-radius: 14px;
    background: var(--grey-50);
    color: var(--navy-900);
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.report-menu-item:hover {
    transform: translateY(-1px);
}

.report-menu-item.active {
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
    color: var(--white);
    box-shadow: 0 10px 24px rgba(12, 45, 98, 0.18);
}

.report-content {
    display: none;
}

.report-content.active {
    display: block;
}

.report-filter-form {
    display: grid;
    grid-template-columns: minmax(320px, 1.5fr) minmax(180px, 0.55fr) minmax(180px, 0.55fr) auto;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.report-field select {
    min-height: 220px;
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.95rem;
    background: var(--grey-50);
}

.report-field input {
    min-height: 52px;
}

.field-hint {
    color: var(--grey-500);
    font-size: 0.83rem;
}

.report-actions {
    display: flex;
    align-items: flex-end;
    min-height: 100%;
}

.report-table-wrapper {
    margin-top: 0.75rem;
}

.report-modal-card {
    width: min(1180px, 100%);
}

.report-modal-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.report-table th,
.report-table td {
    white-space: nowrap;
}

.report-placeholder-cell {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--grey-500);
    font-weight: 600;
}

.report-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.8rem;
}

.report-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 16px;
    background: var(--grey-50);
}

.settings-panel {
    display: grid;
    gap: 0.9rem;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--grey-100);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 24, 52, 0.48);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    width: min(1100px, 100%);
    max-height: calc(100vh - 3rem);
    overflow: auto;
    border-radius: 28px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 22px 60px rgba(7, 24, 52, 0.2);
}

.user-modal-card {
    width: min(760px, 100%);
}

.preview-modal-card {
    width: min(92vw, 1100px);
    max-height: calc(100vh - 2.5rem);
    background: #0a0f17;
    color: var(--white);
}

.preview-chart-shell {
    display: grid;
    gap: 1rem;
}

.preview-chart-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    color: rgba(255, 255, 255, 0.92);
    font-size: 1rem;
}

.preview-chart-frame {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #05070b;
    max-height: calc(100vh - 220px);
}

.preview-chart-svg {
    width: 100%;
    height: min(68vh, 620px);
    display: block;
}

.modal-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.98);
    padding-bottom: 0.5rem;
    z-index: 1;
}

.customer-form {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.field-wide {
    grid-column: span 2;
}

.toggle-field select {
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-sm);
    padding: 0.95rem 1rem;
    font-size: 1rem;
    background: var(--grey-50);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

@media (max-width: 1080px) {
    .tile-grid,
    .report-grid,
    .report-workspace {
        grid-template-columns: 1fr;
    }

    .report-filter-form {
        grid-template-columns: minmax(260px, 1fr) repeat(2, minmax(170px, 0.75fr));
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 1rem;
    }

    .menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content {
        padding: 1rem;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    #customers-view.view.active {
        height: auto;
    }

    .dashboard-chart-filters {
        width: 100%;
        justify-content: flex-start;
    }

    .customer-registry-topbar-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-filter-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .menu {
        grid-template-columns: 1fr;
    }

    .tile-grid {
        grid-template-columns: 1fr;
    }

    .login-card,
    .panel,
    .metric-tile {
        border-radius: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: span 1;
    }

    .modal-actions,
    .table-actions {
        flex-direction: column;
    }

    .topbar-right {
        flex-direction: column;
        align-items: stretch;
    }

    .clock-card {
        text-align: center;
    }

    .customer-col-no,
    .customer-col-name {
        position: static;
        min-width: 120px;
        width: auto;
        max-width: none;
        box-shadow: none;
    }
}
