:root {
  --navy: #214478;
  --teal: #0080AA;
  --navy-dark: #172f54;
  --bg: #ffffff;
  --surface: #f6f8fb;
  --border: #e3e8ef;
  --text: #1c2533;
  --muted: #6b7a90;
  --success: #1f9d6b;
  --danger: #c8443c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 64, .06), 0 4px 16px rgba(16, 32, 64, .06);
  --gradient: linear-gradient(135deg, var(--navy), var(--teal));
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Sidebar brand ---------- */
.sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-logo { height: 25px; display: block; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 10px;
}
.sidebar-head h2 {
  margin: 0; font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 600;
}


/* ---------- Brand ---------- */
.sidebar-brand { display: flex; align-items: center; gap: 8px; }
.brand-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: var(--gradient); padding: 3px 7px; border-radius: 999px;
}

/* ---------- Navigation ---------- */
.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: #eaf0f7; color: var(--navy); }
.nav-link.is-active { background: #fff; color: var(--navy); box-shadow: var(--shadow); font-weight: 600; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gradient);
}
.nav-link.is-active svg { color: var(--teal); }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.sidebar-footer:empty { display: none; }
.sf-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; min-width: 0; }
.sf-avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gradient); color: #fff; font-weight: 700; font-size: 13px;
}
.sf-info { display: flex; flex-direction: column; min-width: 0; }
.sf-email {
  color: var(--text); font-weight: 600; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sf-role { color: var(--muted); font-size: 11px; }
.sf-signout {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--muted); font-weight: 500; font-size: 13px;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.sf-signout svg { width: 16px; height: 16px; flex-shrink: 0; }
.sf-signout:hover:not(:disabled) { color: var(--danger); border-color: rgba(200, 68, 60, .35); background: #fdf4f3; }
.sf-signout:disabled { opacity: .6; cursor: progress; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; outline: none; }
.page { max-width: 1240px; margin: 0 auto; padding: 32px 36px 48px; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); }

.stats { display: flex; gap: 12px; }
.stat {
  display: flex; flex-direction: column; min-width: 96px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.stat-value { font-size: 20px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search {
  flex: 1; min-width: 220px; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 128, 170, .15); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; height: 100%; color: var(--text); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.segmented button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 7px;
  font-weight: 500; color: var(--muted); cursor: pointer; transition: all .15s;
}
.segmented button:hover { color: var(--navy); }
.segmented button.is-active { background: #fff; color: var(--navy); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- Tags ---------- */
.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.tag-bar:empty { display: none; }
.tag-bar-label {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 4px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.tag-bar-label svg { width: 14px; height: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--teal); color: var(--teal); }
.chip.is-active { background: var(--gradient); border-color: transparent; color: #fff; }
.chip-count {
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
  background: var(--surface); color: var(--muted);
}
.chip.is-active .chip-count { background: rgba(255, 255, 255, .22); color: #fff; }
.chip-sm { padding: 2px 8px; font-size: 11px; cursor: default; background: var(--surface); }
.chip-sm:hover { border-color: var(--border); color: var(--text); }
.chip-sm.is-active { background: rgba(0, 128, 170, .1); color: var(--teal); border-color: rgba(0, 128, 170, .3); }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 4px 6px; cursor: pointer;
  color: var(--teal); font-weight: 600; font-size: 13px;
}
.link-btn svg { width: 14px; height: 14px; }
.link-btn:hover { text-decoration: underline; }

.results-meta {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px; margin-bottom: 12px; min-height: 26px;
}

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }

.app-card {
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  animation: card-in .35s ease both;
}
.app-card:hover, .app-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(33, 68, 120, .14);
  border-color: rgba(0, 128, 170, .35);
  outline: none;
}
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card-preview {
  height: 120px; padding: 16px 18px;
  background: linear-gradient(135deg, #eef3fa, #e6f4f9);
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.is-dashboard .card-preview { background: linear-gradient(135deg, #e7eef8, #dff0f7); }

/* Table preview */
.pv-table { display: flex; flex-direction: column; gap: 6px; background: #fff; border-radius: 8px; padding: 10px; box-shadow: var(--shadow); height: 100%; }
.pv-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; }
.pv-row span { height: 6px; border-radius: 3px; background: #e3e9f1; }
.pv-head span { background: var(--navy); opacity: .75; }
.pv-row span:last-child { background: rgba(0, 128, 170, .35); }

/* Dashboard preview */
.pv-dash { display: flex; gap: 10px; height: 100%; }
.pv-bars {
  flex: 2; display: flex; align-items: flex-end; gap: 6px;
  background: #fff; border-radius: 8px; padding: 10px; box-shadow: var(--shadow);
}
.pv-bars span { flex: 1; border-radius: 3px 3px 0 0; background: var(--gradient); opacity: .85; }
.pv-side { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.pv-donut {
  flex: 1; border-radius: 8px; background: #fff; box-shadow: var(--shadow); position: relative;
}
.pv-donut::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 38px; height: 38px; border-radius: 50%;
  background: conic-gradient(var(--navy) 0 45%, var(--teal) 45% 78%, #cfdbe9 78% 100%);
  -webkit-mask: radial-gradient(circle, transparent 10px, #000 11px);
          mask: radial-gradient(circle, transparent 10px, #000 11px);
}
.pv-kpi { height: 22px; border-radius: 8px; background: #fff; box-shadow: var(--shadow); position: relative; }
.pv-kpi::after { content: ""; position: absolute; left: 8px; top: 8px; width: 50%; height: 6px; border-radius: 3px; background: var(--teal); opacity: .6; }

.card-body { padding: 16px 18px 12px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: #fff; background: var(--navy);
}
.is-dashboard .card-icon { background: var(--teal); }
.type-badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px;
  color: var(--navy); background: rgba(33, 68, 120, .08);
}
.is-dashboard .type-badge { color: var(--teal); background: rgba(0, 128, 170, .1); }
.card-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.35; word-break: break-word; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12px;
}
.card-host { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-author { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.card-author-avatar {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--gradient);
}
.card-author-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-author.is-unknown .card-author-name { color: var(--muted); font-style: italic; font-weight: 400; }
.card-open { display: inline-flex; align-items: center; gap: 5px; color: var(--teal); font-weight: 600; flex-shrink: 0; }
.card-open svg { width: 14px; height: 14px; transition: transform .2s; }

/* Stretched link: the whole card opens the element, while inner buttons stay clickable. */
.app-card { position: relative; }
.card-link { color: inherit; text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: 14px; }
.card-link:focus-visible { outline: none; }
.app-card:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(33, 68, 120, .14), 0 0 0 3px rgba(0, 128, 170, .2);
  border-color: rgba(0, 128, 170, .35);
}

/* Delete button (top-right corner of the card) */
.card-delete {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, .92);
  color: var(--muted); cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; transform: scale(.92); transition: opacity .15s, transform .15s, color .15s, border-color .15s, background .15s;
}
.card-delete svg { width: 16px; height: 16px; }
.app-card:hover .card-delete, .app-card:focus-within .card-delete, .card-delete:focus-visible { opacity: 1; transform: none; }
.card-delete:hover { color: var(--danger); border-color: var(--danger); background: #fff; }
.card-delete:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(200, 68, 60, .25); }
@media (hover: none) { .card-delete { opacity: 1; transform: none; } }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.delete-warning { margin: 0; color: var(--text); line-height: 1.5; }

/* Team access row */
.card-access {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface);
}
.access-icon { display: inline-grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.access-icon svg { width: 16px; height: 16px; }
.access-teams { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chip-team { background: #fff; }
.access-none { font-size: 12px; color: var(--muted); font-style: italic; }
.access-btn {
  position: relative; z-index: 1; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  color: var(--navy); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.access-btn svg { width: 14px; height: 14px; }
.access-btn:hover { border-color: var(--teal); color: var(--teal); }
.access-btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }
.access-btn.is-loading { color: transparent; pointer-events: none; position: relative; }
.access-btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 12px;
  border: 2px solid rgba(0, 128, 170, .25); border-top-color: var(--teal); border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Access modal */
.check-chip[hidden] { display: none; }
.access-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.access-count { color: var(--muted); font-size: 12px; }
.access-warning {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
  color: #8a5a00; background: #fff7e6; border: 1px solid #f3dca8;
}
.access-warning svg { width: 16px; height: 16px; flex-shrink: 0; }
.access-warning[hidden] { display: none; }
.app-card:hover .card-open svg { transform: translate(2px, -2px); }

/* Skeleton */
.skeleton { pointer-events: none; animation: none; }
.skeleton .card-preview, .sk-line {
  background: linear-gradient(90deg, #eef2f7 25%, #f7f9fc 50%, #eef2f7 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
.sk-line { height: 10px; border-radius: 5px; }
.sk-sm { width: 30%; } .sk-md { width: 55%; } .sk-lg { width: 80%; height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- State boxes ---------- */
.state-box {
  grid-column: 1 / -1; text-align: center;
  padding: 56px 24px; border: 1px dashed var(--border); border-radius: 14px; background: var(--surface);
}
.state-box h3 { margin: 14px 0 6px; font-size: 17px; color: var(--navy); }
.state-box p { margin: 0 0 18px; color: var(--muted); }
.state-icon {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  background: #fff; color: var(--teal); box-shadow: var(--shadow);
}
.state-icon svg { width: 24px; height: 24px; }
.state-box.is-error .state-icon { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--gradient); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--navy); }
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Users view ---------- */
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stats-row { flex-wrap: wrap; margin-bottom: 24px; }
.stats-row:empty { display: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: none; cursor: pointer;
  padding: 10px 14px; margin-bottom: -1px;
  color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tabs button:hover { color: var(--navy); }
.tabs button.is-active { color: var(--navy); font-weight: 600; border-bottom-color: var(--teal); }
.tabs button.is-active svg { color: var(--teal); }
.tab-count {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--surface); color: var(--muted);
}
.tabs button.is-active .tab-count { background: rgba(0, 128, 170, .1); color: var(--teal); }

.select-wrap { position: relative; }
.select-wrap[hidden], .segmented[hidden] { display: none; }
.select-wrap select {
  appearance: none; height: 40px; padding: 0 34px 0 12px; min-width: 150px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer;
}
.select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 6px; height: 6px; pointer-events: none;
  border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}
.select-wrap select:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 128, 170, .15); }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; box-shadow: 0 1px 2px rgba(16, 32, 64, .04); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.data-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #fafbfd; }

.user-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.user-email { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.you-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 999px; color: #fff; background: var(--gradient);
}
.muted { color: var(--muted); }
.muted-italic { font-style: italic; }

.avatar {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  background: var(--navy);
}
.avatar-creator { background: var(--teal); }
.avatar-reader { background: #7e8da3; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

.role-badge {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  color: var(--navy); background: rgba(33, 68, 120, .1); cursor: help;
}
.role-creator { color: var(--teal); background: rgba(0, 128, 170, .1); }
.role-reader { color: #5b6a80; background: #eef1f5; }

.chip-link { cursor: pointer; }
.chip-link:hover { border-color: var(--teal); color: var(--teal); }

.table-skeleton { padding: 8px 18px; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.team-card {
  display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  transition: box-shadow .2s, border-color .2s; animation: card-in .35s ease both;
}
.team-card:hover { box-shadow: 0 10px 30px rgba(33, 68, 120, .12); border-color: rgba(0, 128, 170, .35); }
.team-card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 10px; }
.team-card-head .card-icon { background: var(--gradient); }
.member-list { list-style: none; margin: 0; padding: 4px 18px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.member-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-empty { margin: 0; padding: 4px 18px 14px; font-size: 13px; flex: 1; }
.team-card-foot {
  display: flex; justify-content: space-between; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(16, 32, 64, .45); backdrop-filter: blur(2px);
  animation: fade-in .15s ease both;
}
.modal-overlay.is-leaving { animation: fade-out .15s ease both; }
.modal {
  width: 100%; max-width: 480px; background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(16, 32, 64, .3); animation: modal-in .2s ease both;
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px 8px; }
.modal-title { margin: 0; font-size: 18px; color: var(--navy); }
.modal-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 12px 24px 8px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field-optional { color: var(--muted); font-weight: 400; }
.field-hint { margin: 0; color: var(--muted); font-size: 13px; }
.input {
  height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 128, 170, .15); }
.form-error {
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
  color: var(--danger); background: rgba(200, 68, 60, .08); border: 1px solid rgba(200, 68, 60, .2);
}
.form-error[hidden] { display: none; }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.check-chip span {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; transition: all .15s;
}
.check-chip span svg { width: 14px; height: 14px; display: none; }
.check-chip span:hover { border-color: var(--teal); color: var(--teal); }
.check-chip input:checked + span { background: var(--gradient); color: #fff; border-color: transparent; }
.check-chip input:checked + span svg { display: block; }
.check-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }

.role-picker { border: 0; margin: 0; padding: 0; min-width: 0; gap: 8px; }
.role-picker legend { font-weight: 600; font-size: 13px; padding: 0; margin-bottom: 6px; }
.role-option { display: block; }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }
.role-option-box {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.role-option-box .role-badge { min-width: 72px; text-align: center; cursor: pointer; }
.role-option-desc { flex: 1; color: var(--muted); font-size: 13px; }
.role-option-check {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border);
  display: grid; place-items: center; color: transparent; flex-shrink: 0;
}
.role-option-check svg { width: 12px; height: 12px; }
.role-option-box:hover { border-color: rgba(0, 128, 170, .5); }
.role-option input:checked + .role-option-box { border-color: var(--teal); background: rgba(0, 128, 170, .05); }
.role-option input:checked + .role-option-box .role-option-check { background: var(--gradient); border-color: transparent; color: #fff; }
.role-option input:focus-visible + .role-option-box { box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }

/* ---------- Team member management ---------- */
.team-card-foot { gap: 4px; flex-wrap: wrap; }
.tm-list {
  list-style: none; margin: 0; padding: 4px; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.tm-list-scroll { max-height: 220px; overflow-y: auto; }
.tm-list > li[hidden] { display: none; }
.tm-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  transition: background .15s, opacity .15s;
}
.tm-row:hover { background: var(--surface); }
.tm-row .user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tm-row .user-name, .tm-row .user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-row .user-name { font-size: 13px; }
.tm-row .user-email { font-size: 12px; }
.tm-search { max-width: none; min-width: 0; height: 36px; }
.tm-no-match { padding: 10px; text-align: center; font-size: 13px; }

.tm-btn {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.tm-btn svg { width: 14px; height: 14px; }
.tm-btn-remove { color: var(--danger); }
.tm-btn-remove:hover { background: rgba(200, 68, 60, .08); border-color: rgba(200, 68, 60, .35); }
.tm-btn-undo { color: var(--navy); display: none; }
.tm-btn-undo:hover { border-color: var(--teal); color: var(--teal); }
.tm-pending-badge {
  display: none; font-size: 11px; font-weight: 600; color: var(--danger);
  background: rgba(200, 68, 60, .08); padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.tm-row.is-removed { background: rgba(200, 68, 60, .04); }
.tm-row.is-removed .avatar, .tm-row.is-removed .user-info { opacity: .5; }
.tm-row.is-removed .user-name { text-decoration: line-through; }
.tm-row.is-removed .tm-btn-remove { display: none; }
.tm-row.is-removed .tm-btn-undo, .tm-row.is-removed .tm-pending-badge { display: inline-flex; }

.tm-row-check { cursor: pointer; font-weight: 400 !important; }
.tm-row-check input { position: absolute; opacity: 0; pointer-events: none; }
.tm-check {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border); flex-shrink: 0;
  display: grid; place-items: center; color: transparent; transition: all .15s;
}
.tm-check svg { width: 12px; height: 12px; }
.tm-row-check input:checked ~ .tm-check { background: var(--gradient); border-color: transparent; color: #fff; }
.tm-row-check input:focus-visible ~ .tm-check { box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }
.tm-row-check:has(input:checked) { background: rgba(0, 128, 170, .06); }

.tm-summary {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600;
}
.tm-summary[hidden] { display: none; }
.tm-summary span { display: inline-flex; align-items: center; gap: 6px; }
.tm-summary svg { width: 15px; height: 15px; }
.tm-sum-add { color: var(--teal); }
.tm-sum-remove { color: var(--danger); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px;
  background: #fff; border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(16, 32, 64, .18);
  font-weight: 500; animation: modal-in .2s ease both; border-left: 4px solid var(--success);
}
.toast svg { color: var(--success); flex-shrink: 0; }
.toast-error { border-left-color: var(--danger); }
.toast-error svg { color: var(--danger); }
.toast.is-leaving { animation: fade-out .25s ease both; }

/* ---------- Mobile ---------- */
.mobile-bar { display: none; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--navy); display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface); }
.backdrop { display: none; }

@media (max-width: 860px) {
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fff;
  }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: 240px;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 10px 40px rgba(16, 32, 64, .2); }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(16, 32, 64, .35); }
  .page { padding: 22px 16px 36px; }
  .search { max-width: none; }
}

/* Users table: actions column */
.data-table .col-actions { text-align: right; white-space: nowrap; width: 1%; }
.data-table .col-actions .link-btn { display: inline-flex; align-items: center; gap: 6px; }
.data-table .col-actions .link-btn svg { width: 16px; height: 16px; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.data-table .col-actions .row-icon-primary:hover { color: var(--teal); border-color: rgba(0, 128, 170, .35); background: rgba(0, 128, 170, .08); }
.data-table .col-actions .row-icon-btn {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 32px; height: 32px; border: 1px solid transparent; border-radius: 8px; background: none;
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.data-table .col-actions .row-icon-btn svg { width: 17px; height: 17px; }
.data-table .col-actions .row-icon-danger:hover { color: var(--danger); border-color: rgba(200, 68, 60, .35); background: rgba(200, 68, 60, .08); }
.data-table .col-actions .row-icon-btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(200, 68, 60, .25); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Table page (table.html) ---------- */
.tp-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; padding: 0 24px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative;
}
.tp-brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.tp-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--navy); font-weight: 600; font-size: 13px; text-decoration: none; transition: all .15s;
}
.tp-back:hover { border-color: var(--teal); color: var(--teal); }
.tp-main { background: #fff; }
.page-wide { max-width: 1600px; }
.tp-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tp-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--gradient); flex-shrink: 0; }
.tp-icon svg { width: 22px; height: 22px; }
.state-box .btn + .btn { margin-left: 8px; }
.toolbar[hidden] { display: none; }
.state-box .btn { text-decoration: none; }

/* Data grid */
.grid-panel { overflow: hidden; display: flex; flex-direction: column; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 200px; }
.data-grid { font-size: 13px; }
.data-grid thead th {
  position: sticky; top: 0; z-index: 2; padding: 0; white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border);
}
.data-grid td { padding: 9px 16px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.data-grid tbody tr:nth-child(even) { background: #fbfcfe; }
.data-grid tbody tr:hover { background: rgba(0, 128, 170, .06); }
.data-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-grid td.neg { color: var(--danger); }
.data-grid mark { background: rgba(0, 128, 170, .18); color: inherit; border-radius: 3px; padding: 0 1px; }

.sort-btn {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 11px 16px; border: 0; background: none; cursor: pointer;
  font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; text-align: left;
}
.data-grid th.num .sort-btn { justify-content: flex-end; }
.sort-btn:hover { color: var(--navy); }
.sort-btn:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px rgba(0, 128, 170, .35); }
.sort-icon path { fill: #c3cddb; transition: fill .15s; }
.sort-icon path.on { fill: var(--teal); }
th.is-sorted { color: var(--navy); }

.data-grid .col-index {
  position: sticky; left: 0; z-index: 1; width: 1%;
  text-align: right; color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--surface); border-right: 1px solid var(--border); padding: 9px 12px;
}
.data-grid thead .col-index { z-index: 3; padding: 11px 12px; }
.grid-empty { text-align: center; color: var(--muted); padding: 40px 16px !important; }

.grid-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--text);
}
.grid-pager { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.grid-size { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.select-sm select { height: 32px; min-width: 76px; padding: 0 28px 0 10px; }
.select-sm::after { right: 11px; }
.pager-btns { display: inline-flex; align-items: center; gap: 4px; }
.pager-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--navy); cursor: pointer; font-size: 16px; line-height: 1; transition: all .15s;
}
.pager-btn:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-info { padding: 0 8px; color: var(--muted); white-space: nowrap; }

@media (max-width: 720px) {
  .tp-header { padding: 0 16px; }
  .tp-back span { display: none; }
  .grid-scroll { max-height: calc(100vh - 340px); }
}

/* ---------- Table page: single scroll area (the grid) ----------
   The page itself fits the viewport; only the table body scrolls. */
.tp-main { display: flex; flex-direction: column; overflow-y: auto; }
.tp-main > .page-wide {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column;
  padding-bottom: 24px;
}
.tp-main > .page-wide > .page-header,
.tp-main > .page-wide > .toolbar { flex-shrink: 0; }
.tp-main > .page-wide > .grid-panel { flex: 1; min-height: 0; }
.tp-main .grid-scroll { flex: 1; min-height: 200px; max-height: none; }
.tp-main .grid-footer { flex-shrink: 0; }

@media (max-width: 720px) {
  .tp-main .grid-scroll { max-height: none; }
  .tp-main > .page-wide { padding-bottom: 16px; }
}


/* ---------- Auth / Invite page ---------- */
.auth-page { background: var(--surface); }
.auth-layout { flex: 1; display: flex; min-height: 100%; }
.auth-aside {
  width: 42%; max-width: 560px; flex-shrink: 0; position: relative; overflow: hidden;
  background: var(--gradient); color: #fff; display: flex; align-items: center; padding: 48px;
}
.auth-aside::before, .auth-aside::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .07);
}
.auth-aside::before { width: 420px; height: 420px; right: -160px; top: -120px; }
.auth-aside::after { width: 300px; height: 300px; left: -100px; bottom: -110px; }
.auth-aside-inner { position: relative; z-index: 1; max-width: 400px; }
.auth-aside-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.brand-logo-light { filter: brightness(0) invert(1); height: 28px; }
.brand-tag-light { background: rgba(255, 255, 255, .2); }
.auth-aside-title { margin: 0 0 28px; font-size: 28px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.auth-aside-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-aside-list li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: rgba(255, 255, 255, .92); }
.auth-aside-list svg {
  flex-shrink: 0; padding: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .16);
}

