:root {
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --radius: 10px;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Auth pages */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #1e3a5f 100%);
}

.auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo i {
    font-size: 2.5rem;
    color: var(--primary);
}

.auth-logo h1 {
    font-size: 1.5rem;
    margin-top: .5rem;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: .875rem;
}

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

.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .375rem;
}

.form-control {
    width: 100%;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .1s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-block { width: 100%; }

.page-header .btn,
.data-table .btn,
.form-card .btn:not(.btn-block) {
    width: auto;
    flex-shrink: 0;
}

.btn-secondary {
    background: var(--sidebar-bg);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }

.alert {
    padding: .875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .875rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.text-danger { color: #dc2626; font-size: .8125rem; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-center { text-align: center; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .625rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand i { color: #60a5fa; font-size: 1.375rem; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: .9375rem;
    transition: background .15s, color .15s;
}

.nav-item i {
    font-size: 1.125rem;
    color: #cbd5e1;
    flex-shrink: 0;
}

.nav-item:hover { background: var(--sidebar-hover); color: #f1f5f9; }
.nav-item:hover i { color: #fff; }
.nav-item.active { background: rgba(59,130,246,.2); color: #fff; border-left: 3px solid var(--sidebar-active); }
.nav-item.active i { color: #93c5fd; }
.nav-divider {
    padding: .75rem 1.5rem .25rem;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
}

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); }
.logout-link:hover { color: #fca5a5 !important; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
}

.search-form {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-form i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-form input {
    width: 100%;
    padding: .625rem 1rem .625rem 2.75rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    font-size: .9375rem;
}

.search-form input:focus {
    outline: none;
    border-color: var(--sidebar-active);
    background: #fff;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: .875rem; }
.user-email { font-size: .75rem; color: var(--text-muted); }

.content { padding: 1.5rem; flex: 1; }

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

.page-header h2 { font-size: 1.5rem; font-weight: 700; }

.view-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text-muted);
    font-size: .875rem;
}

/* Credential grid */
.cred-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
}

.cred-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    position: relative;
}

.cred-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.cred-card-header {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cred-lock-icon {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.95);
    transition: opacity .2s;
    z-index: 1;
}

.cred-card:hover .cred-lock-icon { opacity: 0; }

.cred-card-actions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: .5rem;
    padding-top: 1.75rem;
    opacity: 0;
    transition: opacity .2s;
    z-index: 2;
}

.cred-card:hover .cred-card-actions { opacity: 1; }

.cred-action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1e293b;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform .15s, background .15s;
}

.cred-action-btn i {
    font-size: 1rem;
    color: #1e293b;
    line-height: 1;
}

.cred-action-btn:hover {
    transform: scale(1.08);
    background: #f8fafc;
}

.cred-action-btn.delete:hover i { color: var(--primary); }

.launch-btn {
    position: absolute;
    bottom: .625rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #0f172a;
    padding: .35rem .875rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-decoration: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.launch-btn i {
    font-size: .75rem;
    color: #0f172a;
}

.cred-card:hover .launch-btn { opacity: 1; }

.cred-card-body { padding: 1rem; }

.cred-site-name {
    font-weight: 600;
    font-size: .9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cred-username {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: .25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cred-password-mask {
    font-family: monospace;
    letter-spacing: 2px;
    margin-top: .375rem;
    font-size: .8125rem;
    color: var(--text-muted);
}

.cred-badge {
    display: inline-block;
    font-size: .6875rem;
    padding: .125rem .5rem;
    border-radius: 4px;
    background: #dbeafe;
    color: #1d4ed8;
    margin-top: .375rem;
}

.cred-badge.shared { background: #f3e8ff; color: #7c3aed; }
.cred-badge.admin { background: #fef3c7; color: #b45309; }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }

/* FAB */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(220,38,38,.4);
    text-decoration: none;
    z-index: 200;
    transition: transform .2s, background .2s;
}

.fab:hover { transform: scale(1.08); background: var(--primary-hover); color: #fff; }

/* Forms page */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 560px;
    box-shadow: var(--shadow);
}

.color-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.color-option input { display: none; }
.color-option span {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
}
.color-option input:checked + span { border-color: var(--text); }

/* Tables */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: .875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    font-size: .8125rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
}

.data-table tr:last-child td { border-bottom: none; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
}

.modal h3 { margin-bottom: 1rem; }

.password-reveal {
    font-family: monospace;
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    word-break: break-all;
    margin: 1rem 0;
}

.email-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: var(--bg);
}

.alert pre-wrap,
.alert {
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 150;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .user-info { display: none; }
    .cred-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
