:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    padding: 40px 20px;
}

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

/* Login */
.login-box {
    max-width: 400px;
    margin: 80px auto;
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-box h1 { font-size: 1.8rem; margin-bottom: 8px; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 24px; }

form label { display: block; text-align: left; margin-bottom: 6px; font-weight: 600; }
form input[type="text"],
form input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--surface-light);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 16px;
    outline: none;
}
form input:focus { border-color: var(--accent); }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s;
}
button:hover, .btn:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--surface-light); }
.btn-secondary:hover { background: #475569; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }

.btn-small { padding: 6px 12px; font-size: 0.85rem; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
}
.alert.error { background: rgba(239,68,68,0.15); color: #fecaca; border: 1px solid rgba(239,68,68,0.3); }

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
header h1 { font-size: 1.6rem; }

/* Sections */
section { margin-bottom: 32px; }
section h2 { font-size: 1.2rem; margin-bottom: 16px; color: var(--text-muted); }

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

.card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.card .value { font-size: 1.05rem; font-weight: 600; word-break: break-all; }

.status pre {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Clients */
.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { width: 220px; margin: 0; }

.inline { display: inline; }
.inline form { display: inline; }

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

thead { background: rgba(255,255,255,0.03); }
th, td { padding: 14px 16px; text-align: left; font-size: 0.95rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
td { border-top: 1px solid rgba(255,255,255,0.04); }

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }

.empty { text-align: center; color: var(--text-muted); padding: 40px; }

/* QR Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px;
    width: 90%;
    padding: 24px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 { font-size: 1.1rem; color: var(--text); }

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.qr-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.qr-image {
    width: 280px;
    height: 280px;
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    object-fit: contain;
}

@media (max-width: 640px) {
    .section-header { flex-direction: column; align-items: stretch; }
    .inline-form input { width: 100%; }
    th, td { padding: 10px 12px; font-size: 0.85rem; }
    .qr-image { width: 220px; height: 220px; }
}
