:root {
    --bg-main: #eef3f9;
    --bg-accent: #dbe7f7;
    --ink-900: #101820;
    --ink-700: #314254;
    --ink-500: #65758a;
    --line: #d7e0eb;
    --card: #ffffff;
    --primary: #0d4a7d;
    --primary-soft: #e2edf9;
    --ok: #0f9f6f;
    --danger: #d64a38;
    --warning: #be7b09;
    --shadow: 0 10px 28px rgba(17, 35, 53, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "SUIT", sans-serif;
    color: var(--ink-900);
    background:
        radial-gradient(40rem 20rem at 16% 8%, #ffffff 0%, rgba(255, 255, 255, 0) 70%),
        radial-gradient(28rem 20rem at 88% 6%, #c9daef 0%, rgba(201, 218, 239, 0) 68%),
        linear-gradient(170deg, var(--bg-main) 0%, var(--bg-accent) 100%);
}

.ambient {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(13, 74, 125, 0.05), rgba(15, 159, 111, 0.04));
}

.shell {
    width: min(450px, calc(100vw - 24px));
    margin: 20px auto;
    position: relative;
    z-index: 1;
}

.device-frame {
    border-radius: 34px;
    border: 1px solid #b7c6d7;
    overflow: hidden;
    background: #f7fbff;
    box-shadow: 0 18px 40px rgba(24, 45, 67, 0.2), 0 2px 0 #fff inset;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--ink-500);
    background: linear-gradient(180deg, #fdfefe 0%, #f0f6fd 100%);
    border-bottom: 1px solid var(--line);
    font-weight: 700;
}

.hero {
    padding: 18px 18px 12px;
    background: linear-gradient(160deg, #ffffff 0%, #eef5fc 100%);
    border-bottom: 1px solid var(--line);
}

.hero-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.eyebrow {
    margin: 0;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    color: var(--ink-500);
    font-weight: 700;
}

.title {
    margin: 4px 0 0;
    font-family: "Black Han Sans", sans-serif;
    font-size: 1.56rem;
    letter-spacing: 0.3px;
}

.hero-pill {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.68rem;
    color: #08365d;
    border: 1px solid #9fc0de;
    background: #dbeafa;
    font-weight: 800;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--ink-700);
    font-size: 0.89rem;
    line-height: 1.4;
}

.app-content {
    padding: 14px 14px 8px;
    min-height: 62vh;
}

.section {
    display: none;
    animation: card-up 280ms ease;
}

.section.active {
    display: block;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    padding: 14px;
    box-shadow: var(--shadow);
}

.panel h3 {
    margin: 0 0 10px;
    color: #15334f;
    font-size: 1rem;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 11px;
    font-size: 0.77rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.status-chip.live {
    background: rgba(15, 159, 111, 0.15);
    color: #0d6f4e;
    border: 1px solid rgba(15, 159, 111, 0.35);
}

.status-chip.stop {
    background: rgba(214, 74, 56, 0.11);
    color: #8a2b1f;
    border: 1px solid rgba(214, 74, 56, 0.26);
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

label {
    font-size: 0.86rem;
    color: var(--ink-700);
    font-weight: 700;
}

select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #b7c8db;
    background: #f7fbff;
    color: var(--ink-900);
    padding: 10px;
    font-size: 0.92rem;
    outline: none;
}

select:focus {
    border-color: #6a9bc8;
    box-shadow: 0 0 0 3px rgba(106, 155, 200, 0.18);
}

.btn {
    border: none;
    border-radius: 11px;
    padding: 10px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    transition: transform 140ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.btn.start {
    background: linear-gradient(180deg, #17b883 0%, #0f9f6f 100%);
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(15, 159, 111, 0.28);
}

.btn.stop {
    background: linear-gradient(180deg, #ea6657 0%, #d64a38 100%);
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(214, 74, 56, 0.24);
}

.btn.secondary {
    grid-column: 1 / -1;
    background: #edf3fa;
    color: #34516d;
    border: 1px solid #c9d7e5;
    box-shadow: 0 4px 10px rgba(31, 60, 87, 0.1);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: saturate(1.05);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.log-note {
    margin-top: 10px;
    background: #f4f9ff;
    border: 1px solid #c9dff5;
    border-radius: 11px;
    padding: 10px;
    font-size: 0.86rem;
    line-height: 1.4;
    color: #2a4d6f;
}

.tiny {
    font-size: 0.76rem;
    color: var(--ink-500);
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric {
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 10px;
    background: #fbfdff;
}

.metric .label {
    font-size: 0.75rem;
    color: var(--ink-500);
}

.metric .value {
    margin-top: 4px;
    font-size: 0.96rem;
    font-weight: 800;
    color: #143652;
    line-height: 1.22;
}

.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.report-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.report-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    transform: translateY(8px);
    opacity: 0;
    animation: card-up 360ms ease forwards;
}

.report-card h4 {
    margin: 0 0 7px;
    font-size: 0.94rem;
    color: #183c5c;
}

.report-line {
    margin: 3px 0;
    font-size: 0.84rem;
    line-height: 1.35;
    color: #3a5167;
}

.insight-list {
    display: grid;
    gap: 8px;
}

.insight {
    border-radius: 12px;
    padding: 10px;
    border: 1px solid #cfdeea;
    background: #f8fcff;
    color: #27445f;
    font-size: 0.86rem;
    line-height: 1.4;
}

.insight.warn {
    border-color: #f2d29a;
    background: #fff6e6;
    color: #7d4e05;
}

.insight.danger {
    border-color: #edb4ad;
    background: #fff1ef;
    color: #7d2519;
}

.nav {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid var(--line);
    background: rgba(249, 252, 255, 0.95);
    backdrop-filter: blur(8px);
}

.tab-btn {
    border: 1px solid #c8d6e6;
    background: #ffffff;
    color: #4d667e;
    border-radius: 12px;
    padding: 8px 6px;
    cursor: pointer;
    font-size: 0.77rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform 140ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.tab-btn .nav-icon {
    color: #8ca8c4;
    font-size: 0.48rem;
}

.tab-btn.active {
    background: #134d81;
    border-color: #134d81;
    color: #ffffff;
    box-shadow: 0 8px 14px rgba(19, 77, 129, 0.28);
}

.tab-btn.active .nav-icon {
    color: #9fd4ff;
}

@media (max-width: 560px) {
    body {
        min-height: 100dvh;
        overflow: hidden;
    }

    .shell {
        width: 100vw;
        margin: 0;
        height: 100dvh;
    }

    .device-frame {
        height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, #f8fcff 0%, #f1f7ff 100%);
    }

    .status-bar {
        display: none;
    }

    .hero {
        padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px 9px;
        box-shadow: 0 8px 20px rgba(23, 56, 84, 0.07);
    }

    .eyebrow {
        font-size: 0.66rem;
    }

    .title {
        margin-top: 2px;
        font-size: 1.24rem;
        letter-spacing: 0.02em;
    }

    .hero-pill {
        padding: 4px 8px;
        font-size: 0.62rem;
    }

    .subtitle {
        display: none;
    }

    .app-content {
        flex: 1;
        min-height: 0;
        padding: 9px 8px 6px;
        overflow: hidden;
    }

    .section,
    .section.active,
    .grid {
        height: 100%;
    }

    .grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 0.46fr) minmax(0, 0.54fr);
        gap: 9px;
    }

    .control-panel,
    .telemetry-panel {
        min-height: 0;
        overflow: hidden;
    }

    .control-panel {
        background: linear-gradient(175deg, #ffffff 0%, #f7fbff 100%);
    }

    .telemetry-panel {
        background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
    }

    .panel {
        padding: 9px;
        border-radius: 14px;
        box-shadow: 0 8px 20px rgba(17, 35, 53, 0.13);
    }

    .panel h3 {
        margin-bottom: 7px;
        font-size: 0.89rem;
    }

    .status-chip {
        margin-bottom: 6px;
        padding: 4px 8px;
        font-size: 0.68rem;
    }

    .input-row {
        gap: 4px;
        margin-bottom: 7px;
    }

    label,
    select,
    .btn,
    .log-note,
    .insight,
    .report-line {
        font-size: 0.75rem;
    }

    select {
        padding: 9px 10px;
        min-height: 40px;
        border-radius: 11px;
    }

    .btn-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .btn {
        min-height: 40px;
        padding: 9px 5px;
        border-radius: 10px;
        font-size: 0.77rem;
        line-height: 1.15;
    }

    .btn.secondary {
        grid-column: auto;
    }

    .log-note {
        margin-top: 5px;
        padding: 7px;
        line-height: 1.25;
        max-height: 36px;
        overflow: hidden;
    }

    .tiny {
        display: block;
        margin-top: 5px;
        font-size: 0.63rem;
        line-height: 1.25;
        color: #6b7d91;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .metrics {
        height: calc(100% - 30px);
        gap: 5px;
        align-content: stretch;
    }

    .metric {
        padding: 6px 5px;
        border-radius: 10px;
        background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
    }

    .metric .label {
        font-size: 0.62rem;
        letter-spacing: 0.01em;
    }

    .metric .value {
        margin-top: 2px;
        font-size: 0.74rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav {
        position: static;
        margin: 0 6px 6px;
        border: 1px solid #d1ddeb;
        border-radius: 14px;
        box-shadow: 0 8px 20px rgba(18, 41, 62, 0.12);
        padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
        gap: 6px;
        background: rgba(250, 253, 255, 0.96);
    }

    .tab-btn {
        padding: 8px 4px;
        font-size: 0.7rem;
        gap: 3px;
        min-height: 46px;
    }

    .tab-btn .nav-icon {
        font-size: 0.45rem;
    }
}

@keyframes card-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@media (min-width: 920px) {
    .shell {
        width: min(980px, calc(100vw - 40px));
    }

    .device-frame {
        display: grid;
        grid-template-columns: 1fr 260px;
        grid-template-rows: auto auto 1fr;
        border-radius: 26px;
    }

    .status-bar,
    .hero,
    .app-content {
        grid-column: 1 / 2;
    }

    .nav {
        position: static;
        grid-column: 2 / 3;
        grid-row: 1 / 4;
        border-top: none;
        border-left: 1px solid var(--line);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 10px;
        padding: 16px;
        background: #f5faff;
    }

    .tab-btn {
        flex-direction: row;
        justify-content: flex-start;
        padding: 11px;
        font-size: 0.9rem;
    }

    .tab-btn .nav-icon {
        font-size: 0.62rem;
        margin-right: 3px;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

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