:root {
    font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
    color: #eaf2ff;
    background: #07101d;
    font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 0%, #14335a 0, transparent 30rem), #07101d; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
    min-height: 88px;
    padding: 18px clamp(18px, 4vw, 58px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid #29405e;
    background: rgba(7, 16, 29, .86);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.eyebrow, .section-heading span { margin: 0 0 4px; color: #77a9e8; font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(21px, 3vw, 30px); }
h2 { margin-bottom: 0; font-size: 18px; }
nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button, nav a {
    border: 1px solid #355476;
    border-radius: 9px;
    padding: 9px 13px;
    color: #eaf2ff;
    background: #12243a;
    cursor: pointer;
}
button:hover, nav a:hover { border-color: #65a7f4; background: #183454; }

.connection { display: inline-flex; align-items: center; gap: 7px; color: #9eb1c7; font-size: 13px; }
.connection::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 12px currentColor; }
.connection.online { color: #53dfad; }
.connection.error { color: #ff6f7d; }

main { width: min(1500px, calc(100% - 28px)); margin: 22px auto 50px; }
.panel { border: 1px solid #223c59; border-radius: 15px; background: rgba(11, 25, 42, .92); box-shadow: 0 18px 45px rgba(0, 0, 0, .2); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 12px; }
.history-summary { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.summary-card { padding: 17px; border: 1px solid #243f5e; border-radius: 13px; background: linear-gradient(145deg, #10263f, #0a192b); }
.summary-card span { color: #8fa8c4; font-size: 12px; }
.summary-card strong { display: block; margin-top: 7px; font-size: 27px; }
.summary-card.danger strong { color: #ff7180; }

.toolbar { padding: 14px; display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.toolbar div { min-width: 160px; }
.toolbar .search-box { flex: 1; }
label { display: block; margin-bottom: 5px; color: #91a8c2; font-size: 12px; }
select, input { width: 100%; min-height: 39px; border: 1px solid #294865; border-radius: 9px; padding: 8px 10px; color: #eaf2ff; background: #09192b; }
.toolbar p { margin: 0 0 10px auto; color: #728aa4; font-size: 12px; white-space: nowrap; }

.content-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 12px; }
.server-panel, .elevator-panel, .alert-panel { padding: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.count { min-width: 31px; padding: 5px 8px; border-radius: 99px; text-align: center; color: #bcd9ff !important; background: #173a5f; }
.count.danger { color: #ffd4d7 !important; background: #5b2530; }

.server-list { display: grid; gap: 8px; max-height: 650px; overflow: auto; }
.server-card { width: 100%; padding: 8px; text-align: left; border: 1px solid #274664; border-radius: 9px; background: #0b1d31; }
.server-card.active { border-color: #5aa9ff; background: #113153; }
.server-select { width: 100%; padding: 4px; text-align: left; border: 0; background: transparent; }
.server-select:hover { border-color: transparent; background: rgba(81, 151, 225, .1); }
.server-select strong, .server-select small { display: block; }
.server-select small { margin-top: 5px; color: #8199b4; }
.join-server { display: block; margin-top: 7px; padding: 7px 9px; border: 1px solid #2f755e; border-radius: 7px; text-align: center; color: #77e4b8; background: #103529; font-size: 12px; font-weight: 700; }
.join-server:hover { border-color: #5ce6b0; background: #164b39; }
.online-dot, .offline-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
.online-dot { background: #4dd9a6; box-shadow: 0 0 8px #4dd9a6; }
.offline-dot { background: #78869a; }

.elevator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 650px; overflow: auto; }
.elevator-card { min-height: 190px; padding: 14px; border: 1px solid #27435f; border-radius: 12px; background: #091b2e; }
.elevator-card.fault { border-color: #a43f4d; background: linear-gradient(145deg, #321827, #101928); }
.elevator-card.alarm { animation: alarm 1s infinite alternate; }
.elevator-head { display: flex; justify-content: space-between; gap: 10px; }
.elevator-head strong { overflow-wrap: anywhere; }
.elevator-head > div { min-width: 0; }
.elevator-id { display: block; width: fit-content; margin-top: 5px; color: #69b7ff; font-size: 12px; font-weight: 700; }
.elevator-id:hover { color: #b6dcff; text-decoration: underline; }
.mode { padding: 3px 7px; border-radius: 99px; color: #a7cfff; background: #173653; font-size: 11px; height: fit-content; }
.floor-row { display: flex; align-items: baseline; gap: 8px; margin: 19px 0; }
.floor-row .floor { font-size: 39px; font-weight: 900; line-height: 1; }
.direction { color: #63b4ff; font-size: 24px; }
.state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; color: #91a7bf; font-size: 12px; }
.fault-text { margin: 10px 0 0; color: #ff8d98; font-size: 12px; overflow-wrap: anywhere; }

.history-panel, .alert-panel, .online-history-panel { margin-top: 12px; padding: 16px; }
.online-history-panel .event-list { max-height: 460px; }
.history-list { display: grid; gap: 8px; }
.history-item { display: grid; grid-template-columns: minmax(240px, 1fr) repeat(3, auto); align-items: center; gap: 16px; padding: 11px 12px; border: 1px solid #29425d; border-radius: 10px; background: #0a192a; color: #91a7bf; font-size: 12px; }
.history-item strong, .history-item small { display: block; }
.history-item strong { color: #eaf2ff; font-size: 13px; }
.history-item small { margin-top: 4px; color: #657d97; overflow-wrap: anywhere; }
.history-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 12px; }
.event-panel { padding: 16px; }
.event-list { display: grid; gap: 9px; max-height: 720px; overflow: auto; }
.event-item { padding: 13px; border: 1px solid #3d4257; border-left: 4px solid #6a7892; border-radius: 10px; background: #0a192a; }
.event-item.critical { border-left-color: #ff6473; background: linear-gradient(145deg, #2d1721, #0a192a); }
.event-item.alarm { border-left-color: #ffae46; background: linear-gradient(145deg, #2c2112, #0a192a); }
.event-item.resolved { border-left-color: #52d9a5; }
.event-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.event-heading strong { font-size: 15px; }
.event-heading a { display: block; margin-top: 5px; color: #69b7ff; font-size: 12px; font-weight: 700; }
.event-heading time { color: #8199b4; font-size: 12px; white-space: nowrap; }
.event-item p { margin: 9px 0 0; color: #a6b8cb; font-size: 13px; }
.event-item .event-reason { color: #eef5ff; }
.event-meta { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 10px; color: #728ba6; font-size: 11px; }
.alert-list { display: grid; gap: 9px; }
.alert-item { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px; border: 1px solid #4c3444; border-radius: 11px; background: #201523; }
.alert-item time, .alert-item small { color: #9c8d9b; font-size: 12px; }
.alert-actions { display: flex; gap: 7px; }
.alert-actions button { padding: 7px 10px; }
.empty { min-height: 100px; display: grid; place-items: center; color: #7188a2; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 10px; color: white; background: #244a70; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #8d3240; }

@keyframes alarm { from { box-shadow: 0 0 0 rgba(255, 65, 84, 0); } to { box-shadow: 0 0 24px rgba(255, 65, 84, .55); } }
@media (max-width: 900px) {
    .topbar { position: static; align-items: flex-start; flex-direction: column; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar p { margin: 0; }
    .content-grid { grid-template-columns: 1fr; }
    .history-layout { grid-template-columns: 1fr; }
    .server-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); max-height: none; }
    .alert-item { grid-template-columns: 1fr; }
    .history-item { grid-template-columns: 1fr; gap: 6px; }
    .history-summary { grid-template-columns: repeat(2, 1fr); }
    .event-heading { flex-direction: column; }
}