.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; overflow-y: auto; }
.auth-card {
  width: 100%; max-width: 460px; background: #fff; border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 36px 28px; box-shadow: 0 10px 40px rgba(33, 68, 120, .08);
  animation: modal-in .25s ease both;
}
.auth-logo { height: 28px; margin-bottom: 24px; }
.auth-title { margin: 0; font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -.01em; }
.auth-subtitle { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }

.company-badge {
  display: flex; align-items: center; gap: 12px; margin: 20px 0 22px;
  padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #eef3fa, #e6f4f9); border: 1px solid rgba(0, 128, 170, .18);
}
.company-badge-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center;
  color: #fff; background: var(--gradient);
}
.company-badge-text { display: flex; flex-direction: column; min-width: 0; }
.company-badge-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.company-badge-name { font-size: 16px; font-weight: 700; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-form .field { gap: 5px; }
.auth-form .input { width: 100%; }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(200, 68, 60, .15); }
.field-msg { font-size: 12px; color: var(--danger); min-height: 0; }
.field-msg:empty { display: none; }

.input-group { position: relative; }
.input-group .input { padding-right: 44px; }
.input-addon {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 36px;
  display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); cursor: pointer; transition: color .15s, background .15s;
}
.input-addon:hover { color: var(--teal); background: var(--surface); }
.input-addon:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }

