@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sora:wght@600;700&display=swap');

:root {
    --bg: #eef3f9;
    --bg-strong: #d9e7f6;
    --surface: #ffffff;
    --surface-soft: #f7faff;
    --text: #17212f;
    --muted: #5b6a7b;
    --line: #d8e2ee;
    --accent: #0f62d6;
    --accent-strong: #0a4daa;
    --danger: #c4362b;
    --success: #157a47;
    --shadow: 0 20px 45px rgba(10, 42, 82, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    background:
        radial-gradient(circle at 8% -5%, #ffffff 0%, rgba(255, 255, 255, 0) 40%),
        radial-gradient(circle at 95% 0%, #cfe4fa 0%, rgba(207, 228, 250, 0) 42%),
        linear-gradient(170deg, var(--bg) 0%, var(--bg-strong) 100%);
}

.wrap {
    width: 90%;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: rgba(8, 20, 38, 0.84);
    border-bottom: 1px solid rgba(180, 205, 235, 0.25);
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.2rem;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: #082449;
    background: linear-gradient(135deg, #6de2f7 0%, #e2f9ff 100%);
}

.topbar h1 {
    margin: 0;
    color: #f2f7ff;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-size: 1.02rem;
    letter-spacing: 0.01em;
}

.main-nav {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link {
    color: #d2e3ff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.38rem 0.72rem;
    transition: all 0.22s ease;
}

.nav-link:hover {
    color: #ffffff;
    border-color: rgba(159, 193, 241, 0.4);
    background: rgba(89, 132, 196, 0.25);
}

.nav-link.is-active {
    color: #ffffff;
    border-color: rgba(186, 212, 248, 0.6);
    background: rgba(28, 88, 169, 0.62);
}

.nav-link.nav-user {
    border-color: rgba(154, 205, 255, 0.42);
}

main.wrap {
    padding: 1.35rem 0 2.8rem;
}

.page-head {
    margin: 0 0 1rem;
    padding: 1.25rem 1.1rem;
    border-radius: 16px;
    border: 1px solid rgba(137, 173, 220, 0.45);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.86) 0%, rgba(241, 248, 255, 0.9) 100%);
    box-shadow: 0 12px 24px rgba(34, 74, 130, 0.08);
    animation: rise 0.35s ease both;
}

.kicker {
    margin: 0;
    color: #2f6aaf;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 0.72rem;
    font-weight: 800;
}

.page-head h2 {
    margin: 0.3rem 0 0;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-size: clamp(1.28rem, 2vw, 1.68rem);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.1rem 1.08rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    animation: rise 0.45s ease both;
}

.card h2,
.card h3 {
    margin-top: 0;
    margin-bottom: 0.7rem;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    letter-spacing: 0.01em;
}

.card p {
    color: #1f2d3d;
}

.card a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.15em;
}

.card a.button-link,
.card a.button-link:visited,
.button-link,
.button-link:visited {
    color: #ffffff;
    text-decoration: none;
}

.card ul {
    margin: 0.55rem 0 0;
    padding-left: 1.1rem;
}

.card li {
    margin: 0.35rem 0;
    color: #1f2d3d;
}

.auth-card {
    max-width: 500px;
    margin: 1.6rem auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1rem;
}

.detail-filter-card h2 {
    margin-bottom: 0.5rem;
}

.detail-filter-form button {
    margin-top: 1rem;
}

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

.filter-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.6rem 0.8rem;
    margin-top: 0.95rem;
}

.filter-toggle-item {
    display: flex;
    align-items: center;
    gap: 0.48rem;
    padding: 0.45rem 0.58rem;
    border: 1px solid #d5e2f1;
    border-radius: 10px;
    background: #f8fbff;
}

.filter-toggle-item input[type='checkbox'] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #1f6fd1;
}

.filter-toggle-item label {
    margin: 0;
    display: inline-block;
    font-size: 0.83rem;
    font-weight: 700;
    color: #24415f;
}

.detail-hint {
    margin: 0.7rem 0 0;
    font-size: 0.82rem;
    color: #586d84;
}

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

.summary-card h3 {
    margin-bottom: 0.55rem;
}

.summary-main {
    margin: 0;
    color: #103d78;
    font-size: 1.15rem;
    font-weight: 800;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
}

.summary-sub {
    margin: 0.28rem 0 0;
    color: #5a6f85;
    font-size: 0.82rem;
}

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

.metric-card p {
    margin: 0.34rem 0;
    font-weight: 600;
    color: #2a4058;
}

