/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg2:         #161b27;
  --bg3:         #1e2535;
  --bg4:         #252d3d;
  --border:      rgba(255,255,255,0.08);
  --border2:     rgba(255,255,255,0.14);
  --text:        #e8eaf0;
  --text2:       #9aa3b8;
  --text3:       #5d6578;
  --accent:      #4f8ef7;
  --accent2:     #3a7be0;
  --green:       #1db87a;
  --green2:      #16a06a;
  --red:         #e24b4a;
  --red2:        #c73f3e;
  --amber:       #f59e0b;
  --purple:      #8b5cf6;
  --teal:        #0ea5e9;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --font-sans:   'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --transition:  0.15s ease;
}

html { font-size: 14px; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, rgba(79,142,247,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(29,184,122,0.06) 0%, transparent 60%), var(--bg); }

.login-wrapper { width: 100%; max-width: 400px; padding: 1.5rem; }

.login-brand { text-align: center; margin-bottom: 2rem; }
.brand-icon  { font-size: 3rem; margin-bottom: .75rem; filter: drop-shadow(0 0 20px rgba(79,142,247,0.5)); }
.brand-name  { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.brand-sub   { font-size: .8rem; color: var(--text3); margin-top: .25rem; letter-spacing: .04em; text-transform: uppercase; }

.login-card  { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 2rem; box-shadow: var(--shadow); }

.login-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; }
.version-badge  { font-size: .7rem; color: var(--text3); font-family: var(--font-mono); }
.security-badge { font-size: .7rem; color: var(--text3); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
.form-label  { display: block; font-size: .75rem; font-weight: 500; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }
.form-input  { width: 100%; padding: .6rem .85rem; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text); font-family: var(--font-sans); font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition); outline: none; }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,142,247,.15); }
.form-input::placeholder { color: var(--text3); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

.input-icon-wrap { position: relative; }
.input-icon-wrap .form-input { padding-right: 2.5rem; }
.eye-btn { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; padding: .2rem; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem;
  border-radius: var(--radius); font-family: var(--font-sans); font-size: .85rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent; transition: all var(--transition); white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent);  }
