:root {
    --sidebar-bg: #0F172A;
    --sidebar-text: #94A3B8;
    --sidebar-active: #2563EB;
    --main-bg: #F1F5F9;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border-main: #E2E8F0;
    --brand-gradient: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
    --danger: #DC2626;
    --radius: 0.75rem;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

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

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

/* App layout */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 1.35rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-mark {
    width: 36px; height: 36px;
    background: var(--brand-gradient);
    border-radius: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 800; font-size: 0.75rem;
}

.logo-text { font-size: 1.05rem; font-weight: 800; color: white; }

.nav-menu { padding: 1rem 0; flex: 1; }

.nav-item {
    display: flex; align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

.nav-item svg { margin-right: 0.75rem; width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: white;
    border-left-color: var(--sidebar-active);
}

.sidebar-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #334155;
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}

.sidebar-user-name {
    font-size: 0.82rem; color: #E2E8F0;
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-role { font-size: 0.72rem; color: #64748B; }

.logout-btn {
    width: 100%;
    padding: 0.6rem;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    display: block;
    text-align: center;
    transition: 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
    height: 65px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: var(--shadow);
}

.topbar h1 { font-size: 1.125rem; font-weight: 600; }
.topbar-email { font-size: 0.875rem; color: var(--text-muted); }

.page-content { padding: 2rem; overflow-y: auto; flex: 1; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-main);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.05rem;
    font-weight: 650;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    line-height: 1.25;
}

.btn-primary {
    background: var(--sidebar-active);
    color: white;
}
.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 6px -1px rgb(37 99 235 / 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-main);
}
.btn-secondary:hover { background: #F8FAFC; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-block { width: 100%; justify-content: center; padding: 0.875rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-icon {
    width: 32px; height: 32px;
    border-radius: 0.375rem;
    border: 1px solid var(--border-main);
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748B;
    transition: 0.2s;
    text-decoration: none;
}
.btn-icon:hover { background: #F1F5F9; color: var(--text-main); }
.btn-icon.danger:hover { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
    background: #F8FAFC;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-main);
}

tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-main);
    font-size: 0.9rem;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    background: #F1F5F9;
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
    color: #334155;
}

a code { color: var(--sidebar-active); }
a:hover code { text-decoration: underline; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-group + .form-group { margin-top: 0; }

.form-stack .form-group { margin-bottom: 1.25rem; }

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-control {
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--border-main);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: 0.2s;
    background: white;
    font-family: inherit;
    color: var(--text-main);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.bg-green-100 { background: #DCFCE7; color: #166534; }
.bg-gray-100 { background: #F3F4F6; color: #6B7280; }
.bg-blue-100 { background: #DBEAFE; color: #1E40AF; }
.bg-purple-100 { background: #F3E8FF; color: #6B21A8; }
.bg-red-100 { background: #FEE2E2; color: #991B1B; }

/* Alerts */
.alert-error {
    background: #FEF2F2;
    color: #EF4444;
    border: 1px solid #FECACA;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.empty-state a { color: var(--sidebar-active); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* Detail table */
.detail-table th {
    width: 160px;
    background: transparent;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    vertical-align: top;
}
.detail-table td { font-size: 0.9rem; }
.detail-table tr:hover { background: transparent; }

pre {
    background: #F8FAFC;
    border: 1px solid var(--border-main);
    border-radius: 0.375rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.8rem;
    overflow-x: auto;
    margin: 0;
}

/* Login */
.login-body { display: flex; height: 100vh; background: #F8FAFC; }

.login-brand {
    flex: 1;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.login-brand-inner { text-align: center; max-width: 420px; }
.login-brand-mark {
    width: 56px; height: 56px;
    margin: 0 auto 1.25rem;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1rem;
}
.login-brand h1 { font-size: 2.25rem; font-weight: 800; }
.login-brand p { margin-top: 1rem; opacity: 0.9; font-size: 1.05rem; line-height: 1.6; }

.login-form-side {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    box-shadow: -10px 0 30px rgba(0,0,0,0.05);
}

.login-form-card { width: 100%; max-width: 400px; padding: 2rem; }
.login-form-card h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-sub { color: #64748B; margin-bottom: 2rem; font-size: 0.95rem; }

.login-form-card .form-group { margin-bottom: 1.25rem; }
.login-form-card .form-control { padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 1rem; }
.login-form-card .form-control:focus { box-shadow: 0 0 0 3px #93C5FD; }

@media (max-width: 768px) {
    .login-brand { display: none; }
    .app-layout { flex-direction: column; height: auto; min-height: 100vh; }
    .sidebar { width: 100%; height: auto; }
    .main-content { overflow: visible; }
    .form-grid { grid-template-columns: 1fr; }
}
