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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; background: #f5f6fa; color: #333;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px; background: #1e2a3a; color: #cdd5e0;
    padding: 0; flex-shrink: 0;
}

.sidebar-brand { padding: 1.25rem 1rem; border-bottom: 1px solid #2d3f53; }
.sidebar-brand h2 { margin: 0; font-size: 1rem; color: #fff; }

.nav-list { list-style: none; margin: 0; padding: 0.5rem 0; }
.nav-list li a, .nav-list li .nav-link {
    display: block; padding: 0.6rem 1rem; color: #cdd5e0;
    text-decoration: none; font-size: 0.9rem;
}
.nav-list li a:hover, .nav-list li a.active { background: #2d3f53; color: #fff; }
.nav-divider { border-top: 1px solid #2d3f53; margin: 0.5rem 0; }
.nav-section { padding: 0.4rem 1rem; font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.1em; color: #6b7a8d; }

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

h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.2rem; }

.btn {
    display: inline-block; padding: 0.4rem 1rem; border-radius: 4px;
    border: 1px solid #1a73e8; background: #1a73e8; color: #fff;
    cursor: pointer; text-decoration: none; font-size: 0.875rem;
}
.btn:hover { background: #1558b0; }
.btn-primary { background: #1a73e8; }
.btn-secondary { background: #6c757d; border-color: #6c757d; }
.btn-outline { background: transparent; color: #1a73e8; }
.btn-outline:hover { background: #e8f0fe; }
.btn-danger { background: #d93025; border-color: #d93025; }
.btn-danger:hover { background: #a50e0e; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { background: #fff; border-radius: 6px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card h3 { margin-top: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.stat-card { background: #fff; border-radius: 6px; padding: 1.25rem; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.stat-value { font-size: 2rem; font-weight: 700; color: #1a73e8; }
.stat-label { font-size: 0.85rem; color: #666; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden; }
.table th, .table td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid #e9ecef; font-size: 0.875rem; }
.table th { background: #f8f9fa; font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8f9fa; }

.badge {
    display: inline-block; padding: 0.2rem 0.5rem; border-radius: 99px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-active { background: #d4edda; color: #155724; }
.badge-draft { background: #fff3cd; color: #856404; }
.badge-deprecated { background: #f8d7da; color: #721c24; }
.badge-deleted { background: #e2e3e5; color: #383d41; }

.filter-bar, .toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.filter-bar input, .toolbar input, .toolbar select {
    padding: 0.4rem 0.75rem; border: 1px solid #ced4da; border-radius: 4px;
    font-size: 0.875rem; min-width: 200px;
}

.pagination { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-size: 0.875rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.875rem; }
.form-control { width: 100%; max-width: 500px; padding: 0.4rem 0.75rem;
    border: 1px solid #ced4da; border-radius: 4px; font-size: 0.875rem; }
textarea.form-control { resize: vertical; }
.required { color: #d93025; }

.detail-table { border-collapse: collapse; margin: 1rem 0; }
.detail-table th, .detail-table td { padding: 0.5rem 1rem; border-bottom: 1px solid #e9ecef; text-align: left; }
.detail-table th { width: 160px; color: #666; font-weight: 500; }

.action-bar { display: flex; gap: 0.5rem; margin: 1.5rem 0; }

.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-top: 1rem; }
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal { background: #fff; padding: 2rem; border-radius: 8px; max-width: 400px; width: 90%; }
.modal p { margin-top: 0; }

/* Login page */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f0f2f5; }
.login-card { background: #fff; padding: 2.5rem 2rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.12); text-align: center; width: 320px; }
.login-card h1 { font-size: 1.2rem; margin: 0 0 0.5rem; }
.login-card p { color: #666; margin: 0 0 1.5rem; font-size: 0.9rem; }
.btn-google { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.25rem; background: #fff; border: 1px solid #dadce0; border-radius: 4px; font-size: 0.9rem; cursor: pointer; transition: background .15s; }
.btn-google:hover { background: #f8f9fa; }
.btn-google:disabled { opacity: .6; cursor: not-allowed; }
.login-error { color: #721c24; background: #f8d7da; padding: 0.5rem 0.75rem; border-radius: 4px; font-size: 0.85rem; margin-top: 1rem; }

/* Nav logout button */
.nav-logout-btn { background: none; border: none; width: 100%; text-align: left; padding: 0.5rem 1rem; color: #a0b4c8; cursor: pointer; font-size: 0.875rem; }
.nav-logout-btn:hover { background: #2d3f53; color: #fff; }

/* Sortable column headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: #f0f4f8; }
.sort-icon { margin-left: 0.25rem; opacity: 0.35; font-size: 0.8em; }
.sort-icon.active { opacity: 1; color: #1a73e8; }

/* Column filter row */
tr.filter-row th { padding: 0.25rem 0.5rem; background: #f8fafc; }
.filter-input { width: 100%; padding: 0.2rem 0.4rem; font-size: 0.8rem; border: 1px solid #d0d7de; border-radius: 3px; box-sizing: border-box; }
