* {
    font-family: Arial;
    font-size: 12px;
}

html, body {
    margin: 0;
    padding: 0;
    background: #0b0b0c;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.9375em;
    padding: 1.5em;
    box-sizing: border-box;
}

.server-grid section.server-card {
    background: #111;
    border: 1px solid #262626;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    align-self: start;
}

/* Live = currently the nginx router's default server (see .default-dot) */
.server-grid section.server-card.live {
    background: #0f1a13;
    border-color: #1f3d2a;
}

.server-card.live .card-header {
    background: #07150c;
}

.server-card.live .card-header.clickable-header:hover {
    background: #0c2014;
}

.card-header {
    display: flex;
    align-items: stretch;
    background: #000;
}

.card-header.clickable-header {
    cursor: pointer;
}

.card-header.clickable-header:hover {
    background: #151515;
}

.card-header pre {
    flex: 1;
    background: transparent;
    color: #ffd400;
    font-family: monospace;
    font-size: 13px;
    letter-spacing: 0.3px;
    padding: 0.9em 1.1em;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Server the nginx router currently uses as default (see routing_default in
   /dataStatus) - pulsing dot, green/red by serverIsHealthy() */
.default-dot {
    align-self: center;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    margin-left: 1.1em;
    border-radius: 50%;
    animation: default-pulse 1.8s ease-out infinite;
}

.default-dot.ok {
    background: #2ecc71;
    --pulse-color: rgba(46, 204, 113, 0.7);
}

.default-dot.down {
    background: #e74c3c;
    --pulse-color: rgba(231, 76, 60, 0.7);
}

@keyframes default-pulse {
    0% { box-shadow: 0 0 0 0 var(--pulse-color); }
    70% { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.server-status-icon {
    display: flex;
    align-items: center;
    padding: 0 0 0 1.1em;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.header-ping {
    display: flex;
    align-items: center;
    gap: 0.35em;
    padding: 0 0.9em;
    font-family: monospace;
    font-size: 12px;
    color: #666;
    background: transparent;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
}

.header-ping .ping-emoji,
.header-ping .pending-emoji {
    font-size: 10px;
    line-height: 1;
}

.header-ping.green { color: #2ecc40; }
.header-ping.red,
.header-ping.dead { color: #ff4136; }
.header-ping.yellow { color: #ffb020; }
.header-ping.missing { color: #ff8c1a; }
.header-ping.pending { color: #7f5af0; }
.header-ping.pending .pending-emoji { animation: pulse-pending 1.2s infinite; }

.icon-btn {
    background: transparent;
    border: none;
    border-left: 1px solid #1e1e1e;
    color: #666;
    cursor: pointer;
    padding: 0 1em;
    font-size: 14px;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: #ffd400;
    background: #151515;
}

.server-grid section.server-card.add-card {
    background: transparent;
    border: 1px dashed #333;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    color: #666;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.add-card:hover {
    border-color: #ffd400;
    color: #ffd400;
}

.edit-form {
    padding: 1em 1.1em;
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.edit-form label {
    color: #999;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edit-form input[type=text] {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 0.6em;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 12px;
}

.edit-form input[type=text]:focus {
    outline: none;
    border-color: #ffd400;
}

.edit-form textarea {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 0.6em;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 12px;
    min-height: 60px;
    resize: vertical;
}

.edit-form textarea:focus {
    outline: none;
    border-color: #ffd400;
}

.edit-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4em;
    color: #ccc;
    font-family: monospace;
    font-size: 11px;
    margin-bottom: 0.6em;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}

.form-error {
    color: #ff5c5c;
    font-size: 11px;
    margin: -0.3em 0 0.6em;
}

.edit-actions {
    display: flex;
    gap: 0.5em;
}

.edit-actions button {
    flex: 1;
    border-radius: 4px;
    padding: 8px 6px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-save {
    background: #ffd400;
    color: #000;
    font-weight: bold;
}

.btn-save:hover {
    background: #ffe14d;
}

.btn-save:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-cancel {
    background: #1a1a1a;
    color: #ccc;
    border-color: #333;
}

.btn-cancel:hover {
    background: #222;
}

.btn-delete {
    background: #1a1a1a;
    color: #ff5c5c;
    border-color: rgba(255, 65, 54, 0.35);
}

.btn-delete:hover {
    background: #2a1414;
}

.service-list {
    padding: 0.5em 1em 0.9em;
}

.service-row {
    display: flex;
    flex-direction: row;
    padding: 0.65em 0;
    border-bottom: 1px solid #1e1e1e;
    justify-content: space-between;
    gap: 5px;
}

.service-row.edit-mode {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.6em;
}

.service-row:last-child {
    border-bottom: none;
}

.service-name {
    color: #ddd;
    font-weight: bold;
    text-decoration: none;
    font-size: 12px;
    margin-bottom: 0.55em;
    display: inline-block;
}

.service-name:hover {
    color: #ffd400;
}

.service-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.55em;
}

.service-header .service-name {
    margin-bottom: 0;
}

.icon-btn-sm {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0 0.4em;
    font-size: 12px;
    flex-shrink: 0;
}

.icon-btn-sm:hover {
    color: #ffd400;
}

.add-service-row {
    color: #666;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    padding: 0.5em 0;
    text-align: center;
    border: 1px dashed #262626;
    border-radius: 6px;
    margin-top: 0.5em;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.add-service-row:hover {
    border-color: #ffd400;
    color: #ffd400;
}

.check-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4em;
    margin: 0;
    padding: 0;
    list-style: none;
}

.check-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 999px;
    padding: 0.3em 0.75em;
    font-family: monospace;
    font-size: 11px;
    color: #ccc;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.check-pill:hover {
    background: #222;
}

.check-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #555;
}

.check-pill.green { border-color: rgba(46, 204, 64, 0.35); }
.check-pill.green .dot { background: #2ecc40; }

.check-pill.red .dot,
.check-pill.dead .dot { background: #ff4136; }
.check-pill.red,
.check-pill.dead { border-color: rgba(255, 65, 54, 0.35); }

.check-pill.yellow { border-color: rgba(255, 176, 32, 0.35); }
.check-pill.yellow .dot { background: #ffb020; }

.check-pill.pending { border-color: rgba(127, 90, 240, 0.5); }
.check-pill.pending .dot { background: #7f5af0; animation: pulse-pending 1.2s infinite; }
.check-pill .pending-emoji { margin-left: 0.3em; font-size: 10px; }

@keyframes pulse-pending {
    0% { box-shadow: 0 0 0 0 rgba(127, 90, 240, 0.55); }
    70% { box-shadow: 0 0 0 5px rgba(127, 90, 240, 0); }
    100% { box-shadow: 0 0 0 0 rgba(127, 90, 240, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .check-pill.pending .dot,
    .header-ping.pending .pending-emoji { animation: none; }
}

.sparkline {
    width: 40px;
    height: 14px;
    flex-shrink: 0;
}

.sparkline polyline {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-error-bar {
    fill: #ff4136;
    opacity: 0.85;
}

.action-list-label {
    color: #666;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0.7em 0 0.3em;
}

.action-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5em;
    padding: 0.3em 0;
    color: #999;
    font-family: monospace;
    font-size: 11px;
}

.action-row .edit-form {
    width: 100%;
    padding: 0.5em 0;
}

.action-name {
    flex: 1;
    word-break: break-word;
}

.add-action-row {
    color: #666;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    padding: 0.4em 0;
    text-align: center;
    border: 1px dashed #262626;
    border-radius: 6px;
    margin-top: 0.3em;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.add-action-row:hover {
    border-color: #ffd400;
    color: #ffd400;
}

@media (max-width: 600px) {
    .service-row {
        align-items: flex-start;
    }

    .service-header {
        flex-shrink: 0;
    }

    .check-pill {
        flex-shrink: 0;
    }
}

.incident-banner {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    padding: 1em 1.5em 0;
}

.incident-row {
    display: flex;
    align-items: flex-start;
    gap: 0.8em;
    background: rgba(255, 65, 54, 0.08);
    border: 1px solid rgba(255, 65, 54, 0.35);
    border-left: 3px solid #ff4136;
    border-radius: 8px;
    padding: 0.7em 1em;
    font-family: monospace;
    font-size: 12px;
    color: #ffb0ab;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.incident-row.resolved {
    background: rgba(46, 204, 64, 0.06);
    border-color: rgba(46, 204, 64, 0.3);
    border-left-color: #2ecc40;
    color: #a9c9ae;
}

.incident-icon {
    flex-shrink: 0;
    color: #ff4136;
    padding-top: 0.15em;
}

.incident-row.resolved .incident-icon {
    color: #2ecc40;
}

.incident-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.incident-text strong {
    color: #fff;
}

.incident-row.resolved .incident-text strong {
    color: #d7ecdb;
}

.incident-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
}

.incident-history {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    padding: 1em 1.5em;
}

.incident-history-row {
    color: #666;
    font-family: monospace;
    font-size: 11px;
    padding: 0.4em 1em;
}

.btn-confirm-incident {
    flex-shrink: 0;
    background: #1a1a1a;
    color: #ffb0ab;
    border: 1px solid rgba(255, 65, 54, 0.5);
    border-radius: 4px;
    padding: 0.5em 0.9em;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
}

.btn-confirm-incident:hover {
    background: #2a1414;
    color: #fff;
}

.incident-row.resolved .btn-confirm-incident {
    color: #bfe8c9;
    border-color: rgba(46, 204, 64, 0.5);
}

.incident-row.resolved .btn-confirm-incident:hover {
    background: #142a17;
    color: #fff;
}

.btn-confirm-incident:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-confirm-incident:disabled:hover {
    background: #1a1a1a;
    color: #ffb0ab;
}

.empty-state {
    color: #666;
    font-family: monospace;
    padding: 2em;
    text-align: center;
}

.stale-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    margin: 1em 1.5em 0;
    padding: 0.7em 1em;
    background: rgba(255, 176, 32, 0.08);
    border: 1px solid rgba(255, 176, 32, 0.35);
    border-left: 3px solid #ffb020;
    border-radius: 8px;
    color: #ffd699;
    font-family: monospace;
    font-size: 12px;
}

.btn-retry-stale {
    flex-shrink: 0;
    background: #1a1a1a;
    color: #ffd699;
    border: 1px solid rgba(255, 176, 32, 0.5);
    border-radius: 4px;
    padding: 0.5em 0.9em;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
}

.btn-retry-stale:hover {
    background: #2a2010;
    color: #fff;
}

.btn-retry-stale:disabled {
    opacity: 0.6;
    cursor: default;
}

.retry-spinner {
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    border: 2px solid rgba(255, 214, 153, 0.3);
    border-top-color: #ffd699;
    border-radius: 50%;
    margin-right: 0.4em;
    vertical-align: -0.1em;
    animation: retry-spin 0.6s linear infinite;
}

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

.retry-failed-banner {
    margin: 0.6em 1.5em 0;
    padding: 0.6em 1em;
    background: rgba(255, 65, 54, 0.08);
    border: 1px solid rgba(255, 65, 54, 0.35);
    border-left: 3px solid #ff4136;
    border-radius: 8px;
    color: #ffb0ab;
    font-family: monospace;
    font-size: 12px;
}

.logout-btn {
    background: none;
    border: none;
    color: #555;
    padding: 0.3em 0.5em;
    font-family: monospace;
    font-size: 10px;
    cursor: pointer;
}

.logout-btn:hover {
    color: #ff4136;
}

.edit-mode-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1em;
    padding: 0.5em 1.5em 2em;
}

.edit-mode-btn {
    background: #1a1a1a;
    color: #999;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.5em 1em;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
}

.edit-mode-btn:hover {
    border-color: #ffd400;
    color: #ffd400;
}

.edit-mode-btn.active {
    background: #ffd400;
    color: #000;
    border-color: #ffd400;
    font-weight: bold;
}

.reorder-actions {
    display: flex;
    gap: 0.2em;
}

.server-grid section.login-wrap {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 1em;
    background: radial-gradient(circle at top, #1c1c1c 0%, #000 75%);
    border: none;
}

.login-card {
    width: 300px;
    max-width: 100%;
    background: #111;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 2.5em 2.5em 2em;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    text-align: center;
    font-family: monospace;
    box-sizing: border-box;
}

.login-card h1 {
    color: #ffd400;
    font-size: 18px;
    letter-spacing: 1px;
    margin: 0 0 0.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc40;
    box-shadow: 0 0 0 rgba(46, 204, 64, 0.6);
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 64, 0.55); }
    70% { box-shadow: 0 0 0 6px rgba(46, 204, 64, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 64, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot { animation: none; }
}

.login-card .subtitle {
    color: #888;
    font-size: 11px;
    margin: 0 0 1.8em;
}

.login-card label {
    display: block;
    text-align: left;
    color: #999;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.4em;
}

.login-card input[type=text],
.login-card input[type=password] {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    padding: 10px 12px;
    margin: 0 0 1.3em;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 13px;
}

.login-card input[type=text]:focus,
.login-card input[type=password]:focus {
    outline: none;
    border-color: #ffd400;
}

.login-card input[type=button] {
    width: 100%;
    background: #ffd400;
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 10px 12px;
    font-weight: bold;
    font-size: 13px;
    font-family: monospace;
    cursor: pointer;
    transition: background 0.15s ease;
}

.login-card input[type=button]:hover {
    background: #ffe14d;
}

.login-card input[type=button]:active {
    background: #e6bf00;
}

.login-error {
    color: #ff5c5c;
    font-size: 11px;
    min-height: 1.2em;
    margin: -0.6em 0 1em;
}
