:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --border:   #2d3148;
  --accent:   #6c63ff;
  --accent2:  #5a52e0;
  --text:     #e8eaf6;
  --muted:    #8b8fa8;
  --danger:   #ef5350;
  --success:  #66bb6a;
  --r:        10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────── */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ── Login ───────────────────────────────────────── */
.login-box {
  margin: auto;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo { font-size: 30px; font-weight: 700; text-align: center; letter-spacing: -.5px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: -6px; }

/* ── App layout ──────────────────────────────────── */
#app-screen { display: none; }
#app-screen.active { display: flex; overflow: hidden; }

.sidebar {
  width: 210px;
  min-width: 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-top {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-sm { font-size: 16px; font-weight: 700; display: block; }
.nav-user { font-size: 11px; color: var(--muted); margin-top: 3px; display: block; }

.nav-links {
  list-style: none;
  padding: 10px 0;
  flex: 1;
}

.nav-links li {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  border-radius: 0 8px 8px 0;
  margin-right: 8px;
  transition: all .15s;
}

.nav-links li:hover { background: var(--surface2); color: var(--text); }
.nav-links li.active { background: rgba(108,99,255,.15); color: var(--accent); font-weight: 500; }

.btn-logout {
  margin: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.content { flex: 1; overflow-y: auto; padding: 30px 32px; }

/* ── Tabs ────────────────────────────────────────── */
.tab { display: none; }
.tab.active { display: block; }

.tab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
}

.tab-head h1 { font-size: 20px; font-weight: 600; }

.tab-head-right { display: flex; gap: 10px; align-items: center; }

/* ── Category chips ──────────────────────────────── */
.cat-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.chip {
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover, .chip.active {
  background: rgba(108,99,255,.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Credentials grid ────────────────────────────── */
.creds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.cred-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  transition: border-color .15s;
}
.cred-card:hover { border-color: var(--accent); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}
.card-title { font-weight: 600; font-size: 14px; flex: 1; }
.card-cat {
  font-size: 10px;
  padding: 2px 7px;
  background: var(--surface2);
  border-radius: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  min-height: 32px;
}
.card-row:last-of-type { border-bottom: none; }

.row-label { color: var(--muted); font-size: 10px; width: 52px; flex-shrink: 0; }
.row-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-pw { letter-spacing: 2px; color: var(--muted); font-size: 11px; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  transition: all .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface2); color: var(--accent); }
.icon-btn.ok { color: var(--success); }

.card-notes {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.card-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ── Users list ──────────────────────────────────── */
.users-list { display: flex; flex-direction: column; gap: 10px; }

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-card.inactive { opacity: .5; }

.user-left { display: flex; align-items: center; gap: 12px; }

.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.user-name { font-weight: 500; font-size: 14px; }
.user-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.user-right { display: flex; align-items: center; gap: 8px; }

.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.role-admin    { background: rgba(108,99,255,.2);  color: var(--accent);  }
.role-employee { background: rgba(255,167,38,.15); color: var(--warning); }
.role-member   { background: rgba(102,187,106,.15);color: var(--success); }

/* ── Audit ───────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 6px; }

.audit-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  gap: 14px;
  font-size: 13px;
  align-items: center;
  flex-wrap: wrap;
}

.a-time  { color: var(--muted); font-size: 11px; white-space: nowrap; }
.a-user  { font-weight: 500; min-width: 80px; }
.a-action{ color: var(--accent); min-width: 80px; }
.a-title { color: var(--muted); flex: 1; }
.a-ip    { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ── Inputs ──────────────────────────────────────── */
input, textarea, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
select option { background: var(--surface2); }

label { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: block; }

.alert {
  background: rgba(239,83,80,.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary.full { width: 100%; padding: 11px; }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 14px;
  transition: all .15s;
}
.btn-secondary:hover { border-color: var(--muted); color: var(--text); }

.btn-sm {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: all .15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: all .15s;
}
.btn-danger-sm:hover { border-color: var(--danger); background: rgba(239,83,80,.08); }

/* ── Modals ──────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: popIn .15s ease;
}
.modal-sm { width: 360px; }

@keyframes popIn {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }

.close-btn {
  background: none; border: none;
  color: var(--muted); font-size: 15px;
  padding: 4px 6px; border-radius: 4px;
  transition: color .15s;
}
.close-btn:hover { color: var(--text); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 38px; }
.eye-btn {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  font-size: 15px; padding: 3px;
  color: var(--muted);
}

/* ── Checkboxes ──────────────────────────────────── */
.checkbox-group { display: flex; flex-direction: column; gap: 7px; }
.checkbox-item  { display: flex; align-items: center; gap: 8px; }
.checkbox-item input[type=checkbox] { width: auto; accent-color: var(--accent); }
.checkbox-item label { margin: 0; font-size: 13px; color: var(--text); }

/* ── Empty state ─────────────────────────────────── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 44px; margin-bottom: 12px; }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  animation: slideUp .2s ease;
}
.toast.hidden { display: none; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── Misc ────────────────────────────────────────── */
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Role select inline ──────────────────────────── */
.role-select {
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ── Visibility badge on cards ───────────────────── */
.vis-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.vis-all      { background: rgba(102,187,106,.1);  color: var(--success); }
.vis-employee { background: rgba(255,167,38,.1);   color: var(--warning); }
.vis-admin    { background: rgba(108,99,255,.15);  color: var(--accent);  }

/* ── Invite cards ────────────────────────────────── */
.invite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.invite-card.used { opacity: .5; }

.invite-left  { flex: 1; }
.invite-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.invite-role { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.invite-note { font-size: 12px; color: var(--muted); }

.invite-url {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.invite-url code {
  background: var(--surface2);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
}

/* ── Nav role badge ──────────────────────────────── */
.sidebar-top .role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}

/* ── Google button ───────────────────────────────── */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,.2); text-decoration: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Pending approval banner ─────────────────────── */
.pending-banner {
  background: rgba(255,167,38,.1);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 12px 16px;
  border-radius: 7px;
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}
