/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0f1117;
  --bg2:     #161921;
  --bg3:     #1e2230;
  --bg4:     #252a3a;
  --border:  #2a2f42;
  --border2: #353b52;
  --text:    #e8eaf0;
  --text2:   #9aa0b8;
  --text3:   #5a6080;
  --accent:  #4f7cff;
  --accent2: #3d63d4;
  --accentbg:rgba(79,124,255,.12);
  --green:   #2dd4a0;
  --greenbg: rgba(45,212,160,.1);
  --amber:   #f5a623;
  --amberbg: rgba(245,166,35,.1);
  --red:     #ff5e5e;
  --redbg:   rgba(255,94,94,.1);
  --purple:  #a78bfa;
  --purplebg:rgba(167,139,250,.1);
  --teal:    #22d3ee;
  --tealbg:  rgba(34,211,238,.1);
  --radius:  10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
  --sidebar-w: 240px;
  --transition: .15s ease;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== SPLASH ===== */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
}
.splash-icon { font-size: 48px; animation: pulse 1.5s ease infinite; }
.splash-title { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -.4px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ===== LOGIN ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.login-logo-text h1 { font-size: 18px; font-weight: 600; letter-spacing: -.3px; }
.login-logo-text p { font-size: 12px; color: var(--text3); margin-top: 1px; }
.login-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 24px;
  gap: 3px;
}
.login-tab {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text3);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.login-tab.active {
  background: var(--bg3);
  color: var(--text);
}
.login-error {
  background: var(--redbg);
  border: 1px solid rgba(255,94,94,.3);
  color: var(--red);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}
.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 14px; font-weight: 600; letter-spacing: -.3px; }
.sidebar-logo-sub { font-size: 10px; color: var(--text3); margin-top: 1px; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 8px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
  font-family: var(--font);
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accentbg); color: var(--accent); }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--bg4);
  color: var(--text3);
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 6px 0; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  background: var(--accent);
}
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text3); }
.logout-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 14px;
  padding: 4px;
  border-radius: 5px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* ===== MAIN AREA ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  flex-shrink: 0;
}
.topbar h1 { font-size: 16px; font-weight: 600; letter-spacing: -.3px; flex: 1; }
.search-wrap { position: relative; flex: 1; max-width: 280px; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}
.search {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg3);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--text3); }
.content { flex: 1; overflow-y: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ===== BUTTONS ===== */
.btn {
  padding: 7px 14px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  background: none;
  color: var(--text);
  font-family: var(--font);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-weight: 400;
  text-decoration: none;
}
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: transparent; }
.btn.danger:hover { background: var(--redbg); border-color: transparent; }
.btn.ghost { border-color: transparent; color: var(--text2); }
.btn.ghost:hover { background: var(--bg3); color: var(--text); }

/* ===== VIEWS ===== */
.view { display: none; }
.view.active { display: block; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat-label { font-size: 11px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-val { font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ===== PROPERTIES ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 7px;
}
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.prop-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}
.prop-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.prop-card-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 18px 18px 0 0; }
.prop-card-icon { font-size: 28px; margin-bottom: 12px; }
.prop-card-name { font-size: 14px; font-weight: 600; letter-spacing: -.2px; margin-bottom: 3px; }
.prop-card-addr { font-size: 12px; color: var(--text3); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-card-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.prop-card-btns {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 2;
}
.prop-card:hover .prop-card-btns { opacity: 1; }
.prop-edit-btn, .prop-delete-btn {
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.prop-edit-btn:hover { background: var(--accentbg); color: var(--accent); border-color: transparent; }
.prop-delete-btn:hover { background: var(--redbg); color: var(--red); border-color: transparent; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 500; }

/* ===== DETAIL ===== */
.back-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.breadcrumb { font-size: 13px; color: var(--text3); }
.breadcrumb span { color: var(--text); font-weight: 500; }

/* ===== PASSWORD ROWS ===== */
.pw-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 28px; }
.pw-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition);
}
.pw-row:hover { border-color: var(--border2); }
.pw-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  background: var(--bg3);
  flex-shrink: 0;
}
.pw-meta { flex: 1; min-width: 0; }
.pw-name { font-size: 13px; font-weight: 500; }
.pw-sub { font-size: 11px; color: var(--text3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-prop-tag { font-size: 10px; color: var(--text3); background: var(--bg4); padding: 2px 7px; border-radius: 20px; display: inline-block; margin-top: 3px; }
.pw-mask {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  background: var(--bg3);
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.pw-mask:hover { border-color: var(--border2); color: var(--text); }
.pw-mask.revealed { color: var(--text); letter-spacing: .02em; }
.pw-actions { display: flex; gap: 4px; }

/* ===== ICON BUTTONS ===== */
.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: none;
  color: var(--text3);
  font-size: 13px;
  transition: all var(--transition);
  font-family: var(--font);
}
.icon-btn:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { background: var(--redbg); color: var(--red); border-color: transparent; }

/* ===== DOC CARDS ===== */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.doc-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition);
}
.doc-card:hover { border-color: var(--border2); }
.doc-card-icon { font-size: 24px; margin-bottom: 10px; }
.doc-card-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.doc-card-desc { font-size: 11px; color: var(--text3); line-height: 1.5; flex: 1; }
.doc-card-footer { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-tag { font-size: 10px; padding: 2px 8px; border-radius: 20px; background: var(--accentbg); color: var(--accent); font-weight: 500; }
.doc-file-badge { font-size: 10px; background: var(--greenbg); color: var(--green); padding: 2px 7px; border-radius: 20px; font-weight: 500; }
.doc-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== TEAM ===== */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.team-name { font-size: 13px; font-weight: 500; }
.team-email { font-size: 11px; color: var(--text3); margin-top: 1px; }
.role-badge { font-size: 10px; padding: 3px 9px; border-radius: 20px; font-weight: 600; margin-left: auto; }

/* ===== ACTIVITY ===== */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--text2);
}
.activity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.activity-time { font-size: 10px; color: var(--text3); margin-left: auto; white-space: nowrap; padding-left: 16px; }

/* ===== MODALS ===== */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
.modal-close {
  width: 28px; height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text3);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: all var(--transition);
  font-family: var(--font);
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== FIELDS ===== */
.field { margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text2); display: block; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg3);
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field select option { background: var(--bg3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pw-input-wrap { position: relative; }
.pw-input-wrap input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 14px; padding: 2px; transition: color var(--transition);
}
.pw-toggle:hover { color: var(--text); }
.strength-bar-wrap { height: 3px; background: var(--bg4); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.strength-bar { height: 100%; border-radius: 2px; transition: all .3s; width: 0; }

/* ===== UPLOAD ===== */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--bg3);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accentbg); }
.upload-zone-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--text2); }
.upload-zone span { font-size: 11px; color: var(--text3); }
.file-preview {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.file-preview-name { flex: 1; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview-size { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== EMPTY STATES ===== */
.empty { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-icon { font-size: 32px; margin-bottom: 10px; opacity: .4; }
.empty p { font-size: 13px; margin-bottom: 12px; }

/* ===== SPINNER ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CONFIRM DIALOG ===== */
.confirm-dialog {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  animation: modal-in .15s ease;
}
.confirm-dialog h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.confirm-dialog p { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}
