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

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f5f5f5;
}

/* ---- Navigation ---- */

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: #1e293b;
}

.nav-menu a {
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-menu a:hover { color: #fff; }

.logout-form { display: contents; }

.logout-button {
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
}

.logout-button:hover { color: #fff; }

/* ---- Page layout ---- */

.page-content {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ---- Flash & error messages ---- */

.flash-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #d1fae5;
    border-left: 4px solid #10b981;
    border-radius: 3px;
    color: #065f46;
}

.error-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    border-radius: 3px;
    color: #991b1b;
}

/* ---- Login page ---- */

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f1f5f9;
}

body.login-page .page-content {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}

.login-heading {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #fff;
    padding: 2rem;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.login-form label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.login-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
}

.login-form input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.login-form button {
    padding: 0.6rem 1.25rem;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

.login-form button:hover { background: #0f172a; }

/* ---- User list ---- */

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.list-header h1 { font-size: 1.5rem; }

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.user-table th,
.user-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.user-table thead th {
    background: #f8fafc;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
}

.user-table tbody tr:last-child td { border-bottom: none; }
.user-table tbody tr:hover td { background: #f9fafb; }

.role-cell .role-badge { margin: 0.15rem; }

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.action-cell {
    white-space: nowrap;
}

.action-cell .action-link {
    margin-right: 0.75rem;
}

.action-cell .action-form {
    display: inline;
    margin-right: 0.75rem;
}

.action-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.875rem;
}

.action-link:hover { text-decoration: underline; }

.action-form { display: inline; }

.delete-button {
    padding: 0.2rem 0.6rem;
    background: none;
    color: #dc2626;
    border: 1px solid #dc2626;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.delete-button:hover { background: #fee2e2; }

.empty-message { color: #6b7280; }
.empty-message a { color: #2563eb; }

/* ---- User form ---- */

.user-form-page h1,
.user-roles-page h1 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

.user-form,
.roles-form {
    background: #fff;
    padding: 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-row label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-row input,
.form-row textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
}

.form-row input:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.field-value {
    font-weight: 600;
    color: #374151;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.form-actions button {
    padding: 0.5rem 1.25rem;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

.form-actions button:hover { background: #0f172a; }

/* ---- API key list ---- */

.api-key-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.api-key-table th,
.api-key-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.api-key-table thead th {
    background: #f8fafc;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
}

.api-key-table tbody tr:last-child td { border-bottom: none; }
.api-key-table tbody tr:hover td { background: #f9fafb; }

.key-prefix {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.85rem;
    color: #4b5563;
}

/* ---- API key form ---- */

.api-key-form-page h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }

.api-key-form {
    background: #fff;
    padding: 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---- API key created (show-once) ---- */

.api-key-created-page h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }

.api-key-reveal {
    background: #fff;
    padding: 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.api-key-warning {
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 3px;
    color: #92400e;
    font-weight: 600;
}

.api-key-value {
    display: block;
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.85rem;
    word-break: break-all;
    user-select: all;
}
