:root {
    --ink: #102238;
    --ink-muted: #637184;
    --paper: #f3f5f7;
    --surface: #ffffff;
    --line: #dce2e8;
    --line-soft: #edf0f3;
    --navy: #0d2b45;
    --blue: #1869d5;
    --blue-soft: #e8f1fd;
    --green: #15966a;
    --green-soft: #e8f6f0;
    --amber: #bf7411;
    --radius: 12px;
    color: var(--ink);
    background: var(--paper);
    font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--paper);
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

button,
a,
input {
    outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgb(24 105 213 / 35%);
}

h1:focus {
    outline: none;
}

.eyebrow,
.section-kicker {
    margin: 0;
    color: var(--blue);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 38%);
    border-radius: 50%;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}

/* Login */

.login-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1.18fr) minmax(420px, 0.82fr);
}

.login-brand {
    position: relative;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(2rem, 5vw, 4.5rem);
    color: #fff;
    background: var(--navy);
}

.login-brand::after {
    position: absolute;
    right: -18vw;
    bottom: -42vw;
    width: 72vw;
    height: 72vw;
    border: 1px solid rgb(255 255 255 / 10%);
    border-radius: 50%;
    box-shadow:
        0 0 0 8vw rgb(255 255 255 / 2.5%),
        0 0 0 18vw rgb(255 255 255 / 2%);
    content: "";
}

.login-copy {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: auto 0;
    padding: 8vh 0;
}

.login-copy .eyebrow {
    color: #65a8ff;
}

.login-copy h1 {
    max-width: 680px;
    margin: 1.2rem 0 1.6rem;
    font-size: clamp(3rem, 5.4vw, 6.4rem);
    font-weight: 750;
    letter-spacing: -0.065em;
    line-height: 0.98;
}

.login-copy > p:last-child {
    margin: 0;
    color: #b9c8d8;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    line-height: 1.8;
}

.signal-graphic {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(420px, 70%);
    height: 70px;
    align-items: flex-end;
    gap: 0.7rem;
}

.signal-graphic span {
    display: block;
    width: 2px;
    height: 18px;
    background: #68aaff;
    animation: signal 2.4s ease-in-out infinite;
}

.signal-graphic span:nth-child(2) { height: 38px; animation-delay: 120ms; }
.signal-graphic span:nth-child(3) { height: 62px; animation-delay: 240ms; }
.signal-graphic span:nth-child(4) { height: 34px; animation-delay: 360ms; }
.signal-graphic span:nth-child(5) { height: 48px; animation-delay: 480ms; }

@keyframes signal {
    0%, 100% { opacity: 0.35; transform: scaleY(0.7); transform-origin: bottom; }
    50% { opacity: 1; transform: scaleY(1); transform-origin: bottom; }
}

.login-panel {
    display: grid;
    min-height: 100vh;
    padding: 3rem clamp(2rem, 6vw, 7rem);
    place-items: center;
    background: #fbfcfd;
}

.login-form-wrap {
    width: min(100%, 430px);
    animation: rise 420ms ease-out both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-form-wrap h2 {
    margin: 0.7rem 0 0.6rem;
    font-size: clamp(1.9rem, 3vw, 2.5rem);
    letter-spacing: -0.04em;
}

.form-support {
    margin: 0 0 2.2rem;
    color: var(--ink-muted);
    line-height: 1.65;
}

.login-form-wrap form {
    display: grid;
    gap: 0.7rem;
}

.login-form-wrap label {
    margin-top: 0.65rem;
    color: #34465a;
    font-size: 0.86rem;
    font-weight: 700;
}

.login-form-wrap input {
    width: 100%;
    height: 3.35rem;
    border: 1px solid #ccd5df;
    border-radius: 8px;
    padding: 0 1rem;
    color: var(--ink);
    background: #fff;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form-wrap input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgb(24 105 213 / 10%);
}

.login-form-wrap button {
    height: 3.45rem;
    margin-top: 1.1rem;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--blue);
    font-weight: 800;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.login-form-wrap button:hover {
    background: #0f5dbc;
    transform: translateY(-1px);
}

.form-error {
    margin-bottom: 1rem;
    border-left: 3px solid #d33c3c;
    padding: 0.9rem 1rem;
    color: #9d2626;
    background: #fff1f1;
    font-size: 0.9rem;
}

.security-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.6rem 0 0;
    color: #7b8795;
    font-size: 0.78rem;
}

.security-note span {
    color: var(--green);
    font-size: 0.5rem;
}

/* Dashboard */

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 238px minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    padding: 1.8rem 1.25rem;
    color: #d7e2ec;
    background: var(--navy);
}

