:root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --green: #1a7f37;
    --green-bg: #dafbe1;
    --red: #cf222e;
    --red-bg: #ffebe9;
    --amber: #9a6700;
    --amber-bg: #fff8c5;
    --amber-border: #d4a72c;
    --radius: 6px;
    --shadow-card: 0 1px 0 rgba(31, 35, 40, .04);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 16px 64px;
}

/* ── Header ─────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 2px;
    line-height: 1.25;
}

.page-meta {
    color: var(--muted);
    font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    white-space: nowrap;
    transition: background .1s, border-color .1s;
    font-family: inherit;
}
.btn:hover:not(:disabled) { background: #f3f4f6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
    background: #1f2328;
    border-color: rgba(31, 35, 40, .15);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #32383f; }

.btn-danger { color: var(--red); }
.btn-danger:hover:not(:disabled) {
    background: var(--red-bg);
    border-color: var(--red);
}

.btn-muted {
    color: var(--muted);
    border-color: transparent;
    background: transparent;
}
.btn-muted:hover:not(:disabled) { background: #f3f4f6; }

.btn-sm {
    padding: 3px 8px;
    font-size: 12px;
    line-height: 18px;
}

/* ── Cards ───────────────────────────────────────── */

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

/* ── Add-client form ─────────────────────────────── */

.add-form-card { padding: 16px; }

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

.form-input {
    flex: 1;
    padding: 5px 12px;
    font-size: 14px;
    line-height: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    outline: none;
}
.form-input:focus {
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, .1);
}

/* ── Token reveal ────────────────────────────────── */

.token-reveal {
    background: var(--amber-bg);
    border: 1px solid var(--amber-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.token-reveal-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--amber);
    margin-bottom: 10px;
}

.token-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.token-code {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, "SFMono-Regular", "SF Mono", Consolas, monospace;
    font-size: 13px;
    background: #fffbf0;
    border: 1px solid var(--amber-border);
    border-radius: 4px;
    padding: 6px 10px;
    word-break: break-all;
    color: var(--text);
    display: block;
}

/* ── Client cards ────────────────────────────────── */

.client-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
}

.client-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.client-name {
    font-size: 15px;
    font-weight: 600;
}

.section {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 10px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.field-value {
    font-size: 13px;
    color: var(--text);
}

.mono {
    font-family: ui-monospace, "SFMono-Regular", "SF Mono", Consolas, monospace;
    font-size: 12px;
}

.client-footer {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Section header (label + action button inline) ── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-header .section-label {
    margin-bottom: 0;
}

/* ── DNS edit form ───────────────────────────────── */

.dns-form { padding-top: 4px; }

.dns-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px 16px;
    margin-bottom: 12px;
}

.dns-form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-input-sm {
    padding: 3px 8px;
    font-size: 12px;
    line-height: 18px;
}

.field-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.dns-form-actions {
    display: flex;
    gap: 8px;
}

/* ── Badges ──────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    border: 1px solid transparent;
}

.badge-online {
    background: var(--green-bg);
    color: var(--green);
}

.badge-offline {
    background: var(--bg);
    color: var(--muted);
    border-color: var(--border);
}

.badge-stopped {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red);
}

.badge-success {
    background: var(--green-bg);
    color: var(--green);
}

.badge-warning {
    background: var(--amber-bg);
    color: var(--amber);
    border-color: var(--amber-border);
}

.badge-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red);
}

/* ── Banners ─────────────────────────────────────── */

.error-banner {
    background: var(--red-bg);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    color: var(--red);
    font-size: 13px;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 48px 16px;
    font-size: 14px;
}

/* ── Console log ─────────────────────────────────── */

.console-card {
    overflow: hidden;
}

.console-scroll {
    max-height: 320px;
    overflow-y: auto;
    font-family: ui-monospace, "SFMono-Regular", "SF Mono", Consolas, monospace;
    font-size: 12px;
    background: #0d1117;
    padding: 4px 0;
}

.console-row {
    display: grid;
    grid-template-columns: 90px 110px 140px 1fr;
    gap: 0 12px;
    padding: 3px 16px;
    color: #c9d1d9;
    border-bottom: 1px solid #21262d;
    line-height: 1.6;
}
.console-row:last-child { border-bottom: none; }

.console-row-error { color: #ff7b72; }

.console-ts { color: #8b949e; white-space: nowrap; }
.console-event { color: #79c0ff; }
.console-client { color: #d2a8ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-detail { color: #c9d1d9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.console-row-error .console-ts,
.console-row-error .console-event,
.console-row-error .console-client,
.console-row-error .console-detail { color: #ff7b72; }

/* ── Footer ──────────────────────────────────────── */

.page-footer {
    margin-top: 24px;
    text-align: center;
}