.chart-card h3 {
    margin-bottom: 0.8rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.chart-block {
    border: 1px solid #d8e4f3;
    border-radius: 12px;
    background: #fcfdff;
    padding: 0.68rem;
    min-height: 260px;
}

.chart-block h4 {
    margin: 0 0 0.5rem;
    color: #2a4463;
    font-size: 0.9rem;
}

.chart-block canvas {
    width: 100%;
    height: 220px !important;
}

.device-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.device-title {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
}

.device-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    text-decoration: none;
}

.device-edit-link:hover {
    transform: translateY(-1px);
}

.device-card {
    display: flex;
    flex-direction: column;
}

.device-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.75rem;
}

.device-subline {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.device-readings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.62rem;
    margin-bottom: 0.9rem;
}

.reading-pill {
    border: 1px solid #d7e3f1;
    background: linear-gradient(140deg, #f8fbff 0%, #edf4fd 100%);
    border-radius: 12px;
    padding: 0.62rem 0.6rem;
}

.reading-pill span {
    display: block;
    font-size: 0.74rem;
    font-weight: 700;
    color: #49617f;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.24rem;
}

.reading-pill strong {
    display: block;
    color: #142f55;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-size: 0.98rem;
}

.reading-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
}

.trend-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.35rem;
    padding: 0 0.28rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
}

.trend-up {
    color: #0f5a37;
    background: #e8f8ef;
    border-color: #b5e3c9;
}

.trend-down {
    color: #7c1f2a;
    background: #fdecef;
    border-color: #efc3c9;
}

.trend-neutral {
    color: #33506f;
    background: #eff4fa;
    border-color: #cedbeb;
}

.trend-delta {
    display: block;
    margin-top: 0.25rem;
    color: #4f6784;
    font-size: 0.73rem;
    font-weight: 700;
}

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

.graph-item {
    border: 1px solid #dce7f4;
    border-radius: 11px;
    background: #fcfdff;
    padding: 0.52rem;
}

.graph-item p {
    margin: 0 0 0.38rem;
    font-size: 0.78rem;
    color: #3d5777;
    font-weight: 700;
}

.sparkline {
    display: block;
    width: 100%;
    height: 88px;
}

.graph-note {
    margin: 0.62rem 0 0;
    color: #5f7287;
    font-size: 0.8rem;
}

.device-card-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 0.95rem;
}

.big-number {
    margin: 0;
    font-size: clamp(1.65rem, 3.5vw, 2.3rem);
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    color: #0f4b8f;
}

label {
    display: block;
    margin: 0.82rem 0 0.3rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1f2f44;
}

input,
select,
button {
    font: inherit;
}

