:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e8f0;
    --error: #dc2626;
    --success: #059669;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

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

.wrap { max-width: none; width: 100%; margin: 0 auto; padding: 16px 20px 24px; box-sizing: border-box; }

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.nav-brand:hover {
    color: var(--text);
    text-decoration: none;
}

.nav-brand img {
    display: block;
    border-radius: 999px;
    object-fit: cover;
}

.home-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.home-hero__logo {
    width: 96px;
    height: 96px;
    border-radius: 999px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    background: #fff;
}

.home-hero h1 {
    margin: 0 0 4px;
}

.home-hero__lead {
    margin: 0;
}

.login-logo {
    display: block;
    width: 88px;
    height: 88px;
    margin: 0 auto 16px;
    border-radius: 999px;
    object-fit: cover;
    background: #fff;
}

.nav strong { margin-right: 8px; }

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

table { width: 100%; border-collapse: collapse; }

th {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

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

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 14px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    border: none;
    width: auto;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.muted { color: var(--muted); }
.error { color: var(--error); margin-bottom: 12px; }
.success { color: var(--success); margin-bottom: 12px; }

label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.field { margin-bottom: 12px; }

.inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline input[type=checkbox] { width: auto; }

code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid var(--border);
}

h1 { margin: 0 0 16px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 0 0 12px; font-size: 16px; }

/* Login page (centered) */
.page-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.page-login .card {
    width: min(420px, 92vw);
    padding: 28px;
}

.page-login h1 { font-size: 22px; margin-bottom: 8px; }

.page-login button { width: 100%; margin-top: 8px; }

.stat-value { font-size: 32px; font-weight: 600; color: var(--text); }

.section-title {
    margin: 32px 0 16px;
    font-size: 18px;
    font-weight: 600;
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.service-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.service-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    text-decoration: none;
    color: inherit;
}

.service-card--off {
    opacity: 0.65;
}

.service-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.service-card__name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.service-card__status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.service-card__status.is-on {
    background: #dcfce7;
    color: #166534;
}

.service-card__status.is-off {
    background: #f1f5f9;
    color: var(--muted);
}

.service-card__desc {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.45;
}

.service-card__meta {
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

/* Admin filters */
.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
}

.inline-form .field {
    margin-bottom: 0;
    min-width: 140px;
    flex: 1 1 140px;
    max-width: 220px;
}

.inline-form .field--grow {
    max-width: 280px;
    flex: 1 1 180px;
}

.inline-form button {
    flex: 0 0 auto;
    margin-bottom: 0;
    align-self: flex-end;
}

.wrap--wide {
    max-width: none;
}

/* Log / audit tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

.table-wrap table {
    min-width: 720px;
}

.table-wrap--audit table {
    min-width: 1080px;
}

table.log-table {
    table-layout: fixed;
    width: 100%;
}

table.log-table th,
table.log-table td {
    vertical-align: top;
    padding: 10px 12px;
}

table.log-table th {
    white-space: nowrap;
}

table.log-table .col-when { width: 7.5rem; }
table.log-table .col-user { width: 14rem; }
table.log-table .col-service { width: 10rem; }
table.log-table .col-url { width: auto; }
table.log-table .col-ip { width: 8.5rem; }
table.log-table .col-event { width: 9.5rem; }
table.log-table .col-route { width: 11rem; }
table.log-table .col-http { width: 5.5rem; }
table.log-table .col-ms { width: 4.5rem; }
table.log-table .col-req { width: 12rem; }

.log-when {
    display: flex;
    flex-direction: column;
    gap: 0;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.log-when__date { color: var(--text); font-size: 13px; }
.log-when__time { color: var(--muted); font-size: 12px; }

.log-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.log-stack__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.log-stack__meta {
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.log-path,
.log-req {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.log-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