.strength { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.strength[data-score="0"] { display: none; }
.strength-bars { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-bars span { height: 4px; border-radius: 2px; background: var(--border); transition: background .2s; }
.strength-label { font-size: 12px; font-weight: 600; min-width: 48px; text-align: right; }
.strength[data-score="1"] .strength-bars span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="1"] .strength-label { color: var(--danger); }
.strength[data-score="2"] .strength-bars span:nth-child(-n+2) { background: #e0a030; }
.strength[data-score="2"] .strength-label { color: #b07a10; }
.strength[data-score="3"] .strength-bars span:nth-child(-n+3) { background: var(--teal); }
.strength[data-score="3"] .strength-label { color: var(--teal); }
.strength[data-score="4"] .strength-bars span { background: var(--success); }
.strength[data-score="4"] .strength-label { color: var(--success); }

.select-block select { width: 100%; }

.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 18px; font-size: 15px; margin-top: 6px; }
.auth-foot { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-foot a { color: var(--teal); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.auth-state { border: 0; background: transparent; padding: 24px 8px; }
.auth-success { text-align: center; }
.auth-success .auth-subtitle { margin: 10px 0 26px; }
.auth-success-icon {
  display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: 18px;
  border-radius: 50%; color: #fff; background: var(--gradient);
  box-shadow: 0 8px 24px rgba(0, 128, 170, .3);
}
.auth-success-icon svg { width: 28px; height: 28px; }

@media (max-width: 900px) {
  .auth-aside { display: none; }
}
@media (max-width: 520px) {
  .auth-main { padding: 20px 12px; align-items: flex-start; }
  .auth-card { padding: 26px 20px 22px; }
  .field-row { grid-template-columns: 1fr; }
}

.auth-redirect {
  display: inline-flex; align-items: center; gap: 8px; margin: -10px 0 20px;
  font-size: 13px; color: var(--muted);
}
.auth-redirect-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(0, 128, 170, .25); border-top-color: var(--teal);
  animation: spin .7s linear infinite;
}


/* ---------- Sign page: tabs, steps, pin ---------- */
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.auth-tab {
  display: flex; align-items: center; justify-content: center; height: 38px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none;
  transition: color .15s, background .15s, box-shadow .15s;
}
.auth-tab:hover { color: var(--navy); }
.auth-tab.is-active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(33, 68, 120, .12); }
.auth-tab:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }

.auth-form-spaced { margin-top: 22px; }
.form-error a { color: inherit; font-weight: 700; text-decoration: underline; }

.auth-steps {
  list-style: none; margin: 0 0 22px; padding: 0; display: flex; align-items: center; gap: 8px;
}
.auth-step { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 12px; font-weight: 600; color: var(--muted); }
.auth-step:not(:last-child)::after {
  content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--border); margin-left: 4px;
}
.auth-step.is-done:not(:last-child)::after { background: var(--teal); }
.auth-step:last-child { flex: 0 0 auto; }
.auth-step-dot {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; border: 2px solid var(--border); background: #fff; color: var(--muted);
}
.auth-step-dot svg { width: 13px; height: 13px; }
.auth-step.is-current { color: var(--navy); }
.auth-step.is-current .auth-step-dot { border-color: var(--teal); color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 128, 170, .15); }
.auth-step.is-done .auth-step-dot { border-color: transparent; background: var(--gradient); color: #fff; }

.auth-email { color: var(--navy); word-break: break-all; }

.pin-input {
  text-align: center; font-size: 24px !important; font-weight: 700; letter-spacing: .5em;
  height: 56px; padding-left: .5em !important; color: var(--navy); font-variant-numeric: tabular-nums;
}
.pin-input::placeholder { color: #c3cddb; letter-spacing: .5em; }

.auth-actions-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 2px; border: 0; background: none;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--teal); cursor: pointer; border-radius: 6px;
}
.link-btn:hover:not(:disabled) { color: var(--navy); }
.link-btn:disabled { color: var(--muted); cursor: default; font-weight: 500; }
.link-btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(0, 128, 170, .25); }