.brand-lockup--app {
    margin: 0 0.55rem 3.2rem;
    color: #fff;
}

.app-sidebar nav {
    display: grid;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.9rem;
    border-radius: 7px;
    padding: 0 0.85rem;
    color: #afbdca;
    font-size: 0.9rem;
    text-decoration: none;
}

.nav-item span {
    width: 1.2rem;
    color: #758ba0;
    text-align: center;
}

.nav-item--active {
    color: #fff;
    background: rgb(255 255 255 / 9%);
    font-weight: 700;
}

.nav-item--active span {
    color: #67a9ff;
}

.nav-item--disabled {
    opacity: 0.55;
}

.sidebar-footer {
    display: grid;
    margin-top: auto;
    border-top: 1px solid rgb(255 255 255 / 11%);
    padding: 1.3rem 0.65rem 0;
}

.environment-label {
    margin-bottom: 0.8rem;
    color: #6daaf5;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.sidebar-footer strong {
    color: #fff;
    font-size: 0.85rem;
}

.sidebar-footer > span:not(.environment-label),
.sidebar-footer .authorized > span {
    color: #8397a9;
    font-size: 0.75rem;
}

.logout-button {
    margin-top: 1rem;
    border: 0;
    padding: 0;
    color: #93a6b8;
    background: transparent;
    font-size: 0.78rem;
    cursor: pointer;
}

.logout-button:hover {
    color: #fff;
}

.dashboard {
    min-width: 0;
    padding: 2.35rem clamp(1.3rem, 3vw, 3.5rem) 1.5rem;
}

.dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
}

.dashboard-header h1 {
    margin: 0.35rem 0 0;
    font-size: clamp(1.8rem, 3vw, 2.65rem);
    letter-spacing: -0.045em;
}

.site-meta {
    margin: 0.35rem 0 0;
    color: var(--ink-muted);
    font-size: 0.85rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.demo-badge,
.quality-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    border-radius: 999px;
    padding: 0 0.7rem;
    color: #70510f;
    background: #f7eacb;
    font-size: 0.7rem;
    font-weight: 800;
}

.refresh-button {
    min-height: 2.35rem;
    border: 1px solid #cad3dd;
    border-radius: 7px;
    padding: 0 0.9rem;
    color: #34465a;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.refresh-button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.status-strip {
    display: grid;
    margin: 2rem 0 2.6rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(4, 1fr);
}

.status-strip > div {
    display: grid;
    min-height: 5.2rem;
    align-content: center;
    border-right: 1px solid var(--line);
    padding: 0 1.4rem;
    grid-template-columns: auto 1fr;
    column-gap: 0.55rem;
}

.status-strip > div:last-child {
    border-right: 0;
}

.status-strip span:not(.status-dot) {
    color: var(--ink-muted);
    font-size: 0.7rem;
}

.status-strip strong {
    grid-column: 1 / -1;
    margin-top: 0.3rem;
    font-size: 1rem;
}

.status-strip .status-dot + span + strong {
    grid-column: 2;
}

.status-dot {
    display: inline-block;
    width: 0.52rem;
    height: 0.52rem;
    border-radius: 50%;
}

.status-dot--normal {
    background: var(--green);
    box-shadow: 0 0 0 4px rgb(21 150 106 / 12%);
}

.workspace-grid {
    display: grid;
    align-items: start;
    gap: clamp(2rem, 4vw, 4.2rem);
    grid-template-columns: minmax(0, 1fr) 260px;
}

.primary-workspace {
    display: grid;
    gap: 3rem;
    min-width: 0;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1.15rem;
}

.section-heading h2 {
    margin: 0.28rem 0 0;
    font-size: 1.35rem;
    letter-spacing: -0.035em;
}

.section-heading > span {
    color: var(--ink-muted);
    font-size: 0.72rem;
}

.environment-grid {
    display: grid;
    gap: 1px;
    border: 1px solid var(--line);
    background: var(--line);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-panel {
    padding: 1.35rem 1.45rem 1rem;
    background: var(--surface);
}

.metric-summary {
    display: grid;
    align-items: baseline;
    grid-template-columns: 1fr auto auto;
    column-gap: 0.35rem;
}

.metric-summary > span {
    color: var(--ink-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.metric-summary strong {
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    letter-spacing: -0.055em;
}

.metric-summary small {
    color: var(--ink-muted);
}

.sparkline {
    width: 100%;
    height: 92px;
    margin: 1.2rem 0 0.5rem;
    overflow: visible;
}

.sparkline polyline,
.table-sparkline polyline {
    fill: none;
    stroke: var(--blue);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.sparkline-area {
    fill: rgb(24 105 213 / 7%);
}

.sparkline circle {
    fill: #fff;
    stroke: var(--blue);
    stroke-width: 2;
}

.metric-foot {
    display: flex;
    justify-content: space-between;
    color: #7a8795;
    font-size: 0.68rem;
}

.particle-table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--ink);
}

.particle-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-variant-numeric: tabular-nums;
}

.particle-table th,
.particle-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 0.85rem 1rem;
    text-align: left;
    white-space: nowrap;
}

