:root {
    --blue-950: #0b1f4d;
    --blue-900: #0f2f6f;
    --blue-800: #16428f;
    --blue-600: #2563eb;
    --blue-100: #dbeafe;
    --slate-950: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --white: #ffffff;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --shadow: 0 18px 45px rgba(15, 23, 42, .10);
    --radius-lg: 24px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #eef4ff 100%);
    color: var(--slate-950);
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
.btn {
    border: 0;
    border-radius: 12px;
    padding: 11px 16px;
    background: var(--blue-600);
    color: var(--white);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .22);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover,
.btn:hover {
    filter: brightness(.96);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger {
    background: #dc2626;
}

.btn-secondary {
    background: #64748b;
}

label {
    display: block;
    margin: 12px 0 6px;
    color: var(--slate-700);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: var(--white);
    color: var(--slate-950);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.login-page {
    overflow: hidden;
}

.login-shell,
.app-shell,
.app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
}

.brand-panel {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    padding: 34px;
    color: var(--white);
    background:
        radial-gradient(circle at 18% 18%, rgba(96, 165, 250, .55), transparent 28%),
        radial-gradient(circle at 85% 78%, rgba(37, 99, 235, .40), transparent 26%),
        linear-gradient(160deg, var(--blue-950), var(--blue-800));
}

.brand-panel::after {
    content: "";
    position: absolute;
    inset: auto -80px -90px auto;
    width: 260px;
    height: 260px;
    border-radius: 999px;
    border: 36px solid rgba(255, 255, 255, .08);
}

.brand-content {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: calc(100vh - 68px);
    flex-direction: column;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .24);
    font-size: 30px;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}

.customer-logo {
    max-width: 54px;
    max-height: 54px;
    object-fit: contain;
}

.brand-name,
.brand-system {
    display: block;
    line-height: .95;
}

.brand-name {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: -1.2px;
}

.brand-system {
    margin-top: 5px;
    color: #bfdbfe;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
}

.brand-text {
    max-width: 270px;
    margin: 28px 0 0;
    color: #dbeafe;
    font-size: 15px;
    line-height: 1.65;
}

.brand-badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: auto;
}

.brand-badges span {
    padding: 8px 11px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 999px;
    background: rgba(255,255,255,.10);
    color: #eff6ff;
    font-size: 12px;
    font-weight: 700;
}

.login-main {
    display: grid;
    place-items: center;
    padding: 48px;
}

.login-card {
    width: min(430px, 100%);
    padding: 38px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, .9);
}

.login-card h1 {
    margin: 6px 0 8px;
    font-size: 38px;
    letter-spacing: -1px;
}

.login-form button {
    width: 100%;
    margin-top: 18px;
}

.app-brand-panel {
    position: sticky;
    top: 0;
    align-self: start;
}

.app-main {
    min-width: 0;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 92px;
    padding: 20px 30px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
}

.topbar-title {
    min-width: 0;
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 26px;
    letter-spacing: -.5px;
}

.eyebrow {
    color: var(--blue-600);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 30px;
    background: rgba(255, 255, 255, .76);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
}

.topnav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 999px;
    color: var(--slate-700);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.topnav a:hover {
    background: var(--slate-100);
    color: var(--blue-600);
}

.topnav .nav-logout {
    margin-left: auto;
    color: #b91c1c;
    background: #fff1f2;
}

.user-pill {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 118px;
    padding: 9px 13px;
    border-radius: 16px;
    background: var(--slate-100);
    color: var(--slate-500);
    font-size: 12px;
}

.user-pill strong {
    color: var(--slate-950);
    font-size: 13px;
}

.content {
    min-width: 0;
    padding: 28px 30px;
}

.card {
    margin-bottom: 24px;
    padding: 24px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, .95);
    border: 1px solid rgba(226, 232, 240, .9);
    box-shadow: var(--shadow);
}

.card h2 {
    margin-top: 0;
    margin-bottom: 18px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0 0 6px;
}

.page-header p {
    margin: 0;
    color: var(--slate-500);
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

.checkbox-row {
    display: flex;
    gap: 24px;
    align-items: center;
    min-height: 42px;
    margin-top: 10px;
}

.checkbox-row-wrapper {
    justify-content: flex-end;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 14px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead th {
    background: #1e3a8a;
    color: #ffffff;
    padding: 14px 16px;
    text-align: center;
    font-weight: 700;
    border-bottom: 2px solid #dbeafe;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    text-align: center;
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.data-table tbody tr:hover {
    background: #dbeafe;
    transition: background .15s ease;
}

.compact-table td,
.compact-table th {
    padding-top: 8px;
    padding-bottom: 8px;
}

.number-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.date-badge {
    background: #2563eb;
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
}

.readings-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 14px;
}

.readings-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 4200px;
    width: max-content;
    font-size: 14px;
}

.readings-table th,
.readings-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    white-space: nowrap;
    vertical-align: middle;
}

