* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #1a1a2e;
    --card: #16213e;
    --card-border: #0f3460;
    --accent: #0f3460;
    --accent-light: #1a4a8a;
    --green: #00d97e;
    --red: #e63946;
    --yellow: #ffc107;
    --text: #e0e0e0;
    --text-dim: #8899aa;
    --text-bright: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 16px;
}

/* Check form */
.check-form {
    display: flex;
    gap: 12px;
}

.check-form input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.check-form input:focus {
    border-color: var(--accent-light);
}

.check-form input::placeholder {
    color: var(--text-dim);
}

.btn {
    padding: 12px 24px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: var(--text-bright);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-light); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.check-result {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    display: none;
    font-size: 0.9rem;
}

.check-result.online {
    display: block;
    background: rgba(0, 217, 126, 0.1);
    border: 1px solid var(--green);
    color: var(--green);
}

.check-result.offline {
    display: block;
    background: rgba(230, 57, 70, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
}

.check-result .server-info {
    color: var(--text-dim);
    margin-top: 4px;
    font-size: 0.85rem;
}

/* Summary bar */
.summary {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.summary-item .label { color: var(--text-dim); }
.summary-item .value { font-weight: 700; color: var(--text-bright); }
.summary-item .value.green { color: var(--green); }
.summary-item .value.red { color: var(--red); }

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
}

col.col-name    { width: 7%; }
col.col-server  { width: 28%; }
col.col-status  { width: 10%; }
col.col-ping    { width: 8%; }
col.col-history { width: 47%; }

thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-dim);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

thead th:hover { color: var(--text-bright); }
thead th .sort-arrow { margin-left: 4px; font-size: 0.7rem; }

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover { background: rgba(15, 52, 96, 0.3); }

/* Group header row */
tr.group-header {
    cursor: pointer;
}

tr.group-header td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(15, 52, 96, 0.2);
    font-size: 0.85rem;
}

tr.group-header:hover td { background: rgba(15, 52, 96, 0.35); }

.group-chevron {
    font-size: 0.7rem;
    color: var(--text-dim);
}

tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(15, 52, 96, 0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody td:last-child {
    white-space: normal;
    overflow: visible;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.online {
    background: rgba(0, 217, 126, 0.15);
    color: var(--green);
}

.status-badge.offline {
    background: rgba(230, 57, 70, 0.15);
    color: var(--red);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

/* Check dots */
.check-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.check-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: default;
    position: relative;
}

.check-dot.on { background: var(--green); }
.check-dot.off { background: var(--red); }

.check-dot-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #0d1b2a;
    border: 1px solid var(--card-border);
    color: var(--text);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

.check-dot:hover .check-dot-tooltip {
    display: block;
}

.dots-toggle {
    margin-left: 4px;
    font-size: 0.7rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.dots-toggle:hover { color: var(--text-bright); }

.check-dots.expanded {
    flex-wrap: wrap;
    max-width: 280px;
}

.check-dots.expanded .check-dot {
    width: 6px;
    height: 6px;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-dim);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

.update-info {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 12px;
}

/* Filter */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar input {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    width: 220px;
}

.filter-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover, .filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-bright);
}

@media (max-width: 768px) {
    body { padding: 8px; }
    .card { padding: 14px; }
    .check-form { flex-direction: column; }
    .summary { gap: 8px; font-size: 0.82rem; }
    .filter-bar input { width: 100%; }

    table { table-layout: auto; font-size: 0.78rem; }
    col.col-name   { width: auto; }
    col.col-server { width: 0; }
    col.col-status { width: auto; }
    col.col-ping   { width: auto; }
    col.col-history { width: auto; }

    /* Hide server column on mobile */
    thead th:nth-child(2),
    tbody td:nth-child(2) { display: none; }

    thead th, tbody td { padding: 6px 4px; }

    /* Compact status badge */
    .status-badge { padding: 2px 6px; font-size: 0.7rem; gap: 4px; }
    .status-dot { width: 6px; height: 6px; }

    /* Smaller dots */
    .check-dots { gap: 2px; }
    .check-dot { width: 7px; height: 7px; }
    .check-dots.expanded .check-dot { width: 5px; height: 5px; }
    .dots-toggle { font-size: 0.65rem; }

    /* Group header: hide status/ping, name spans full width with dots */
    .gh-status, .gh-ping { display: none; }
    .gh-name { font-size: 0.82rem; }
    .group-chevron { font-size: 0.6rem; }
}
