/* openmun-auth admin dashboard */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --surface: #fff;
    --header-bg: #1e293b;
    --header-text: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
}

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

/* Header */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0 1rem;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
}
.header-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}
header nav {
    display: flex;
    gap: 0.25rem;
}
header nav a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
header nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}
.header-user {
    margin-left: auto;
    font-size: 0.875rem;
    color: #94a3b8;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Section headings */
h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}
h2:first-child { margin-top: 0; }

/* Forms */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
}
input:focus, select:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}
input.narrow { width: 120px; }
input.wide { width: 280px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--primary);
    white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
th {
    text-align: left;
    padding: 0.75rem;
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
tr.inactive td { opacity: 0.5; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.login-card h1 {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
    text-align: center;
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0 0 1.5rem;
}
.login-card .form-group { margin-bottom: 1rem; }
.login-card input[type="text"],
.login-card input[type="password"] { width: 100%; }
.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    margin-top: 0.5rem;
}
.login-sep {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* Login tab chooser (radio-driven, no JS needed) */
.tab-radio { position: absolute; opacity: 0; pointer-events: none; }
.tab-bar {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 1.25rem;
    border-bottom: 1px solid var(--border);
}
.tab-label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    user-select: none;
}
.tab-label:hover { color: var(--text); }
/* Keyboard focus on the (visually hidden) radio highlights its label. */
.tab-radio:focus-visible + .tab-bar .tab-label,
.tab-radio:focus-visible ~ .tab-bar .tab-label { outline: none; }
.tab-panel { display: none; }
#tab-password:checked ~ .tab-bar label[for="tab-password"],
#tab-scan:checked ~ .tab-bar label[for="tab-scan"],
#tab-code:checked ~ .tab-bar label[for="tab-code"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
#tab-password:checked ~ .tab-panels .panel-password,
#tab-scan:checked ~ .tab-panels .panel-scan,
#tab-code:checked ~ .tab-panels .panel-code { display: block; }
.login-card .tab-panel input[type="text"],
.login-card .tab-panel input[type="password"] { width: 100%; }

/* QR scanner */
#scanner-container {
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
#scanner-container:not(.open) { display: none; }
#scanner-container.open {
    display: block;
    background: #000;
    border: 1px solid var(--border);
}
.scanner-status {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}
.scanner-warning {
    margin: 0.75rem 0 0;
    padding: 0.75rem;
    font-size: 0.8125rem;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 6px;
}
.panel-scan .btn { width: 100%; justify-content: center; }

/* Monospace */
.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
.code-display {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 2px;
    color: var(--text);
}

/* Checkbox groups */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    cursor: pointer;
    text-transform: none;
    font-weight: normal;
    letter-spacing: normal;
    color: var(--text);
}

/* Actions cell */
.actions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* Audit log warning rows */
.warning-row td { background: #fef3c7; }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.75rem; }
.text-center { text-align: center; }
.break-all { word-break: break-all; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