input[type='text'],
input[type='password'],
input[type='number'],
select {
    width: 100%;
    border: 1px solid #c5d3e4;
    background: #fbfdff;
    border-radius: 10px;
    padding: 0.62rem 0.72rem;
    color: #142338;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus,
select:focus {
    outline: 0;
    border-color: #74aaf2;
    box-shadow: 0 0 0 4px rgba(103, 161, 239, 0.2);
    background: #ffffff;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.95rem;
    border: 0;
    border-radius: 10px;
    padding: 0.62rem 0.94rem;
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 9px 18px rgba(15, 98, 214, 0.25);
    cursor: pointer;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 12px 22px rgba(15, 98, 214, 0.28);
}

button:active,
.button-link:active {
    transform: translateY(0);
}

.button-small {
    margin-top: 0;
    padding: 0.4rem 0.68rem;
    border-radius: 8px;
    font-size: 0.78rem;
    box-shadow: none;
}

button.danger {
    background: linear-gradient(135deg, #d04538 0%, #a92a20 100%);
    box-shadow: 0 8px 15px rgba(160, 36, 26, 0.25);
}

.inline-form {
    display: inline;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #d7e1ec;
    border-radius: 12px;
    background: #fcfdff;
}

.station-link {
    color: #0e4d99;
    font-weight: 800;
    text-decoration: none;
}

.station-link:hover {
    text-decoration: underline;
}

.station-actions {
    display: flex;
    gap: 0.42rem;
    align-items: center;
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    border-bottom: 1px solid #e0e8f2;
    text-align: left;
    padding: 0.66rem 0.72rem;
    vertical-align: middle;
}

th {
    background: #f3f8ff;
    color: #2f4766;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

tbody tr:nth-child(even) {
    background: #fafcff;
}

tbody tr:hover {
    background: #edf4ff;
}

.alert {
    border-radius: 12px;
    padding: 0.72rem 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-weight: 600;
    animation: rise 0.3s ease both;
}

.alert-success {
    border-color: #b8ebcc;
    background: #e9fcef;
    color: #105933;
}

.alert-error {
    border-color: #f2b7b2;
    background: #feeeec;
    color: #7f2d28;
}

.alert-info {
    border-color: #b6d3f3;
    background: #edf5ff;
    color: #1c4f8d;
}

.token-output code {
    display: block;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    color: #eef7ff;
    background: linear-gradient(150deg, #0e223d 0%, #132f55 100%);
    border-radius: 11px;
    border: 1px solid rgba(151, 194, 248, 0.33);
    padding: 0.78rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.status-active {
    color: #0f5d37;
    background: #dcf7e6;
    border: 1px solid #9ad8b2;
}

.status-inactive {
    color: #7b3d11;
    background: #ffeedf;
    border: 1px solid #f0c79c;
}

.status-offline {
    color: #7a1f27;
    background: #ffe9ec;
    border: 1px solid #f2b8c0;
}

.site-footer {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(122, 157, 200, 0.35);
    background: linear-gradient(180deg, rgba(12, 28, 51, 0.94) 0%, rgba(8, 22, 43, 0.98) 100%);
    color: #eaf3ff;
}

.footer-grid {
    padding: 1rem 0 1.15rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0.8rem;
    align-items: center;
}

.footer-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.footer-title {
    margin: 0;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
    font-size: 0.95rem;
    color: #f6fbff;
}

.footer-line {
    margin: 0;
    color: #b9cde8;
    font-size: 0.82rem;
}

.footer-line strong {
    color: #dff1ff;
}

.footer-stat {
    border: 1px solid rgba(137, 176, 219, 0.3);
    background: rgba(58, 96, 140, 0.24);
    border-radius: 10px;
    padding: 0.58rem 0.7rem;
}

.footer-stat span {
    display: block;
    color: #bcd4f1;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

.footer-stat strong {
    display: block;
    margin-top: 0.22rem;
    font-size: 1.04rem;
    color: #f2f8ff;
    font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
}

.station-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 1rem;
    margin-bottom: 0.8rem;
}

.station-meta-grid p {
    margin: 0;
}

.station-tabs {
    margin-top: 1rem;
}

.station-tab-nav {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.station-tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.58rem 0.9rem;
    border-radius: 999px;
    border: 1px solid #bfd3ec;
    background: #eef5ff;
    color: #1c4f8d;
    font-weight: 800;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.18s ease;
}

.station-tab-link:hover {
    transform: translateY(-1px);
    background: #e4efff;
    color: #113a6c;
}

.station-tab-link.is-active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(15, 98, 214, 0.18);
}

.station-tab-panels {
    min-height: 0;
}

.station-tab-panel {
    margin-bottom: 0;
}

.station-info-panel {
    padding: 0.75rem;
    border: 1px solid #d9e5f3;
    border-radius: 12px;
    background: #f8fbff;
}

.station-latest-reading {
    margin-top: 1rem;
}

.station-latest-reading h4 {
    margin: 0 0 0.55rem;
}

.station-rename-form {
    margin: 0.95rem 0 0.75rem;
    padding: 0.75rem;
    border: 1px solid #d9e5f3;
    border-radius: 12px;
    background: #f8fbff;
}

.station-rename-form label {
    margin-top: 0;
}

.station-ota-form {
    margin: 0 0 0.85rem;
    padding: 0.75rem;
    border: 1px solid #d9e5f3;
    border-radius: 12px;
    background: #f8fbff;
}

.station-ota-form h4 {
    margin: 0 0 0.4rem;
}

.station-ota-form label {
    margin-top: 0.7rem;
}

.station-ota-form .summary-sub {
    margin: 0;
}

.version-log-entry {
    border: 1px solid #dbe6f3;
    border-radius: 12px;
    background: #fbfdff;
    padding: 0.78rem;
    margin-bottom: 0.7rem;
}

.version-log-entry:last-child {
    margin-bottom: 0;
}

.version-log-entry h3 {
    margin: 0 0 0.3rem;
}

.rename-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: center;
}

.station-page-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

code {
    background: #eef4fd;
    color: #13355f;
    border-radius: 6px;
    padding: 0.18rem 0.36rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 0.9em;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 860px) {
    .topbar .wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-link {
        font-size: 0.84rem;
    }

    .auth-card {
        margin-top: 1rem;
    }

    .page-head {
        padding: 1rem 0.88rem;
    }

    .device-readings {
        grid-template-columns: 1fr;
    }

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

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

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

    .detail-summary-grid,
    .detail-metric-grid {
        grid-template-columns: 1fr;
    }

    .station-meta-grid {
        grid-template-columns: 1fr;
    }

    .station-tab-nav {
        flex-direction: column;
    }

    .rename-row {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 520px) {
    .filter-toggle-grid {
        grid-template-columns: 1fr;
    }

    .card {
        border-radius: 14px;
        padding: 0.95rem 0.9rem;
    }

    .brand h1 {
        font-size: 0.95rem;
    }

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