/* ============ Signava design system ============ */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e6e8f0;
  --border-strong: #d4d7e3;
  --text: #14172b;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #5551d8;
  --primary-hover: #4744c4;
  --primary-soft: #eeeefc;
  --accent: #8b5cf6;
  --success: #12805c;
  --success-soft: #e3f6ee;
  --warning: #b45309;
  --warning-soft: #fef3e2;
  --danger: #d92d20;
  --danger-soft: #feeceb;
  --sidebar-bg: #14172b;
  --sidebar-text: #aab0c6;
  --sidebar-active: #ffffff;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 43, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 23, 43, 0.08);
  --shadow-lg: 0 12px 40px rgba(20, 23, 43, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }

p { margin: 0 0 .75rem; }

/* ============ App shell ============ */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
  transition: transform .25s ease;
}

.main {
  flex: 1;
  margin-left: 256px;
  padding: 28px 32px 64px;
  max-width: 1400px;
  width: calc(100% - 256px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 14px;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand .logo-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid; place-items: center;
  color: #fff; font-size: .95rem; font-weight: 800;
}

.ws-switch { padding: 0 14px 12px; position: relative; }

.ws-switch-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: #e6e8f2;
  border-radius: var(--radius);
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  text-align: left;
}
.ws-switch-btn:hover { background: rgba(255,255,255,.1); }
.ws-switch-btn .caret { margin-left: auto; opacity: .6; }

.nav { padding: 6px 14px; display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex; align-items: center; gap: 12px;
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 500;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { color: var(--sidebar-active); background: rgba(99, 102, 241, .28); }
.nav a svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }

.nav-label {
  padding: 16px 14px 6px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #5d6480;
  font-weight: 600;
}

.sidebar-bottom { margin-top: auto; padding: 14px; }

.usage-box {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 12px;
  font-size: .78rem;
  margin-bottom: 12px;
}
.usage-box .row { display: flex; justify-content: space-between; margin-bottom: 4px; color: #cdd2e4; }
.usage-box .bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; margin-bottom: 10px; }
.usage-box .bar > span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #6366f1, #a855f7); }
.usage-box .plan-line { display: flex; justify-content: space-between; align-items: center; color: #8f96b3; }
.usage-box .plan-line a { color: #a5b4fc; font-weight: 600; }

.user-box { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.user-box .meta { min-width: 0; flex: 1; }
.user-box .meta .name { color: #e6e8f2; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .meta .email { color: #7c8398; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .logout { color: #7c8398; }
.user-box .logout:hover { color: #fff; }

/* Mobile topbar */
.mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  background: var(--sidebar-bg); color: #fff;
  padding: 12px 16px;
  align-items: center; gap: 12px;
}
.mobile-bar .hamburger { background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; display: grid; }

.backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 12, 24, .5);
  z-index: 35;
}

@media (max-width: 940px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .backdrop { display: block; }
  .main { margin-left: 0; width: 100%; padding: 20px 16px 56px; }
  .mobile-bar { display: flex; }
}

/* ============ Components ============ */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card + .card { margin-top: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 16px;
  font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fcd9d6; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.field .hint { font-size: .75rem; color: var(--faint); margin-top: 4px; }

.input, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit; font-size: .9rem;
  background: var(--surface);
  color: var(--text);
}
.input:focus, .select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.select[multiple] { min-height: 92px; }

.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 4px 0; cursor: pointer; }
.checkbox-line input { accent-color: var(--primary); width: 15px; height: 15px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .72rem; font-weight: 600;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: #eef0f5; color: var(--muted); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c7d2fe, #ddd6fe);
  color: #4338ca;
  display: grid; place-items: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sq { border-radius: 10px; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .89rem;
}
table.data th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbfe; }

.result-name { font-weight: 600; color: var(--text); }
.result-name:hover { color: var(--primary); }
.sub-line { color: var(--muted); font-size: .8rem; }

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty .icon { font-size: 2rem; margin-bottom: 8px; }
.empty h3 { color: var(--text); }

.flash {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 100;
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  font-size: .88rem;
  max-width: 380px;
  animation: flash-in .25s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } }

.alert {
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: .88rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f6dcb8; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: #f6c4c0; }

/* Search layout */
.search-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .search-layout { grid-template-columns: 1fr; } }

.filters-card { position: sticky; top: 20px; }
@media (max-width: 1100px) { .filters-card { position: static; } }
.filters-card h3 { display: flex; justify-content: space-between; align-items: center; }
.filters-card .clear { font-size: .78rem; font-weight: 500; }

.filters-scroll { max-height: calc(100vh - 210px); overflow-y: auto; padding-right: 4px; }
@media (max-width: 1100px) { .filters-scroll { max-height: none; } }

