/* SecurePass — compact, dense, tool-like admin UI (Linear/Stripe vibe). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .brand .logo {
  width: 22px; height: 22px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-green));
  flex: 0 0 auto;
}
.sidebar .brand .name { font-weight: 700; color: #fff; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.sidebar .brand .name small { display:block; font-weight:500; font-size:var(--fs-xs); color:var(--sidebar-fg-muted); letter-spacing:0; }

.nav { padding: var(--sp-3); overflow-y: auto; flex: 1; }
.nav .group-label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--sidebar-fg-muted); padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); margin-bottom: 2px;
  border-radius: var(--radius-sm); color: var(--sidebar-fg);
  font-size: var(--fs-base); text-decoration: none;
}
.nav a .ic { width: 15px; height: 15px; opacity: 0.8; flex:0 0 auto; }
.nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); box-shadow: inset 2px 0 0 var(--sidebar-accent); }
.sidebar .foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid rgba(255,255,255,0.06); font-size: var(--fs-xs); color: var(--sidebar-fg-muted); }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-5); position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { font-size: var(--fs-base); color: var(--text-muted); }
.topbar .crumbs b { color: var(--text); font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: var(--sp-4); }

.bell { position: relative; cursor: pointer; padding: var(--sp-2); border-radius: var(--radius-sm); color: var(--text-muted); }
.bell:hover { background: var(--bg); }
.bell .badge {
  position: absolute; top: 0; right: 0; min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--danger); color: #fff; border-radius: 8px; font-size: 9px; line-height: 15px;
  text-align: center; font-weight: 700; display: none;
}
.bell.has-unread .badge { display: block; }

.userchip { display: flex; align-items: center; gap: var(--sp-3); }
.userchip .av {
  width: 26px; height: 26px; border-radius: 50%; flex:0 0 auto;
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-green));
  color:#fff; font-size: var(--fs-xs); font-weight: 700;
  display:flex; align-items:center; justify-content:center;
}
.userchip .meta { line-height: 1.1; }
.userchip .meta .n { font-weight: 600; font-size: var(--fs-sm); }
.userchip .meta .r { color: var(--text-faint); font-size: var(--fs-xs); }

/* ---------- Content ---------- */
.content { padding: var(--sp-6); flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }
.page-head h1 { font-size: var(--fs-xl); letter-spacing: -0.01em; }
.page-head .sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: var(--sp-5); }
.card .hd { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.card .hd h3 { font-size: var(--fs-base); }
.card .bd { padding: var(--sp-5); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-sm); }
.stat .label { color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat .value.g { color: var(--brand-green); }
.stat .value.b { color: var(--brand-navy); }

/* ---------- Tables (dense) ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
table.tbl th, table.tbl td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.wrap { white-space: normal; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; line-height: 1.4; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }
.btn-primary:hover { background: var(--green-600); }
.btn-green { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }
.btn-green:hover { background: var(--green-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 3px var(--sp-3); font-size: var(--fs-xs); }
.btn-ghost { border-color: transparent; background: transparent; }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-2); color: var(--text); }
.field .hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--sp-2); }
.input, .select, textarea.input {
  width: 100%; font-family: inherit; font-size: var(--fs-base);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.input:focus, .select:focus { outline: none; border-color: var(--brand-navy); box-shadow: 0 0 0 3px var(--info-bg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.row3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-4); }
.field .ok { color: var(--success); } .field .bad { color: var(--danger); }

/* ---------- Badges / pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; padding: 2px var(--sp-3); border-radius: 20px; }
.pill.green { background: var(--success-bg); color: var(--success); }
.pill.blue { background: var(--info-bg); color: var(--info); }
.pill.amber { background: var(--warning-bg); color: var(--warning); }
.pill.red { background: var(--danger-bg); color: var(--danger); }
.pill.gray { background: #F1F5F9; color: var(--text-muted); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 1000; display: flex; flex-direction: column; gap: var(--sp-3); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-3) var(--sp-4);
  min-width: 240px; max-width: 360px; font-size: var(--fs-sm);
  animation: toast-in .18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast .t-title { font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 480px; max-width: calc(100vw - 32px); overflow: hidden; animation: toast-in .15s; }
.modal .m-hd { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content: space-between; }
.modal .m-hd h3 { font-size: var(--fs-lg); }
.modal .m-bd { padding: var(--sp-5); max-height: 64vh; overflow-y: auto; }
.modal .m-ft { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); background: var(--surface-2); }
.x { cursor: pointer; color: var(--text-faint); border:0; background:none; font-size:18px; line-height:1; }

/* ---------- Notifications dropdown ---------- */
.notif-pop { position: absolute; top: calc(var(--topbar-h) - 4px); right: var(--sp-5); width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; display: none; }
.notif-pop.open { display: block; }
.notif-pop .nh { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); display:flex; justify-content: space-between; align-items:center; font-weight:600; font-size: var(--fs-sm); }
.notif-pop .nl { max-height: 320px; overflow-y: auto; }
.notif-item { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.notif-item.unread { background: var(--info-bg); }
.notif-item .tm { color: var(--text-faint); font-size: var(--fs-xs); margin-top: 2px; }
.notif-empty { padding: var(--sp-6); text-align: center; color: var(--text-faint); font-size: var(--fs-sm); }

.muted { color: var(--text-muted); }
.empty { padding: var(--sp-7); text-align: center; color: var(--text-faint); }
.spin { display:inline-block; width:14px; height:14px; border:2px solid var(--border-strong); border-top-color: var(--brand-green); border-radius:50%; animation: sp 0.6s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Event workspace tabs ---------- */
.ework-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:var(--sp-4); gap:var(--sp-4); flex-wrap:wrap; }
.ework-head .t { display:flex; align-items:center; gap:var(--sp-3); }
.ework-head h1 { font-size:var(--fs-xl); letter-spacing:-.01em; }
.ework-head .pub { font-size:var(--fs-sm); }
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--border); margin-bottom:var(--sp-5); overflow-x:auto; }
.tabs a { padding:var(--sp-3) var(--sp-4); font-size:var(--fs-sm); font-weight:600; color:var(--text-muted); border-bottom:2px solid transparent; white-space:nowrap; }
.tabs a:hover { color:var(--text); text-decoration:none; }
.tabs a.active { color:var(--brand-navy); border-bottom-color:var(--brand-green); }

