:root {
    --bg: #54575e;
    --surface: #101522;
    --surface-2: #151b2b;
    --surface-3: #1a2235;
    --border: rgba(255,255,255,.08);
    --text: #f7f8fc;
    --muted: #929bb0;
    --primary: #8b5cf6;
    --primary-2: #6d28d9;
    --success: #34d399;
    --danger: #fb7185;
    --warning: #fbbf24;
    --sidebar: 256px;
    --radius: 18px;
    --shadow: 0 20px 60px rgba(0,0,0,.32);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 75% -10%, rgba(124,58,237,.16), transparent 34%),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 800; letter-spacing: -.04em; }
.brand-mark {
    width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: 11px; color: #fff; background: linear-gradient(135deg, #a78bfa, #6d28d9);
    box-shadow: 0 8px 24px rgba(124,58,237,.28);
}
.brand-large { font-size: 1.35rem; }
.brand-large .brand-mark { width: 44px; height: 44px; border-radius: 13px; }

/* Sidebar */
.sidebar {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: var(--sidebar);
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 26px 18px 18px; background: rgba(12,16,28,.92);
    border-right: 1px solid var(--border); backdrop-filter: blur(18px);
}
.sidebar-brand { padding: 0 8px 30px; }
.sidebar-nav { display: grid; gap: 7px; }
.nav-item {
    display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 0 13px;
    border-radius: 12px; color: var(--muted); font-weight: 650; transition: .18s ease;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(139,92,246,.20), rgba(139,92,246,.07)); box-shadow: inset 2px 0 var(--primary); }
.nav-icon { width: 20px; text-align: center; opacity: .9; }
.sidebar-bottom { display: grid; gap: 8px; }
.profile-mini {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 13px;
    border: 1px solid transparent;
}
.profile-mini:hover, .profile-mini.active { background: rgba(255,255,255,.045); border-color: var(--border); }
.avatar {
    flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: 50%; background: #252d42; color: #c4b5fd; font-weight: 800;
}
.profile-mini-copy { min-width: 0; display: grid; }
.profile-mini-copy strong, .profile-mini-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-mini-copy strong { font-size: .84rem; }
.profile-mini-copy small { color: var(--muted); font-size: .7rem; margin-top: 2px; }
.logout-link { display: flex; align-items: center; gap: 12px; padding: 10px 13px; color: var(--muted); border-radius: 11px; }
.logout-link:hover { color: var(--danger); background: rgba(251,113,133,.06); }
.sidebar-toggle, .sidebar-backdrop { display: none; }

