:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
}

* { box-sizing: border-box; }

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

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

.muted { color: var(--muted); font-size: 0.9rem; }

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-links a { color: var(--text); }
.nav-user { display: flex; gap: 0.75rem; align-items: center; }
.user-name { color: var(--muted); font-size: 0.9rem; }
.logout-form { margin: 0; }
.link-button {
    background: none; border: none; padding: 0;
    color: var(--primary); cursor: pointer; font-size: inherit;
}
.link-button:hover { text-decoration: underline; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1 { margin-top: 0; }
h2 { margin: 0 0 1rem; font-size: 1.15rem; }
h3 { margin: 0 0 0.5rem; font-size: 1rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
}
.card-active { border-color: var(--primary); }

.metric {
    display: flex; flex-direction: column; gap: 0.25rem;
    margin-top: 0.5rem;
}
.metric-value { font-size: 1.5rem; font-weight: 600; }
.metric-label { font-size: 0.85rem; color: var(--muted); }

.status { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.dot {
    width: 10px; height: 10px; border-radius: 50%;
    display: inline-block;
}
.dot-on { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,0.2); }
.dot-off { background: var(--muted); }

.login-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.login-card h1 { margin: 0 0 0.25rem; }

.form { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1rem; }
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.form input, .form select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--surface);
}
.form input:focus, .form select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-disabled { color: var(--muted); background: var(--bg); cursor: not-allowed; pointer-events: none; opacity: 0.6; }

.alert { padding: 0.6rem 0.8rem; border-radius: 6px; margin: 0.5rem 0; font-size: 0.9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e3a8a; }
.alert-success { background: #dcfce7; color: #166534; }

table.users {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}
table.users th, table.users td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-size: 0.95rem;
}
table.users th { background: var(--bg); font-weight: 600; }
table.users tr:last-child td { border-bottom: none; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.field-error { color: var(--danger); font-size: 0.85rem; }

.inline-form { display: inline; margin: 0; }

.role-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.role-badge.role-ADMIN { background: #fef3c7; color: #92400e; }
.role-badge.role-USER  { background: #e0e7ff; color: #3730a3; }

.house-switcher { margin: 0; }
.house-switcher select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 0.9rem;
    cursor: pointer;
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin-bottom: 0.25rem; }

.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state h2 { margin-top: 0; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