.readings-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #ffffff !important;
    box-shadow: 6px 0 12px rgba(15, 23, 42, .08);
}

.readings-table thead .sticky-col {
    z-index: 20;
    background: #f8fafc !important;
}

.point-col {
    min-width: 280px;
    width: 280px;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all .2s ease;
}

body.sidebar-collapsed .point-col {
    min-width: 520px;
    width: 520px;
    max-width: 520px;
}

.summary-col {
    min-width: 130px;
    background: #f1f5f9 !important;
}

.today-header,
.today-cell,
.today-input-col {
    background: #eff6ff !important;
}

.today-input-col {
    min-width: 150px;
}

.save-col {
    min-width: 90px;
    text-align: center;
}

.reading-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.reading-input-wrap .reading-input {
    width: 62px;
    min-width: 62px;
    max-width: 62px;
    margin: 0;
}

.reading-input-wrap .reading-unit {
    display: inline-block;
    min-width: auto;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.reading-input {
    padding: 1px 1px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    width: 42px !important;
    min-width: 42px;
    max-width: 42px;
    flex: 0 0 42 px;
}

.reading-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.reading-unit {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    min-width: 32px;
}

.ftp-locked {
    color: #64748b;
    font-weight: 700;
    text-align: center;
    background: #f1f5f9 !important;
}

.sidebar-toggle {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 99999;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: #ffffff;
    color: #1e3a8a;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .22);
}

.sidebar-toggle:hover {
    background: #eff6ff;
}

body.sidebar-collapsed .brand-panel,
body.sidebar-collapsed .app-brand-panel {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    overflow: hidden !important;
}

body.sidebar-collapsed .app-layout {
    display: block !important;
    grid-template-columns: none !important;
}

body.sidebar-collapsed .app-main {
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
}

body.sidebar-collapsed .content {
    width: 100% !important;
    max-width: none !important;
}

table.report-table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 6px !important;
    font-size: 14px !important;
}

table.report-table th {
    background: #1d4ed8 !important;
    color: #ffffff !important;
    padding: 16px 22px !important;
    text-align: center !important;
}

table.report-table td {
    background: #ffffff !important;
    padding: 15px 22px !important;
    text-align: center !important;
    border-bottom: none !important;
}

table.report-table tbody tr:nth-child(even) td {
    background: #eff6ff !important;
}

table.report-table tbody tr:nth-child(odd) td {
    background: #ffffff !important;
}

table.report-table tbody tr:hover td {
    background: #dbeafe !important;
}

table.report-table .number-cell {
    text-align: center !important;
    font-weight: 700 !important;
}

@media (max-width: 1100px) {
    .login-shell,
    .app-layout {
        grid-template-columns: 280px minmax(0, 1fr);
    }

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

    .user-pill {
        width: 100%;
    }

    .topnav .nav-logout {
        margin-left: 0;
    }

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

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

    .brand-panel {
        min-height: auto;
        padding: 24px;
    }

    .app-brand-panel {
        position: relative;
    }

    .brand-content {
        min-height: auto;
    }

    .brand-badges {
        margin-top: 22px;
    }

    .login-main,
    .content {
        padding: 20px;
    }

    .login-card {
        padding: 26px;
    }

    .topbar,
    .topnav {
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media screen and (max-width: 1024px) {
    .readings-table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .readings-scroll {
        overflow-x: hidden !important;
    }

    .readings-table .summary-col,
    .readings-table .history-col {
        display: none !important;
    }

    .readings-table .mobile-visible-history {
        display: table-cell !important;
    }

    .readings-table .point-col {
        min-width: 180px !important;
        width: 180px !important;
        max-width: 180px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .readings-table .today-input-col {
        min-width: 120px !important;
        width: 120px !important;
    }

    .readings-table .save-col {
        min-width: 75px !important;
        width: 75px !important;
    }

    .reading-input {
        width: 62px !important;
        min-width: 62px;
        max-width: 62px;
        flex: 0 0 62 px;
    }
}
