/* ============================================================
   InsuranceAgentHub — application shell layout.
   Builds on tokens.css (the design source of truth).
   ============================================================ */

html, body, #app { height: 100%; }

.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar (navy) ---------- */
.sidebar {
  width: 248px; flex: none; height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--nav-bg-top), var(--nav-bg-bot));
  border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--nav-line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(150deg, #C9A227, #9C7314);
  box-shadow: 0 2px 8px rgba(201,162,39,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
}
.brand-name { color: #fff; font-size: 14px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.1; }
.brand-name span { color: #C9A227; }
.brand-sub { color: #6B7689; font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin-top: 1px; }

.ws-switch {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px; margin-top: 14px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px; cursor: default; text-align: left;
}
.ws-ic { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; }
.ws-name { color: #F4F7FB; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-meta { color: #6B7689; font-size: 10.5px; font-weight: 500; }

.nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; }
.nav-group { margin-bottom: 14px; }
.nav-group-label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: #525C6E; padding: 0 10px 6px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  border: none; cursor: pointer; background: transparent; color: var(--nav-fg);
  font-family: var(--ff); font-size: 13px; font-weight: 500; position: relative;
  transition: background .12s, color .12s; text-decoration: none; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: #C7D0DE; }
.nav-item.active { background: var(--nav-active-bg); color: #F4F7FB; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 99px; background: var(--nav-active-line); }
.nav-item .nav-ic { display: grid; place-items: center; width: 18px; height: 18px; }
.nav-item .nav-label { flex: 1; text-align: left; white-space: nowrap; }
.nav-badge { font-family: var(--ff-mono); font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: rgba(255,255,255,0.07); color: #8A95A6; }
.nav-item.active .nav-badge { background: rgba(255,255,255,0.14); color: #fff; }
.nav-alert { width: 6px; height: 6px; border-radius: 99px; background: var(--red); }

.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--nav-line); }
.credits { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 10px; padding: 11px; margin-bottom: 11px; }
.credits-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.credits-top span:first-child { color: #C7D0DE; font-size: 11.5px; font-weight: 600; }
.credits-top span:last-child { font-family: var(--ff-mono); font-size: 11px; color: #8A95A6; }
.credits-bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.credits-bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6D5AE6, #9D8BFF); }
.credits-meta { color: #6B7689; font-size: 10.5px; margin-top: 7px; }
.user-foot { display: flex; align-items: center; gap: 9px; }
.user-foot .un { color: #F4F7FB; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-foot .ur { color: #6B7689; font-size: 10.5px; }

/* ---------- Main column ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; color: var(--t1); line-height: 1.1; }
.topbar-sub { font-size: 11.5px; color: var(--t4); }
.cmd {
  margin-left: 8px; flex: 1; max-width: 460px; height: 38px; display: flex; align-items: center; gap: 9px;
  padding: 0 12px; background: #F1F3F6; border: 1px solid var(--line); border-radius: 10px; color: var(--t4); cursor: text;
}
.cmd span.q { flex: 1; text-align: left; font-size: 13px; }
.spacer { flex: 1; }

.workspace { flex: 1; overflow-y: auto; background: var(--bg); }
.page { padding: 22px 24px 40px; max-width: 1320px; }
.page-intro { margin-bottom: 18px; }
.impersonation-bar {
  background: var(--gold-soft); border-bottom: 1px solid var(--gold-line); color: var(--gold);
  font-size: 12.5px; font-weight: 600; padding: 8px 20px; display: flex; align-items: center; justify-content: space-between;
}

/* ---------- Layout grids / KPI ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.kpi { padding: 16px 18px; }
.kpi .eyebrow { margin-bottom: 8px; }
.kpi .val { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; color: var(--t1); font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--t3); margin-top: 4px; }
.card-body { padding: 16px 18px; }

/* stage chips row */
.stage-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-chip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.stage-chip .n { font-family: var(--ff-mono); font-weight: 600; color: var(--t1); }
.stage-chip .l { font-size: 12px; color: var(--t3); }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--t2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; font-family: var(--ff); font-size: 13px; color: var(--t1);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-sm); transition: border-color .14s, box-shadow .14s;
}
.textarea { height: auto; padding: 9px 11px; min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* flash */
.flash { padding: 11px 14px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.flash-error { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, var(--nav-bg-top), var(--nav-bg-bot)); padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: var(--r-xl); box-shadow: var(--sh-pop); padding: 30px 30px 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 19px; font-weight: 680; letter-spacing: -0.02em; color: var(--t1); }
.auth-sub { font-size: 13px; color: var(--t3); margin: 4px 0 22px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--t3); }
.auth-foot a { color: var(--blue-600); text-decoration: none; }

.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: var(--r-sm); border: 1px solid var(--line); font-size: 12.5px; color: var(--t2); text-decoration: none; }
.pagination .on { background: #101A2C; border-color: #101A2C; color: #fff; }

.empty { text-align: center; padding: 48px 20px; color: var(--t3); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--panel); font-size: 12.5px; color: var(--t2); text-decoration: none; }
.filter-chip.on { background: #101A2C; border-color: #101A2C; color: #fff; }

a.plain { text-decoration: none; color: inherit; }

@media (max-width: 1024px) {
  .sidebar { width: 64px; }
  .brand-name, .brand-sub, .ws-name, .ws-meta, .nav-label, .nav-badge, .nav-group-label, .credits, .user-foot .un, .user-foot .ur { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