/* ---------- Form builder ---------- */
.fb-wrap { display:grid; grid-template-columns:1fr 340px; gap:var(--sp-5); align-items:start; }
@media (max-width:900px){ .fb-wrap { grid-template-columns:1fr; } }
.fb-field { border:1px solid var(--border); border-radius:var(--radius); padding:var(--sp-3) var(--sp-4); margin-bottom:var(--sp-3); background:var(--surface); }
.fb-field.dragging { opacity:.5; }
.fb-field .fb-top { display:flex; align-items:center; gap:var(--sp-3); }
.fb-field .grip { cursor:grab; color:var(--text-faint); user-select:none; }
.fb-field .grip:active { cursor:grabbing; }
.preview-card { border:1px solid var(--border); border-radius:var(--radius); padding:var(--sp-5); background:var(--surface-2); position:sticky; top:60px; }
.preview-card .pf { margin-bottom:var(--sp-4); }
.preview-card label { display:block; font-size:var(--fs-sm); font-weight:600; margin-bottom:4px; }

/* ---------- Bars (mini) ---------- */
.bar-row { display:flex; align-items:center; gap:var(--sp-3); margin-bottom:var(--sp-2); font-size:var(--fs-sm); }
.bar-row .bl { width:120px; flex:0 0 auto; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-row .bt { flex:1; background:var(--light-gray); border-radius:6px; height:16px; overflow:hidden; }
.bar-row .bf { height:100%; background:var(--brand-green); border-radius:6px; }
.bar-row .bn { width:44px; flex:0 0 auto; text-align:right; font-weight:600; }
.spark { display:flex; align-items:flex-end; gap:3px; height:60px; }
.spark .sb { flex:1; background:var(--brand-navy); border-radius:3px 3px 0 0; min-height:2px; opacity:.85; }