/* Main */
.main-content { margin-left: var(--sidebar); padding: 42px 42px 56px; max-width: 1500px; }
.page-header { margin-bottom: 28px; }
.page-header-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.eyebrow { display: block; margin-bottom: 8px; color: #a78bfa; font-size: .68rem; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
.page-header h1 { margin-bottom: 7px; font-size: clamp(1.7rem, 2.5vw, 2.35rem); letter-spacing: -.045em; }
.page-header p { margin-bottom: 0; color: var(--muted); }
.panel {
    background: rgba(16,21,34,.76); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.alert { padding: 13px 15px; border-radius: 13px; margin-bottom: 18px; border: 1px solid var(--border); }
.alert-danger { background: rgba(251,113,133,.08); border-color: rgba(251,113,133,.22); color: #fecdd3; }
.alert-success { background: rgba(52,211,153,.08); border-color: rgba(52,211,153,.2); color: #a7f3d0; }

/* Buttons & forms */
.btn {
    min-height: 44px; border: 1px solid transparent; border-radius: 12px; padding: 0 16px;
    color: #fff; font-weight: 750; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 9px 24px rgba(109,40,217,.22); }
.btn-secondary { background: #252d42; border-color: var(--border); }
.btn-ghost { background: transparent; border-color: var(--border); color: #cbd2e1; }
.btn-danger { background: rgba(190,30,60,.14); border-color: rgba(251,113,133,.18); color: #fda4af; }
.btn-small { min-height: 36px; padding: 0 11px; font-size: .78rem; }
.btn-full { width: 100%; }
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > span { color: #cfd5e2; font-size: .78rem; font-weight: 700; }
.field input, .field select, .field textarea, .select-control {
    width: 100%; border: 1px solid var(--border); outline: none; color: var(--text);
    background: #0b101b; border-radius: 11px; padding: 12px 13px; min-height: 46px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .select-control:focus {
    border-color: rgba(139,92,246,.65); box-shadow: 0 0 0 3px rgba(139,92,246,.11);
}
.field input:disabled { opacity: .55; cursor: not-allowed; }
.field-hint { color: var(--muted); font-size: .75rem; margin: -7px 0 18px; line-height: 1.5; }
.input-action { position: relative; }
.input-action input { padding-right: 74px; }
.mini-btn {
    position: absolute; right: 5px; top: 5px; bottom: 5px; border: 0; border-radius: 8px;
    background: #252d42; color: #d8d2ff; padding: 0 10px; font-size: .74rem; font-weight: 800;
}
.icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
    background: rgba(255,255,255,.03); color: var(--muted); display: grid; place-items: center; font-size: 1.25rem;
}
.icon-btn:hover { color: #fff; background: rgba(255,255,255,.07); }
.icon-btn.danger:hover { color: #fda4af; }
.inline-form { display: inline; }

/* Vault */
.toolbar { padding: 12px; display: flex; gap: 10px; margin-bottom: 20px; }
.search-box { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--border); background: #0b101b; border-radius: 11px; }
.search-box span { color: var(--muted); font-size: 1.2rem; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); min-height: 44px; }
.select-control { width: auto; min-width: 220px; }
.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.vault-card {
    position: relative; min-height: 190px; padding: 18px; display: flex; flex-direction: column;
    background: linear-gradient(180deg, rgba(22,28,45,.92), rgba(15,20,32,.92));
    border: 1px solid var(--border); border-radius: 17px; transition: .2s ease;
}
.vault-card:hover { transform: translateY(-2px); border-color: rgba(139,92,246,.24); box-shadow: 0 18px 45px rgba(0,0,0,.22); }
.vault-card-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .7rem; }
.category-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 10px color-mix(in srgb, var(--dot) 50%, transparent); }
.category-name { font-weight: 700; }
.vault-date { margin-left: auto; }
.vault-card h2 { margin: 22px 0 5px; font-size: 1.08rem; letter-spacing: -.02em; }
.owner-label { color: var(--muted); font-size: .72rem; margin-bottom: auto; }
.vault-actions { display: flex; gap: 7px; align-items: center; margin-top: auto; padding-top: 18px; }
.vault-actions .btn { flex: 1; }
.empty-state {
    grid-column: 1 / -1; text-align: center; padding: 72px 20px; border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-icon { font-size: 2rem; color: #a78bfa; margin-bottom: 12px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 540px; margin: 0 auto 20px; color: var(--muted); line-height: 1.6; }

/* Panels / tables / profiles */
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.profile-grid .panel { padding: 24px; }
.panel-heading { margin-bottom: 22px; }
.panel-heading h2 { margin-bottom: 6px; font-size: 1.05rem; }
.panel-heading p { color: var(--muted); margin-bottom: 0; font-size: .8rem; }
.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.data-table td { font-size: .84rem; }
.data-table tr:last-child td { border-bottom: 0; }
.table-sub { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.category-badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--badge); background: color-mix(in srgb, var(--badge) 12%, transparent); border: 1px solid color-mix(in srgb, var(--badge) 30%, transparent); font-family: ui-monospace, monospace; font-size: .7rem; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.06); color: #cbd2e1; font-size: .7rem; font-weight: 750; }
.status-pill.success { color: #a7f3d0; background: rgba(52,211,153,.08); }
.status-pill.danger { color: #fecdd3; background: rgba(251,113,133,.08); }
.status-pill.warning { color: #fde68a; background: rgba(251,191,36,.08); }
.empty-table { text-align: center !important; color: var(--muted); padding: 36px !important; }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 5px 0 20px; color: #cbd2e1; font-size: .82rem; }
.check-row label { display: inline-flex; align-items: center; gap: 8px; }

/* Modals */
.modal {
    position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px;
    background: rgba(3,5,10,.72); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: .18s ease;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
    width: min(100%, 760px); max-height: min(90vh, 900px); overflow: auto;
    padding: 24px; background: #101522; border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 30px 100px rgba(0,0,0,.5);
    transform: translateY(10px) scale(.985); transition: .18s ease;
}
.modal.open .modal-card { transform: translateY(0) scale(1); }
.modal-small { max-width: 450px; }
.modal-medium { max-width: 540px; }
.modal-large { max-width: 820px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.modal-heading h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.modal-copy { color: var(--muted); font-size: .8rem; line-height: 1.55; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.field-full { grid-column: 1 / -1; }
.security-callout { display: flex; gap: 10px; padding: 13px; margin-top: 3px; border-radius: 13px; background: rgba(139,92,246,.07); border: 1px solid rgba(139,92,246,.16); }
.security-callout > span { color: #a78bfa; font-weight: 900; }
.security-callout strong, .security-callout small { display: block; }
.security-callout strong { font-size: .76rem; }
.security-callout small { margin-top: 3px; color: var(--muted); font-size: .7rem; }

/* Auth */
.auth-page { background: #070a12; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; }
.auth-visual {
    position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 6vw 42px;
    background:
        radial-gradient(circle at 20% 20%, rgba(139,92,246,.22), transparent 34%),
        radial-gradient(circle at 80% 80%, rgba(59,130,246,.12), transparent 30%),
        #0b0f1a;
}
.auth-visual-copy { max-width: 660px; }
.auth-visual h1 { margin: 0 0 18px; font-size: clamp(2.8rem, 5vw, 5.5rem); line-height: .98; letter-spacing: -.065em; }
.auth-visual h1 em { color: #a78bfa; font-style: normal; }
.auth-visual-copy p { max-width: 560px; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.security-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.security-pills span { padding: 8px 10px; border: 1px solid var(--border); border-radius: 999px; color: #aeb6c8; font-size: .68rem; background: rgba(255,255,255,.03); }
.auth-panel { display: grid; place-items: center; padding: 32px; background: #0a0e17; }
.auth-card { width: min(100%, 420px); }
.auth-heading { margin: 40px 0 26px; }
.auth-heading h2 { margin-bottom: 8px; font-size: 2rem; letter-spacing: -.05em; }
.auth-heading p, .auth-note { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.auth-note { text-align: center; margin-top: 16px; }
.mobile-brand { display: none; }

/* Setup */
.setup-page { display: grid; place-items: center; padding: 24px; }
.setup-card { width: min(100%, 520px); padding: 34px; background: rgba(16,21,34,.94); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); }
.brand-centered { justify-content: center; margin-bottom: 30px; }
.setup-card h1 { font-size: 2rem; letter-spacing: -.05em; margin-bottom: 10px; }
.lead { color: var(--muted); font-size: .84rem; line-height: 1.65; margin-bottom: 24px; }
.password-meter { height: 5px; overflow: hidden; border-radius: 999px; background: #252d42; margin: -3px 0 14px; }
.password-meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #fb7185, #fbbf24, #34d399); transition: width .2s; }

@media (max-width: 980px) {
    :root { --sidebar: 230px; }
    .main-content { padding: 32px 26px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
    .auth-panel { min-height: 100vh; }
    .mobile-brand { display: inline-flex; }
}

@media (max-width: 760px) {
    :root { --sidebar: 245px; }
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 60px rgba(0,0,0,.4); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 40; inset: 0; display: block; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: .22s; }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
    .sidebar-toggle {
        position: fixed; z-index: 60; top: 13px; left: 13px; display: grid; place-content: center; gap: 4px;
        width: 43px; height: 43px; border: 1px solid var(--border); border-radius: 12px; background: rgba(16,21,34,.9);
    }
    .sidebar-toggle span { width: 18px; height: 2px; background: #dce1ec; border-radius: 4px; }
    body.menu-open { overflow: hidden; }
    .main-content { margin-left: 0; padding: 76px 16px 36px; }
    .page-header-row { align-items: stretch; flex-direction: column; }
    .page-header-row .btn { width: 100%; }
    .toolbar { flex-direction: column; }
    .select-control { width: 100%; }
    .vault-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .modal-card { padding: 19px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
    .setup-card { padding: 24px 19px; }
}

@media (max-width: 620px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
    .data-table td { display: flex; justify-content: space-between; gap: 15px; padding: 9px 16px; border: 0; }
    .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 700; }
    .data-table td:last-child { display: block; }
    .table-actions { justify-content: flex-end; }
    .auth-panel { padding: 20px; }
}
