:root {
    --bg: #0f1117;
    --surface: #171a23;
    --border: #2a2e3a;
    --text: #e6e8ee;
    --muted: #8b90a0;
    --accent: #4f8cff;
    --accent-hover: #3a72e8;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
}

nav a:hover {
    color: var(--accent);
    background: #1c2433;
}

/* Everything that belongs on the right-hand side of the nav. A single
   margin-left:auto here rather than on individual items: the Stop & Reset
   button used to carry it, so with debug actions off (prod) nothing pushed
   right and the welcome/logout block sat jammed against the nav links. */
.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stop-button {
    background: transparent;
    border: 1px solid #ff5f5f;
    color: #ff5f5f;
}

.stop-button:hover {
    background: #ff5f5f;
    color: #fff;
}

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

main.home-layout {
    max-width: 1400px;
}

.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 1.5rem;
    align-items: start;
}

.home-main {
    min-width: 0;
}

.home-chat h2 {
    margin: 0 0 0.75rem;
}

.home-chat .log-chat {
    height: 75vh;
}

.home-chat-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.82rem;
}

.log-controls-label {
    font-weight: 600;
    color: var(--text);
}

@media (max-width: 960px) {
    .home-grid {
        grid-template-columns: 1fr;
    }

    .home-chat .log-chat {
        height: 50vh;
    }
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
}

h2 {
    font-size: 1.15rem;
    margin: 2rem 0 0.75rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

thead {
    background: #1c2029;
}

th,
td {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #1c2029;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

form {
    display: inline;
}

button {
    font: inherit;
    font-size: 0.85rem;
    border: none;
    border-radius: var(--radius);
    padding: 0.35rem 0.8rem;
    color: #fff;
    background: var(--accent);
    cursor: pointer;
    transition: background 0.15s ease;
}

button:hover {
    background: var(--accent-hover);
}

td button + button {
    margin-left: 0.4rem;
}

ul {
    padding-left: 1.2rem;
    margin: 0.5rem 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.log-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.log-status {
    font-size: 0.85rem;
    color: var(--muted);
}

.log-status.live {
    color: #4caf50;
}

.log-status.down {
    color: #ff5f5f;
}

.log-chat {
    height: 70vh;
    overflow: hidden;
    /*overflow-y: auto;*/
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.8rem;
}

.log-line {
    padding: 0.1rem 0;
    margin-bottom: 0.35rem;
}

.log-msg {
    white-space: pre-wrap;
    word-break: break-word;
}

.log-ts {
    color: var(--muted);
    margin-right: 0.5rem;
}

.log-who {
    font-weight: 700;
    margin-right: 0.5rem;
}

.log-level {
    margin-right: 0.5rem;
    font-weight: 600;
}

.log-line.level-debug .log-level {
    color: #56c9d6;
}

.log-line.level-info .log-level {
    color: #5ad16a;
}

.log-line.level-warning .log-level,
.log-line.level-warn .log-level {
    color: #e0a94f;
}

.log-line.level-error .log-level,
.log-line.level-critical .log-level {
    color: #ff5f5f;
}

.data-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.data-tabs a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.data-tabs a.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--accent);
}

.data-table-scroll {
    overflow-x: auto;
}

.data-error {
    color: red;
}