.email-verified {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 20px; padding: 10px 12px;
  border-radius: 10px; background: linear-gradient(135deg, #eef3fa, #e6f4f9); border: 1px solid rgba(0, 128, 170, .18);
}
.email-verified-icon { color: var(--teal); display: grid; place-items: center; }
.email-verified-text { flex: 1; min-width: 0; font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-verified-badge {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--success); background: rgba(255, 255, 255, .8);
}
.email-verified-badge svg { width: 12px; height: 12px; }

@media (max-width: 520px) {
  .auth-step-label { display: none; }
}

/* ---------- Usage view ---------- */
.section-title {
  margin: 0 0 14px; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
[data-ref="team"]:not(:empty) { margin-top: 36px; }

.reset-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border-radius: 999px; background: rgba(0, 128, 170, .08); color: var(--teal);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.reset-pill svg { width: 16px; height: 16px; }
.header-actions { align-items: center; }

.usage-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.usage-card {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  padding: 20px 22px; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04); overflow: hidden;
  animation: card-in .35s ease both;
}
.usage-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--gradient);
}
.usage-card-head { display: flex; align-items: center; gap: 12px; }
.usage-card-head .card-icon { background: var(--gradient); color: #fff; }
.usage-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.usage-card-title .card-title { margin: 0; }

.usage-figures { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.usage-big { font-size: 34px; font-weight: 700; color: var(--navy); letter-spacing: -.02em; line-height: 1; }
.usage-of { color: var(--muted); }
.usage-pct { margin-left: auto; font-size: 18px; font-weight: 700; }

.usage-kv {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.usage-kv div { display: flex; flex-direction: column; gap: 2px; }
.usage-kv dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.usage-kv dd { margin: 0; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.usage-alert {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 8px;
  font-size: 13px; color: var(--danger); background: rgba(200, 68, 60, .08); border: 1px solid rgba(200, 68, 60, .2);
}
.usage-alert svg { flex-shrink: 0; width: 16px; height: 16px; }

/* Meter */
.meter { position: relative; width: 100%; background: #edf1f6; border-radius: 999px; overflow: hidden; }
.meter-sm { height: 8px; }
.meter-lg { height: 12px; }
.meter-fill {
  display: block; height: 100%; border-radius: inherit; background: var(--gradient);
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.meter-warn .meter-fill { background: linear-gradient(90deg, #e0a32e, #f0b84a); }
.meter-danger .meter-fill { background: linear-gradient(90deg, #e07a3a, #e5603c); }
.meter-over .meter-fill { background: linear-gradient(90deg, #c8443c, #e0574e); }
.meter-unlimited .meter-fill {
  background: repeating-linear-gradient(45deg, rgba(0, 128, 170, .18) 0 6px, rgba(0, 128, 170, .08) 6px 12px);
}

.level-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .05em;
}
.level-ok { color: var(--success); background: rgba(31, 157, 107, .1); }
.level-warn { color: #b07a12; background: rgba(224, 163, 46, .14); }
.level-danger { color: #c45a20; background: rgba(224, 122, 58, .14); }
.level-over { color: var(--danger); background: rgba(200, 68, 60, .1); }
.level-unlimited { color: var(--teal); background: rgba(0, 128, 170, .1); }

.level-text-ok { color: var(--navy); }
.level-text-warn { color: #b07a12; }
.level-text-danger { color: #c45a20; }
.level-text-over { color: var(--danger); }

/* Stats */
.stat-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-warn .stat-value { color: #b07a12; }
.stat-danger .stat-value { color: var(--danger); }

/* Table */
.usage-table .col-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.usage-table .col-meter { width: 32%; min-width: 200px; }
.meter-cell { display: flex; align-items: center; gap: 12px; }
.meter-cell .meter { flex: 1; }
.meter-pct { min-width: 42px; text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .usage-cards { grid-template-columns: 1fr; }
  .usage-big { font-size: 28px; }
  .reset-pill { height: auto; padding: 8px 12px; white-space: normal; }
}


/* ---------- Billing view ---------- */
.billing-top {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px;
  margin-bottom: 36px; align-items: start;
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.pm-wrap {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04); animation: card-in .35s ease both;
}
.pm-card {
  position: relative; width: 280px; max-width: 100%; aspect-ratio: 1.586; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px 20px; border-radius: 14px; color: #fff; overflow: hidden;
  background: var(--gradient);
  box-shadow: 0 12px 28px rgba(33, 68, 120, .28);
}
.pm-card::after {
  content: ""; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px;
  border-radius: 50%; background: rgba(255, 255, 255, .1); pointer-events: none;
}
.pm-card::before {
  content: ""; position: absolute; width: 180px; height: 180px; left: -60px; bottom: -110px;
  border-radius: 50%; background: rgba(255, 255, 255, .07); pointer-events: none;
}
.pm-amex { background: linear-gradient(135deg, #1d5f8a, #0080AA 60%, #2ba3c9); }
.pm-visa { background: linear-gradient(135deg, #172f54, #214478 60%, #2d5ba0); }
.pm-mastercard { background: linear-gradient(135deg, #1c2533, #33405a 60%, #214478); }
.pm-discover { background: linear-gradient(135deg, #214478, #3a6aa8); }
.pm-card-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.pm-chip {
  width: 36px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, #f3d98b, #c9a24a);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.pm-brand { font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; opacity: .95; }
.pm-number {
  position: relative; z-index: 1; font-size: 18px; font-weight: 600; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pm-card-bottom { display: flex; justify-content: space-between; position: relative; z-index: 1; }
.pm-card-bottom div { display: flex; flex-direction: column; }
.pm-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.pm-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.pm-skeleton { box-shadow: none; }

.pm-details { flex: 1; min-width: 200px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.pm-details div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.pm-details div:last-child { border-bottom: 0; padding-bottom: 0; }
.pm-details dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.pm-details dd { margin: 0; font-weight: 600; text-align: right; }

.pm-empty {
  display: flex; align-items: center; gap: 16px; padding: 22px;
  border: 1px dashed var(--border); border-radius: 14px; background: var(--surface);
}
.pm-empty strong { color: var(--navy); }
.pm-empty p { margin: 4px 0 0; font-size: 13px; }

.billing-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.billing-summary .stat { padding: 16px 18px; border-radius: 14px; gap: 4px; }
.billing-summary .stat:first-child { grid-column: 1 / -1; }
.billing-summary .stat:first-child .stat-value { font-size: 26px; }

.billing-table .col-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.billing-table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.invoice-icon { background: rgba(0, 128, 170, .1); color: var(--teal); flex-shrink: 0; }
.invoice-icon svg { width: 16px; height: 16px; }
.invoice-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }
.btn-sm { padding: 6px 12px; font-size: 13px; text-decoration: none; }
.btn-sm svg { width: 14px; height: 14px; }

@media (max-width: 900px) {
  .billing-top { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .pm-wrap { padding: 16px; }
  .pm-card { width: 100%; }
}


/* ---------- Subscription view ---------- */
.sub-current {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04); animation: card-in .35s ease both;
}
.sub-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px;
  padding: 24px 26px; color: #fff; background: var(--gradient); min-height: 200px;
}
.sub-hero::after {
  content: ""; position: absolute; width: 240px; height: 240px; right: -80px; top: -110px;
  border-radius: 50%; background: rgba(255, 255, 255, .1); pointer-events: none;
}
.sub-hero::before {
  content: ""; position: absolute; width: 180px; height: 180px; left: -70px; bottom: -120px;
  border-radius: 50%; background: rgba(255, 255, 255, .07); pointer-events: none;
}
.sub-hero > * { position: relative; z-index: 1; }
.sub-hero-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sub-hero-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, .18);
}
.sub-hero-icon svg { width: 20px; height: 20px; }
.sub-active { color: #fff; background: rgba(255, 255, 255, .2); }
.sub-hero-name { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.sub-hero-tagline { margin: 0; opacity: .85; font-size: 13px; }
.sub-hero-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 14px; flex-wrap: wrap; }
.sub-hero-amount { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.sub-hero-per { opacity: .8; font-size: 13px; }
.sub-skeleton { border-radius: 0; background: #edf1f6; }

.sub-details {
  margin: 0; padding: 18px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-content: center;
}
.sub-details div {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.sub-details div:nth-last-child(-n+1) { border-bottom: 0; }
.sub-details dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.sub-details dd { margin: 0; font-size: 16px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.sub-details dd .muted { font-size: 13px; font-weight: 500; }
.sub-details .sk-line { margin: 10px 0; }

.sub-plans-head { margin-top: 36px; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; align-items: stretch; }
.plan-card {
  position: relative; display: flex; flex-direction: column; gap: 16px;
  padding: 24px 22px 22px; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 32, 64, .04);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  animation: card-in .35s ease both;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(33, 68, 120, .12); border-color: rgba(0, 128, 170, .35); }
.plan-card.is-featured { border-color: rgba(0, 128, 170, .35); }
.plan-card.is-current { border: 2px solid var(--teal); padding: 23px 21px 21px; box-shadow: 0 10px 30px rgba(0, 128, 170, .12); }
.plan-ribbon {
  position: absolute; top: -11px; left: 22px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--gradient); box-shadow: 0 4px 12px rgba(0, 128, 170, .3);
}
.plan-ribbon-alt { background: #fff; color: var(--teal); border: 1px solid rgba(0, 128, 170, .35); box-shadow: none; }
.plan-head { display: flex; flex-direction: column; gap: 4px; }
.plan-name { margin: 0; font-size: 18px; font-weight: 700; color: var(--navy); }
.plan-tagline { margin: 0; color: var(--muted); font-size: 13px; min-height: 36px; }
.plan-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.plan-amount { font-size: 30px; font-weight: 700; color: var(--navy); letter-spacing: -.02em; line-height: 1.1; }
.plan-amount.is-custom { font-size: 24px; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plan-per { color: var(--muted); font-size: 13px; }
.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.plan-features li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.plan-features svg {
  flex-shrink: 0; width: 18px; height: 18px; padding: 3px; border-radius: 50%;
  color: var(--teal); background: rgba(0, 128, 170, .1);
}
.plan-action .btn { justify-content: center; text-decoration: none; }
.plan-action .btn:disabled { cursor: default; opacity: 1; color: var(--teal); border-color: rgba(0, 128, 170, .3); background: rgba(0, 128, 170, .06); }
.plan-card > .sk-line { display: block; }

.plan-note { display: flex; align-items: center; gap: 8px; margin: 20px 0 0; font-size: 13px; }
.plan-note svg { flex-shrink: 0; width: 16px; height: 16px; }

.plan-change { display: flex; align-items: stretch; gap: 12px; }
.plan-change-box {
  flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.plan-change-box.is-new { border-color: rgba(0, 128, 170, .35); background: rgba(0, 128, 170, .05); }
.plan-change-box strong { color: var(--navy); }
.plan-change-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.plan-change-arrow { align-self: center; color: var(--teal); font-size: 20px; font-weight: 700; }
.plan-change-details { gap: 10px; }

/* Analysts seat selector (Pro upgrade) */
.seat-field {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.seat-field-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.seat-field-text .field-hint { margin: 0; }
.seat-label { font-weight: 600; color: var(--navy); font-size: 14px; }
.seat-stepper {
  display: inline-flex; align-items: stretch; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.seat-stepper:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 128, 170, .15); }
.seat-btn {
  width: 38px; border: 0; background: var(--surface); color: var(--navy);
  font-size: 18px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.seat-btn:hover:not(:disabled) { background: rgba(0, 128, 170, .1); color: var(--teal); }
.seat-btn:disabled { opacity: .4; cursor: not-allowed; }
.seat-input {
  width: 64px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  text-align: center; font: inherit; font-size: 16px; font-weight: 700; color: var(--navy);
  font-variant-numeric: tabular-nums; padding: 8px 4px; outline: none; -moz-appearance: textfield;
}
.seat-input::-webkit-outer-spin-button, .seat-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.seat-info { display: flex; align-items: center; gap: 8px; margin: 8px 2px 0; font-size: 12px; color: var(--muted); }
.seat-info svg { flex-shrink: 0; width: 14px; height: 14px; color: var(--teal); }
.seat-info.is-warning { color: #9a6700; }
.seat-info.is-warning svg { color: #d4a72c; }
.seat-summary {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  background: rgba(0, 128, 170, .05); border: 1px solid rgba(0, 128, 170, .2);
}
.seat-summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); padding: 4px 0; font-variant-numeric: tabular-nums; }
.seat-summary-row.is-total { margin-top: 6px; padding-top: 10px; border-top: 1px solid rgba(0, 128, 170, .2); color: var(--navy); font-weight: 600; font-size: 14px; }
.seat-summary-row.is-total strong { font-size: 18px; color: var(--navy); }
@media (max-width: 520px) {
  .seat-field { flex-direction: column; align-items: stretch; }
  .seat-stepper { align-self: flex-start; }
}

@media (max-width: 900px) {
  .sub-current { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .sub-details { grid-template-columns: 1fr; padding: 12px 20px; }
  .sub-details div:nth-last-child(-n+1) { border-bottom: 0; }
  .sub-hero { padding: 20px; }
}