.particle-table thead th {
    color: var(--ink-muted);
    background: #f8f9fa;
    font-size: 0.67rem;
    font-weight: 700;
}

.particle-table tbody th {
    font-size: 0.82rem;
}

.particle-table td {
    color: #35465a;
    font-size: 0.78rem;
}

.particle-table td strong {
    color: var(--ink);
    font-size: 0.95rem;
}

.particle-table td small {
    color: #83909d;
    font-size: 0.63rem;
}

.table-sparkline {
    display: block;
    width: 150px;
    height: 34px;
}

.quality-badge {
    min-height: 1.5rem;
    color: #12724f;
    background: var(--green-soft);
    font-size: 0.62rem;
}

.device-rail {
    border-left: 1px solid var(--line);
    padding-left: 1.7rem;
}

.section-heading--compact {
    margin-bottom: 0.25rem;
}

.device-item {
    border-bottom: 1px solid var(--line);
    padding: 1.25rem 0;
}

.device-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.device-title strong {
    font-size: 0.88rem;
}

.device-item > p {
    margin: 0.45rem 0 1rem 1.2rem;
    color: var(--ink-muted);
    font-size: 0.74rem;
}

.device-item dl {
    display: grid;
    gap: 0.55rem;
    margin: 0;
}

.device-item dl div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.device-item dt,
.device-item dd {
    margin: 0;
    font-size: 0.68rem;
}

.device-item dt {
    color: #8793a0;
}

.device-item dd {
    color: #3a4c60;
    text-align: right;
}

.rail-note {
    margin-top: 1.6rem;
    border-left: 3px solid var(--amber);
    padding: 0.3rem 0 0.3rem 0.9rem;
}

.rail-note strong {
    font-size: 0.75rem;
}

.rail-note p {
    margin: 0.35rem 0 0;
    color: var(--ink-muted);
    font-size: 0.68rem;
    line-height: 1.6;
}

.dashboard-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    color: #8a95a1;
    font-size: 0.65rem;
}

.loading-state {
    display: grid;
    min-height: 70vh;
    place-items: center;
    color: var(--ink-muted);
}

.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--green);
}

.invalid {
    outline: 1px solid #d23b3b;
}

.validation-message {
    color: #b62626;
}

.blazor-error-boundary {
    padding: 1rem;
    color: #fff;
    background: #a92a2a;
}

.blazor-error-boundary::after {
    content: "오류가 발생했습니다.";
}

@media (max-width: 1080px) {
    .workspace-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .device-rail {
        display: grid;
        border-top: 1px solid var(--line);
        border-left: 0;
        padding-top: 1.5rem;
        padding-left: 0;
        grid-template-columns: repeat(2, 1fr);
        column-gap: 2rem;
    }

    .device-rail .section-heading,
    .device-rail .rail-note {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand {
        min-height: 42vh;
        padding: 1.7rem;
    }

    .login-copy {
        padding: 5rem 0 2rem;
    }

    .login-copy h1 {
        font-size: clamp(2.6rem, 12vw, 4.2rem);
    }

    .signal-graphic {
        display: none;
    }

    .login-panel {
        min-height: 58vh;
        padding: 3.5rem 1.6rem;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: static;
        display: grid;
        width: 100%;
        height: auto;
        padding: 1rem 1.2rem;
        grid-template-columns: auto 1fr;
    }

    .brand-lockup--app {
        margin: 0;
    }

    .app-sidebar nav {
        display: flex;
        justify-content: flex-end;
    }

    .nav-item {
        min-height: 2.5rem;
    }

    .nav-item:not(.nav-item--active) {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .dashboard {
        padding-top: 1.5rem;
    }

    .status-strip {
        grid-template-columns: repeat(2, 1fr);
    }

    .status-strip > div:nth-child(2) {
        border-right: 0;
    }

    .status-strip > div:nth-child(-n+2) {
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 560px) {
    .dashboard-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }

    .environment-grid,
    .device-rail {
        grid-template-columns: 1fr;
    }

    .device-rail .section-heading,
    .device-rail .rail-note {
        grid-column: 1;
    }

    .status-strip > div {
        padding: 0 0.8rem;
    }

    .particle-table th,
    .particle-table td {
        padding: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