.btn-primary:hover:not(:disabled)  { background: var(--accent2); border-color: var(--accent2); }
.btn-success  { background: var(--green);   color: #fff; border-color: var(--green);   }
.btn-success:hover:not(:disabled)  { background: var(--green2);  border-color: var(--green2);  }
.btn-danger   { background: var(--red);     color: #fff; border-color: var(--red);     }
.btn-danger:hover:not(:disabled)   { background: var(--red2);    border-color: var(--red2);    }
.btn-ghost    { background: transparent; color: var(--text2); border-color: var(--border2); }
.btn-ghost:hover:not(:disabled)    { background: var(--bg3); color: var(--text); }
.btn-icon     { padding: .4rem .55rem; font-size: .9rem; }
.btn-full     { width: 100%; justify-content: center; padding: .75rem; }
.btn-sm       { padding: .35rem .75rem; font-size: .78rem; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: .7rem 1rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: 1rem; border: 1px solid; }
.alert-danger  { background: rgba(226,75,74,.12); border-color: rgba(226,75,74,.3); color: #f87171; }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fcd34d; }
.alert-info    { background: rgba(79,142,247,.12); border-color: rgba(79,142,247,.3); color: #93c5fd; }
.alert-success { background: rgba(29,184,122,.12); border-color: rgba(29,184,122,.3); color: #6ee7b7; }

/* ─── Spinner ────────────────────────────────────────────────────────────── */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar { width: 220px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-header { padding: 1.25rem 1rem .75rem; border-bottom: 1px solid var(--border); }
.sidebar-logo   { display: flex; align-items: center; gap: .5rem; }
.sidebar-logo-icon { font-size: 1.4rem; }
.sidebar-logo-text { font-size: .95rem; font-weight: 600; letter-spacing: -.01em; }
.sidebar-user   { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.user-avatar    { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: .8rem; font-weight: 600; margin-bottom: .4rem; }
.av-1 { background: rgba(93,101,120,.3); color: #9aa3b8; }
.av-2 { background: rgba(14,165,233,.2); color: #38bdf8; }
.av-3 { background: rgba(139,92,246,.2); color: #a78bfa; }
.av-4 { background: rgba(245,158,11,.2); color: #fcd34d; }
.user-name  { font-size: .82rem; font-weight: 500; color: var(--text); }
.user-nivel { font-size: .7rem; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.nav-section { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.nav-section-title { font-size: .65rem; font-weight: 600; color: var(--text3); text-transform: uppercase;
  letter-spacing: .08em; padding: .25rem .85rem .4rem; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .85rem; font-size: .83rem;
  color: var(--text2); cursor: pointer; border-radius: 0; transition: all var(--transition);
  border-left: 2px solid transparent; user-select: none; }
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(79,142,247,.1); color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: .95rem; }
.sidebar-footer { margin-top: auto; padding: .75rem; border-top: 1px solid var(--border); }
.db-indicator { display: flex; align-items: center; gap: .4rem; font-size: .7rem; color: var(--text3);
  font-family: var(--font-mono); margin-bottom: .5rem; }
.db-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 52px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 1.25rem; background: var(--bg2); flex-shrink: 0; }
.topbar-title { font-size: .95rem; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.content-area { flex: 1; overflow-y: auto; padding: 1.25rem; }
.panel { display: none; }
.panel.active { display: block; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-header { display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.card-title  { font-size: .88rem; font-weight: 600; color: var(--text); }
.card-body   { padding: 1.1rem; }

/* ─── Stats ──────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .9rem 1.1rem; }
.stat-label { font-size: .7rem; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem; }
.stat-val   { font-size: 1.6rem; font-weight: 600; color: var(--text); line-height: 1; }
.stat-sub   { font-size: .72rem; color: var(--text3); margin-top: .25rem; }

/* ─── Search / Filter bar ────────────────────────────────────────────────── */
.filter-bar  { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.search-input { flex: 1; min-width: 200px; padding: .5rem .85rem; background: var(--bg3);
  border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text);
  font-family: var(--font-sans); font-size: .85rem; outline: none; transition: border-color var(--transition); }
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }
.filter-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.pill { padding: .25rem .7rem; border-radius: 99px; font-size: .72rem; cursor: pointer;
  border: 1px solid var(--border2); color: var(--text2); background: transparent; transition: all var(--transition);
  font-family: var(--font-sans); }
.pill:hover, .pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Credentials list ───────────────────────────────────────────────────── */
.cred-list { display: flex; flex-direction: column; gap: .5rem; }
.cred-card  { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem 1rem; transition: border-color var(--transition); }
.cred-card:hover { border-color: var(--border2); }
.cred-top   { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.cred-meta  { flex: 1; min-width: 0; }
.cred-title { font-size: .9rem; font-weight: 500; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.cred-user  { font-size: .78rem; color: var(--text2); margin-top: 2px; font-family: var(--font-mono); }
.cred-tags  { display: flex; gap: .3rem; align-items: center; flex-shrink: 0; }
.tag        { font-size: .68rem; padding: 2px 7px; border-radius: 99px; font-weight: 500; }
.tag-nivel1 { background: rgba(29,184,122,.15); color: #6ee7b7; }
.tag-nivel2 { background: rgba(14,165,233,.15); color: #38bdf8; }
.tag-nivel3 { background: rgba(139,92,246,.15); color: #a78bfa; }
.tag-nivel4 { background: rgba(245,158,11,.15); color: #fcd34d; }
.tag-cat    { background: var(--bg4); color: var(--text2); border: 1px solid var(--border); }
.cred-pass  { display: flex; align-items: center; gap: .5rem; margin-top: .65rem; }
.pass-display { flex: 1; font-family: var(--font-mono); font-size: .82rem;
  color: var(--text2); padding: .3rem .6rem; background: var(--bg4);
  border-radius: var(--radius); min-width: 0; word-break: break-all; }
.pass-display.revealed { color: var(--green); }
.cred-actions { display: flex; gap: .3rem; }
.expiry-warn { font-size: .7rem; color: var(--amber); margin-top: .4rem; }

/* ─── Strength bar ───────────────────────────────────────────────────────── */
.strength-bar-wrap { display: flex; gap: 3px; margin-top: .4rem; }
.strength-seg { height: 4px; flex: 1; border-radius: 2px; background: var(--bg4); transition: background .3s; }
.str-0 .strength-seg:nth-child(-n+0) { background: var(--red); }
.str-1 .strength-seg:nth-child(-n+1) { background: var(--red); }
.str-2 .strength-seg:nth-child(-n+2) { background: var(--amber); }
.str-3 .strength-seg:nth-child(-n+3) { background: var(--amber); }
.str-4 .strength-seg:nth-child(-n+4) { background: var(--green); }
.str-5 .strength-seg:nth-child(-n+5) { background: var(--green); }
.strength-label { font-size: .7rem; color: var(--text3); margin-top: .3rem; }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th { text-align: left; font-size: .68rem; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em; padding: .5rem .75rem;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); color: var(--text2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.td-mono { font-family: var(--font-mono); font-size: .78rem; }

/* ─── Badges de status ───────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: 2px 8px;
  border-radius: 99px; font-size: .7rem; font-weight: 500; }
.badge-ok      { background: rgba(29,184,122,.15); color: #6ee7b7; }
.badge-fail    { background: rgba(226,75,74,.15);  color: #f87171; }
.badge-warn    { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-info    { background: rgba(79,142,247,.15); color: #93c5fd; }
.badge-neutral { background: var(--bg4); color: var(--text2); }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-xl);
  padding: 1.5rem; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow); animation: modalIn .2s ease; }
.modal-box.modal-lg { max-width: 680px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-title  { font-size: 1rem; font-weight: 600; color: var(--text); }
.modal-close  { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 1.2rem; padding: .2rem; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem;
  padding-top: 1rem; border-top: 1px solid var(--border); }

/* ─── Policy panel ───────────────────────────────────────────────────────── */
.policy-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem 1rem; display: flex; justify-content: space-between; align-items: center; }
.policy-name { font-size: .85rem; font-weight: 500; color: var(--text); }
.policy-type { font-size: .7rem; color: var(--text3); margin-top: 2px; font-family: var(--font-mono); }
.policy-list { display: flex; flex-direction: column; gap: .5rem; }
.toggle-switch { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: var(--bg4); border-radius: 99px;
  border: 1px solid var(--border2); transition: background var(--transition); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  background: var(--text3); border-radius: 50%; transition: all var(--transition); }
.toggle-switch input:checked + .toggle-track { background: var(--green); border-color: var(--green); }
.toggle-switch input:checked ~ .toggle-thumb { left: 18px; background: #fff; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 2000;
  display: flex; flex-direction: column; gap: .4rem; }
.toast { padding: .65rem 1rem; border-radius: var(--radius); font-size: .83rem;
  display: flex; align-items: center; gap: .5rem; min-width: 240px; max-width: 360px;
  animation: toastIn .25s ease; box-shadow: var(--shadow); }
.toast-ok   { background: #0d2b1f; border: 1px solid rgba(29,184,122,.4); color: #6ee7b7; }
.toast-err  { background: #2b0d0d; border: 1px solid rgba(226,75,74,.4);  color: #f87171; }
.toast-info { background: #0d1b2b; border: 1px solid rgba(79,142,247,.4); color: #93c5fd; }
.toast-out  { animation: toastOut .25s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state-text { font-size: .88rem; }

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.section-title { font-size: .75rem; font-weight: 600; color: var(--text3); text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: .75rem; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar  { width: 100%; height: auto; }
  .app-layout { flex-direction: column; }
}
