:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #d9dee5;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --soft: #f8fafc;
    --shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
    --ok: #0f766e;
    --bad: #b91c1c;
    --warn: #b45309;
    --font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.brand {
    color: var(--brand);
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3, h4 { margin: 0; letter-spacing: 0; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
nav {
    display: flex;
    gap: 18px;
    align-items: center;
    color: var(--muted);
}
.page { max-width: 1240px; margin: 0 auto; padding: 28px; }
.tabs {
    display: flex;
    gap: 6px;
    margin: 0 0 20px;
    padding: 5px;
    width: fit-content;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e9eef4;
    box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.05);
}
.tab-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    min-width: 126px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #374151;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tab-button:hover {
    background: rgba(255, 255, 255, 0.62);
    color: var(--brand-strong);
}
.tab-button.active {
    color: var(--brand-strong);
    border-color: rgba(15, 118, 110, 0.18);
    background: var(--panel);
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
}
.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.summary div, .channel, .server, .login-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.summary div { padding: 16px; box-shadow: 0 1px 2px rgba(17, 24, 39, 0.03); }
.summary span {
    display: block;
    min-height: 32px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.25;
    margin-bottom: 8px;
}
.summary strong { font-size: 24px; }
.channels { display: grid; gap: 16px; }
.channel {
    padding: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.channel-title {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: baseline;
    margin-bottom: 14px;
}
.channel-title span { color: var(--muted); }
.server-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.server { padding: 16px; }
.server-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.pill {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    background: #eef2f7;
    color: var(--muted);
}
.pill.ok { background: #d1fae5; color: var(--ok); }
.pill.bad { background: #fee2e2; color: var(--bad); }
.pill.warn { background: #fef3c7; color: var(--warn); }
dl {
    display: grid;
    grid-template-columns: minmax(132px, 44%) minmax(0, 1fr);
    gap: 8px 12px;
    margin: 0;
    font-size: 14px;
}
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.viewer-list {
    margin-top: 14px;
    padding: 12px;
    border-top: 1px solid var(--line);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
}
.viewer-list-title {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}
.viewer-list ul {
    max-height: 132px;
    overflow: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}
.viewer-list li {
    padding: 6px 0;
    border-top: 1px solid #e5e9ef;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.viewer-list li:first-child {
    border-top: 0;
    padding-top: 0;
}
.viewer-list p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.history {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.history-standalone {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.history-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
}
.history-head span {
    color: var(--muted);
    font-size: 13px;
}
.history-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.history-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    min-width: 0;
}
.history-card h4,
.incidents h4 {
    margin-bottom: 10px;
}
.history-card dl {
    grid-template-columns: minmax(140px, 46%) minmax(0, 1fr);
}
.incidents {
    margin-top: 14px;
}
.network-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 16px;
}
.network-card {
    min-width: 0;
    overflow: hidden;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}
.network-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 10px;
}
.network-head span {
    color: var(--muted);
    font-size: 13px;
    text-align: right;
    overflow-wrap: anywhere;
}
.chart-frame {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.network-chart {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 3 / 1;
    min-height: 210px;
    max-height: 280px;
    font-family: var(--font);
}
.grid-line {
    stroke: #e2e7ee;
    stroke-width: 1;
}
.axis-label {
    fill: var(--muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
}
.line-in,
.line-out {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.line-in { stroke: #22a35a; }
.line-out { stroke: #d98c25; }
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: #374151;
    font-size: 14px;
    font-weight: 700;
}
.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.chart-legend i {
    display: inline-block;
    width: 12px;
    height: 4px;
    border-radius: 999px;
}
.legend-in { background: #22a35a; }
.legend-out { background: #d98c25; }
.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    font-size: 14px;
}
th, td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    color: var(--muted);
    font-weight: 700;
    background: #f8fafc;
}
tr:last-child td {
    border-bottom: 0;
}
.empty, .error { margin: 12px 0 0; color: var(--muted); }
.error { color: var(--bad); }
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-box {
    width: min(420px, 100%);
    padding: 28px;
}
.login-box h1 { margin: 6px 0 22px; }
label {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--muted);
}
input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 16px;
}
button {
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--bad);
    background: #fee2e2;
}
@media (max-width: 820px) {
    .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .server-grid { grid-template-columns: 1fr; }
    .history-grid { grid-template-columns: 1fr; }
    .network-grid { grid-template-columns: 1fr; }
    .network-head { align-items: flex-start; flex-direction: column; }
    .network-head span { text-align: left; }
    .network-chart { min-height: 170px; }
}
@media (max-width: 520px) {
    .page { padding: 16px; }
    .summary { grid-template-columns: 1fr; }
    dl { grid-template-columns: 1fr; }
    .tabs { width: 100%; }
    .tab-button { flex: 1; min-width: 0; }
    .channel { padding: 14px; }
    .chart-legend { display: grid; gap: 8px; }
}
