:root {
    --bg: #f2f5f7;
    --panel: #fff;
    --ink: #17252d;
    --muted: #65727c;
    --line: #dce4e8;
    --brand: #087d87;
    --brand-dark: #075f68;
    --brand-soft: #e1f3f4;
    --warn: #b97800;
    --danger: #b9352f;
    --success: #157347;
    --shadow: 0 18px 48px rgba(26, 55, 69, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Noto Sans KR", "Segoe UI", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 10% 0%, #e0f3f3 0, transparent 32%), var(--bg);
}

button, input { font: inherit; }
.layout { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 56px; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-icon { width: 58px; height: 58px; filter: drop-shadow(0 10px 20px rgba(8, 125, 135, .2)); }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1; letter-spacing: -.04em; }
.subtitle, .section-description { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.hero-actions { display: flex; align-items: center; gap: 12px; }

.panel { padding: 22px; margin-top: 18px; background: rgba(255, 255, 255, .94); border: 1px solid rgba(23, 37, 45, .08); border-radius: 20px; box-shadow: var(--shadow); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h2 { margin: 0; font-size: 1.15rem; }
.device-count { display: inline-grid; place-items: center; min-width: 25px; height: 25px; margin-left: 5px; padding: 0 7px; color: var(--brand-dark); background: var(--brand-soft); border-radius: 99px; font-size: .72rem; vertical-align: 2px; }
h3 { margin: 22px 0 10px; font-size: .82rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

.ws-indicator { color: var(--warn); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.ws-indicator.connected { color: var(--success); }
.ws-indicator.disconnected { color: var(--danger); }

.devices-list { display: grid; gap: 10px; }
.device-card { overflow: hidden; background: #fbfcfd; border: 1px solid var(--line); border-radius: 15px; transition: border-color .2s, box-shadow .2s; }
.device-card[open] { border-color: rgba(8, 125, 135, .38); box-shadow: 0 10px 30px rgba(21, 66, 76, .08); }
.device-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; cursor: pointer; list-style: none; user-select: none; }
.device-header::-webkit-details-marker, .activity-summary::-webkit-details-marker { display: none; }
.device-header:hover { background: var(--brand-soft); }
.device-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.device-identity > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.device-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; color: white; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); border-radius: 11px; font-size: .78rem; font-weight: 800; }
.device-name { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.device-user { margin-top: 3px; color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-side { display: flex; align-items: center; gap: 12px; }
.chevron { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.device-card[open] .chevron { transform: rotate(225deg); }

.status { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 99px; color: white; font-size: .67rem; font-weight: 800; text-transform: uppercase; }
.status.online { background: var(--success); }
.status.warning { background: var(--warn); }
.device-body { padding: 18px; border-top: 1px solid var(--line); }
.device-info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.info-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.info-label { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.info-value { overflow-wrap: anywhere; font-size: .8rem; font-weight: 650; }

.connections { display: grid; gap: 9px; }
.connection-row { padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.connection-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: .74rem; }
.connection-type { padding: 3px 7px; color: var(--brand-dark); background: var(--brand-soft); border-radius: 6px; font-size: .65rem; font-weight: 800; }
.copy-line { display: flex; align-items: center; gap: 8px; }
.copy-line code { flex: 1; min-width: 0; padding: 9px 11px; overflow-x: auto; color: #21404a; background: #f2f6f7; border-radius: 8px; font-family: "SFMono-Regular", Consolas, monospace; font-size: .76rem; white-space: nowrap; }

.btn { padding: 7px 13px; border: 0; border-radius: 8px; cursor: pointer; font-size: .77rem; font-weight: 750; transition: opacity .15s, transform .15s; }
.btn:hover { opacity: .86; transform: translateY(-1px); }
.btn:disabled { cursor: wait; opacity: .55; }
.btn-primary { color: white; background: var(--brand); }
.btn-secondary { color: var(--ink); background: white; border: 1px solid var(--line); }
.btn-copy { flex: 0 0 auto; color: var(--brand-dark); background: var(--brand-soft); }

.activity-panel { padding: 0; overflow: hidden; }
.activity-summary { padding: 18px 22px; cursor: pointer; font-size: .92rem; font-weight: 750; list-style: none; }
.activity-summary::after { content: "+"; float: right; color: var(--muted); }
.activity-panel[open] .activity-summary::after { content: "−"; }
.activity-content { padding: 0 22px 22px; }
.tab-group { display: inline-flex; gap: 3px; margin-bottom: 10px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; }
.tab { padding: 5px 12px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: .72rem; font-weight: 700; }
.tab.active { color: white; background: var(--brand); }
.log-container { max-height: 360px; padding: 4px; overflow-y: auto; background: #fbfcfd; border: 1px solid var(--line); border-radius: 11px; }
.log-entry { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: 7px; }
.log-time { min-width: 72px; color: var(--muted); font-family: Consolas, monospace; font-size: .68rem; }
.log-level { padding: 2px 6px; border-radius: 4px; font-size: .62rem; font-weight: 800; }
.log-level-INFO { color: var(--brand); background: var(--brand-soft); }
.log-level-WARN { color: var(--warn); background: #fff4dd; }
.log-level-ERROR { color: var(--danger); background: #fde8e7; }
.log-level-CONFLICT { color: #6d42ad; background: #f0e8fc; }
.log-message { flex: 1; color: var(--muted); font-size: .76rem; }
.empty-state, .empty-log { padding: 30px; color: var(--muted); text-align: center; }
.port-empty { padding: 16px; color: var(--muted); text-align: center; font-size: .8rem; }

.login-page { display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 410px); }
.login-card { display: flex; flex-direction: column; padding: 34px; background: white; border: 1px solid rgba(23, 37, 45, .08); border-radius: 22px; box-shadow: var(--shadow); }
.login-icon { width: 52px; height: 52px; margin-bottom: 20px; }
.login-card h1 { font-size: 2rem; }
.login-description { margin: 10px 0 26px; color: var(--muted); font-size: .88rem; }
.login-card label { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: .74rem; font-weight: 700; }
.login-card input { width: 100%; padding: 12px 13px; color: var(--ink); background: #fbfcfd; border: 1px solid var(--line); border-radius: 9px; outline: 0; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 125, 135, .12); }
.login-card .remember-option { display: flex; align-items: center; gap: 8px; margin-top: 16px; cursor: pointer; user-select: none; }
.login-card .remember-option input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--brand); box-shadow: none; }
.login-card .remember-option span { color: var(--ink); font-size: .78rem; font-weight: 600; }
.login-error { min-height: 20px; margin: 12px 0 2px; color: var(--danger); font-size: .76rem; }
.login-submit { width: 100%; padding: 11px; }

@media (max-width: 760px) {
    .layout { width: min(100% - 20px, 1040px); padding-top: 22px; }
    .hero, .section-head { align-items: flex-start; flex-direction: column; }
    .hero-actions { width: 100%; justify-content: space-between; }
    .device-info-grid { grid-template-columns: 1fr 1fr; }
    .copy-line { align-items: stretch; flex-direction: column; }
    .btn-copy { align-self: flex-end; }
}

@media (max-width: 430px) {
    .panel { padding: 16px; border-radius: 16px; }
    .brand-icon { width: 48px; height: 48px; }
    .device-header { padding: 13px; }
    .device-info-grid { grid-template-columns: 1fr; }
    .status { display: none; }
    .login-card { padding: 26px; }
}
