:root {
    color-scheme: light;
    --bg: #eef2f7;
    --card: rgba(255, 255, 255, 0.96);
    --line: #d9e6ef;
    --text: #16324a;
    --muted: #60758a;
    --primary: #0f4c81;
    --primary-strong: #0a3558;
    --secondary: #1f8b8f;
    --danger: #c64242;
    --warning: #c48612;
    --success: #1f8b4d;
    --shadow: 0 16px 40px rgba(15, 36, 58, 0.14);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #f5f7fb 0%, #eef2f7 100%);
    color: var(--text);
}

button,
input {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

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

.screen {
    padding: 14px;
}

.screen-center {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-screen {
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.login-card,
.panel-card,
.well-card,
.detail-card,
.motor-card,
.notification-card,
.summary-card {
    background: var(--card);
    border: 1px solid rgba(217, 230, 239, 0.95);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 460px);
    padding: 22px;
    backdrop-filter: blur(10px);
}

.login-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    padding: 20px 18px 18px;
    border-radius: 20px;
    background:
        linear-gradient(135deg, rgba(15, 76, 129, 0.96), rgba(31, 139, 143, 0.9)),
        #0f4c81;
    color: #fff;
}

.login-hero::after {
    content: "";
    position: absolute;
    inset: auto -18px -26px auto;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.09);
}

.brand-badge,
.eyebrow {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.eyebrow {
    background: rgba(15, 76, 129, 0.08);
    color: var(--primary);
}

.brand-logo {
    width: 72px;
    height: 72px;
    margin: 14px 0 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.14);
    padding: 8px;
}

.login-title {
    margin: 0 0 8px;
    font-size: 1.8rem;
    line-height: 1.08;
}

.login-subtitle {
    margin: 0;
    max-width: 28ch;
    color: rgba(255, 255, 255, 0.86);
    line-height: 1.5;
}

.brand-block h1,
.topbar h2,
.panel-head h3 {
    margin: 6px 0 0;
}

.brand-block p,
.meta-row,
.muted,
.message {
    color: var(--muted);
}

.entry-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 18px;
}

.entry-option {
    text-align: center;
    padding: 12px;
    border-radius: 14px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.entry-option.desktop {
    background: #ffffff;
    color: #0f4c81;
}

.entry-option.mobile.active {
    background: linear-gradient(135deg, #0f4c81, #1f6fb2);
    color: #ffffff;
    border-color: #0f4c81;
}

.install-panel {
    margin-bottom: 18px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #f7fbff 0%, #eef6fb 100%);
    border: 1px solid #dce9f2;
}

.install-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-strong);
}

.install-copy {
    margin: 6px 0 14px;
    color: var(--muted);
    line-height: 1.45;
}

.install-help {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(15, 76, 129, 0.08);
    font-size: 0.92rem;
    line-height: 1.4;
}

.form-message {
    margin: 0;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(198, 66, 66, 0.1);
    color: #a12a2a;
}

.stack-md,
.stack-sm {
    display: grid;
    gap: 14px;
}

.stack-sm {
    gap: 10px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    font-size: 0.92rem;
    font-weight: 600;
}

.field input,
.search-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    background: #fff;
    color: var(--text);
}

.field input:focus,
.search-input:focus {
    outline: 0;
    border-color: rgba(15, 76, 129, 0.5);
    box-shadow: 0 0 0 4px rgba(15, 76, 129, 0.08);
}

.btn,
.icon-btn,
.tab {
    border: 0;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover,
.icon-btn:hover,
.tab:hover {
    transform: translateY(-1px);
}

.btn {
    padding: 13px 16px;
    font-weight: 700;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 76, 129, 0.18);
}

.btn-success {
    background: linear-gradient(135deg, #1f8b4d 0%, #166534 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(31, 139, 77, 0.18);
}

.btn-light {
    background: #edf3f9;
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-compact {
    padding: 11px 14px;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.icon-btn {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #e4ebf3;
    box-shadow: 0 8px 22px rgba(15, 36, 58, 0.08);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tabbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.tab {
    padding: 10px 8px;
    background: #fff;
    color: var(--muted);
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(14, 42, 74, 0.06);
}

.tab.active {
    background: var(--primary);
    color: #fff;
}

.toolbar {
    margin-bottom: 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.summary-card,
.notification-card,
.well-card,
.detail-card,
.motor-card {
    padding: 16px;
}

.summary-card {
    position: relative;
    overflow: hidden;
}

.summary-card::after {
    content: ";
    position: absolute;
    right: -24px;
    bottom: -28px;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: rgba(15, 76, 129, 0.06);
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.card-list,
.detail-wrap {
    display: grid;
    gap: 12px;
}

.well-head,
.panel-head,
.motor-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.well-title {
    margin: 0;
    font-size: 1.05rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-success {
    background: rgba(31, 139, 77, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(196, 134, 18, 0.14);
    color: var(--warning);
}

.badge-danger {
    background: rgba(198, 66, 66, 0.12);
    color: var(--danger);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.meta-item {
    padding: 12px;
    border-radius: 16px;
    background: #f7fafd;
    border: 1px solid #e4edf5;
}

.meta-item span {
    display: block;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.well-actions,
.motor-actions {
    display: flex;
    gap: 10px;
}

.well-actions .btn,
.motor-actions .btn {
    flex: 1;
}

.tab-panel[hidden] {
    display: none;
}

.detail-header {
    margin-bottom: 14px;
}

.profile-box {
    padding: 14px;
    border-radius: 18px;
    background: #f7fafd;
    border: 1px solid #e4edf5;
    margin-bottom: 14px;
}

.profile-box p {
    margin: 0 0 10px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(26px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    min-width: 220px;
    max-width: calc(100vw - 32px);
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(11, 27, 45, 0.92);
    color: #fff;
    box-shadow: var(--shadow);
    z-index: 999;
}

@media (max-width: 520px) {
    .screen {
        padding: 14px;
    }

    .login-card {
        padding: 16px;
    }

    .login-hero {
        padding: 18px 16px 16px;
    }

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

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn-compact {
        flex: 1;
    }

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

    .well-actions,
    .motor-actions {
        flex-direction: column;
    }
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 1050;
    border-top: 1px solid #dee2e6;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6c757d;
    font-size: 12px;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    min-width: 0;
}

.bottom-nav-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.bottom-nav-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

.bottom-nav-item span {
    font-size: 11px;
    line-height: 1.1;
}

.bottom-nav-item.active {
    color: #007bff;
}

.bottom-nav-item.active .bottom-nav-icon svg {
    color: #007bff;
}

.bottom-nav-item:hover {
    color: #0056b3;
    text-decoration: none;
}

.main-with-bottom-nav {
    padding-bottom: 65px !important;
}

@media (max-width: 420px) {
    .bottom-nav-icon,
    .bottom-nav-icon svg {
        width: 20px;
        height: 20px;
    }

    .bottom-nav-item span {
        font-size: 10px;
    }
}
