:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --error: #dc2626;
    --success: #16a34a;
    --radius: 0.5rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
}

a:hover {
    color: color-mix(in srgb, var(--primary), black 15%);
}

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

.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.brand-logo {
    display: block;
    max-height: 64px;
}

.auth-container .brand-logo {
    max-height: 120px;
    margin-bottom: 1.5rem;
}

nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

nav a {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
}

nav a:hover {
    background: var(--bg);
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.button-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.button-primary:hover {
    background: color-mix(in srgb, var(--primary), black 15%);
}

.button-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.button-danger {
    background: var(--error);
    color: white;
}

.button-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

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

.portal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.portal-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.portal-card img {
    width: 128px;
    height: 128px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.portal-card h3 {
    font-size: 0.9375rem;
    font-weight: 500;
}

.portal-card-noicon h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.portal-card-description {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    background: var(--bg);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background: #fef2f2;
    color: #991b1b;
}

.badge-pending {
    background: #fef9c3;
    color: #854d0e;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

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

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.page-header {
    padding: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    padding: 1rem 0;
}

.pagination a,
.pagination span {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 1rem 0;
}

.filter-bar input,
.filter-bar select {
    width: auto;
    min-width: 150px;
}

.note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #1e40af;
}

.groups-dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 360px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    margin: auto;
}

.groups-dialog::backdrop {
    background: rgba(0,0,0,0.3);
}

.groups-dialog h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.groups-dialog .dialog-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.groups-dialog .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

.groups-dialog .checkbox-label input[type="checkbox"] {
    width: auto;
}

.groups-dialog .dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.groups-dialog .button-primary {
    width: auto;
}

footer {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .auth-container {
        margin: 2rem 1rem;
    }

    .portal-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar input,
    .filter-bar select {
        width: 100%;
    }
}