details.fgroup { border-top: 1px solid var(--border); padding: 10px 0; }
details.fgroup:first-of-type { border-top: 0; }
details.fgroup summary {
  cursor: pointer;
  font-size: .85rem; font-weight: 600;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
details.fgroup summary::-webkit-details-marker { display: none; }
details.fgroup summary:after { content: "+"; color: var(--faint); font-weight: 400; }
details.fgroup[open] summary:after { content: "−"; }
details.fgroup .fbody { padding-top: 10px; }

.results-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.results-toolbar .count { font-weight: 600; font-size: .92rem; }
.results-toolbar .spacer { flex: 1; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--muted);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 12, 24, .55);
  z-index: 90;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  padding: 24px;
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.97); } }
.modal h3 { margin-bottom: 14px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px); left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 60;
  padding: 6px;
  color: var(--text);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit; font-size: .88rem;
  color: var(--text);
  background: none; border: 0;
  cursor: pointer;
  text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); text-decoration: none; }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-menu .current { font-weight: 700; color: var(--primary); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 18px; }
.stat-card .label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.stat-card .foot { font-size: .78rem; color: var(--faint); }
.stat-card .bar { height: 6px; border-radius: 3px; background: #eef0f5; overflow: hidden; margin-top: 10px; }
.stat-card .bar > span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #a855f7); border-radius: 3px; }

/* Profile pages */
.profile-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.profile-head .info { flex: 1; min-width: 240px; }
.profile-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #eef0f5; color: var(--muted); border-radius: 999px; padding: 3px 11px; font-size: .78rem; font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t-body { flex: 1; min-width: 0; }
.timeline .t-title { font-weight: 600; }
.timeline .t-sub { color: var(--muted); font-size: .84rem; }
.timeline .t-desc { color: var(--muted); font-size: .84rem; margin-top: 6px; white-space: pre-line; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: .89rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ============ Public / landing ============ */

.public-body { background: #0d0f1e; color: #e6e8f2; min-height: 100vh; display: flex; flex-direction: column; }

.public-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 6vw;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.public-nav .links { display: flex; gap: 22px; align-items: center; }
.public-nav a { color: #b9bed4; font-size: .92rem; }
.public-nav a:hover { color: #fff; text-decoration: none; }

.hero {
  text-align: center;
  padding: 72px 6vw 56px;
  position: relative;
  overflow: hidden;
}
.hero:before {
  content: "";
  position: absolute;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.35), transparent 65%);
  top: -320px; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}
.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 18px;
  position: relative;
}
.hero h1 .grad { background: linear-gradient(90deg, #818cf8, #c084fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: #9aa1bd; max-width: 620px; margin: 0 auto 30px; font-size: 1.08rem; position: relative; }
.hero .cta { display: flex; gap: 12px; justify-content: center; position: relative; flex-wrap: wrap; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 6vw 60px;
}
.feature {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.feature h3 { color: #fff; margin-bottom: 6px; }
.feature p { color: #9aa1bd; font-size: .9rem; margin: 0; }
.feature .f-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid; place-items: center;
  margin-bottom: 14px; color: #fff;
}

.pricing { padding: 20px 6vw 80px; max-width: 1100px; margin: 0 auto; width: 100%; }
.pricing h2 { text-align: center; color: #fff; font-size: 1.8rem; margin-bottom: 30px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.plan-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex; flex-direction: column;
}
.plan-card.highlight { border-color: #818cf8; background: rgba(99,102,241,.12); position: relative; }
.plan-card .p-name { color: #fff; font-weight: 700; font-size: 1.05rem; }
.plan-card .p-price { color: #fff; font-size: 2rem; font-weight: 800; margin: 10px 0 2px; }
.plan-card .p-price span { font-size: .85rem; color: #9aa1bd; font-weight: 500; }
.plan-card ul { list-style: none; padding: 0; margin: 16px 0 22px; color: #b9bed4; font-size: .88rem; display: grid; gap: 8px; }
.plan-card ul li:before { content: "✓  "; color: #818cf8; font-weight: 700; }
.plan-card .btn { margin-top: auto; }

.public-footer { text-align: center; color: #5d6480; font-size: .82rem; padding: 26px; margin-top: auto; }

/* Auth / centered cards */
.center-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.center-card { max-width: 430px; width: 100%; }

/* ---- Person profile: sticky section nav ---- */
.section-nav {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 18px;
  padding: 8px 10px;
}
.section-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.section-nav a:hover { background: var(--bg); color: var(--text); }
.section-nav .count {
  display: inline-block;
  margin-left: 4px;
  font-size: .72rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 1px 6px;
}
.card[id] { scroll-margin-top: 64px; }

/* ---- Refresh button spinner ---- */
.btn.is-refreshing { opacity: .7; pointer-events: none; }
