/* Tokens lifted from the app's DESIGN.html so the panel reads as the same
   product. Flat only — no clay shadows, no 3D. */
:root {
  --primary:      #0284C7;
  --primary-dark: #0369A1;
  --primary-light:#E0F2FE;
  --body:         #0F172A;
  --muted:        #475569;
  --subtle:       #94A3B8;
  --border:       #E2E8F0;
  --border-soft:  #F1F5F9;
  --surface:      #FFFFFF;
  --canvas:       #F8FAFC;
  --success:      #16A34A;
  --success-bg:   #DCFCE7;
  --warning:      #D97706;
  --warning-bg:   #FEF3C7;
  --danger:       #DC2626;
  --danger-bg:    #FEE2E2;
  --font: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 10px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--body);
  background: var(--canvas); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--r-md); padding: 8px 14px;
  font-weight: 500; cursor: pointer; background: none; transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }
.btn-ghost { border-color: var(--border); background: var(--surface); color: var(--muted); }
.btn-ghost:not(:disabled):hover { border-color: var(--subtle); color: var(--body); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: none; cursor: pointer; color: var(--subtle);
  font-size: 24px; line-height: 1; padding: 4px 8px; border-radius: var(--r-sm);
}
.icon-btn:hover { background: var(--border-soft); color: var(--body); }

/* ---------- sign in ---------- */
.login-view { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 32px;
}
.login-mark {
  width: 40px; height: 40px; border-radius: var(--r-lg); background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
  margin-bottom: 20px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-error {
  background: var(--danger-bg); color: #991B1B; padding: 9px 12px;
  border-radius: var(--r-md); font-size: 13px; margin: 0 0 16px;
}

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--r-md); background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.brand-text { font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: none; background: none; border-radius: var(--r-md); cursor: pointer;
  color: var(--muted); font-weight: 500; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.nav-item:hover { background: var(--border-soft); color: var(--body); }
.nav-item.is-active { background: var(--primary-light); color: var(--primary-dark); }
.nav-count { margin-left: auto; font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.nav-item.is-active .nav-count { color: var(--primary-dark); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.who { padding: 0 6px 12px; min-width: 0; }
.who-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-email { font-size: 12px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px 28px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 19px; margin: 0; font-weight: 600; }
.page-sub { margin: 2px 0 0; color: var(--subtle); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: var(--subtle); }
.search input {
  width: 290px; max-width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 28px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md);
  padding: 5px 11px; font-size: 13px; color: var(--muted); cursor: pointer; font-weight: 500;
}
.chip:hover { border-color: var(--subtle); color: var(--body); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-n { opacity: .7; margin-left: 5px; font-variant-numeric: tabular-nums; }
.filter-sep { width: 1px; background: var(--border); margin: 2px 6px; }

.content { padding: 0 28px 28px; }
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding: 11px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--canvas);
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--body); }
.sort-arrow { color: var(--primary); margin-left: 4px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--border-soft); }
.cell-strong { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--subtle); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--subtle); }
.nowrap { white-space: nowrap; }
.dim { color: var(--subtle); }

.who-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--primary-light); color: var(--primary-dark);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-neutral { background: var(--border-soft); color: var(--muted); }
.badge-active  { background: var(--success-bg); color: #15803D; }
.badge-warn    { background: var(--warning-bg); color: #92400E; }
.badge-danger  { background: var(--danger-bg);  color: #991B1B; }
.badge-info    { background: var(--primary-light); color: var(--primary-dark); }

.state { padding: 48px 16px; text-align: center; color: var(--subtle); }
.state strong { display: block; color: var(--body); font-weight: 500; margin-bottom: 4px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary);
  display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px 0; flex-wrap: wrap; }
.pager-info, .pager-pos { font-size: 13px; color: var(--muted); }
.pager-controls { display: flex; align-items: center; gap: 10px; }

/* ---------- detail drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw; z-index: 21;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 17px; margin: 0; font-weight: 600; word-break: break-word; }
.drawer-head p { margin: 3px 0 0; font-size: 13px; color: var(--subtle); word-break: break-word; }
.drawer-body { overflow-y: auto; padding: 8px 22px 28px; }
.d-section { margin-top: 20px; }
.d-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--subtle);
  margin: 0 0 8px; font-weight: 600;
}
.d-row { display: flex; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.d-row:last-child { border-bottom: none; }
.d-key { flex: none; width: 132px; color: var(--muted); }
.d-val { flex: 1; min-width: 0; word-break: break-word; }
.d-note { background: var(--warning-bg); color: #92400E; padding: 9px 12px; border-radius: var(--r-md); font-size: 13px; margin-top: 12px; }
.d-link { color: var(--primary); cursor: pointer; text-decoration: none; font: inherit; background: none; border: none; padding: 0; }
.d-link:hover { text-decoration: underline; }
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border-soft); cursor: pointer;
}
.member-row:last-child { border-bottom: none; }
.member-row:hover .member-name { color: var(--primary); }
.member-main { min-width: 0; flex: 1; }
.member-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-email { font-size: 12px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; padding: 12px 16px; }
  .brand { padding: 0; }
  .nav { flex-direction: row; }
  .nav-item span:not(.nav-count) { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: none; display: flex; align-items: center; gap: 10px; }
  .who { display: none; }
  .topbar, .filters, .content { padding-left: 16px; padding-right: 16px; }
  .search input { width: 190px; }
}

/* ---------- delete confirmation ---------- */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { background: #B91C1C; }
.btn-danger-outline { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.btn-danger-outline:not(:disabled):hover { background: var(--danger-bg); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 30; }
.modal {
  position: fixed; z-index: 31; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  display: flex; flex-direction: column;
}
.modal-head { padding: 20px 22px 0; }
.modal-head h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.steps li {
  flex: 1; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--subtle); padding-bottom: 7px; border-bottom: 2px solid var(--border);
}
.steps li.is-active { color: var(--danger); border-bottom-color: var(--danger); }
.steps li.is-done { color: var(--muted); border-bottom-color: var(--muted); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-body p { margin: 0 0 12px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px; border-top: 1px solid var(--border);
}

.danger-note {
  background: var(--danger-bg); color: #991B1B; padding: 11px 13px;
  border-radius: var(--r-md); font-size: 13px; margin-bottom: 14px;
}
.info-note {
  background: var(--primary-light); color: var(--primary-dark); padding: 11px 13px;
  border-radius: var(--r-md); font-size: 13px; margin-bottom: 14px;
}
.impact-total { font-size: 26px; font-weight: 700; line-height: 1.1; }
.impact-total span { font-size: 13px; font-weight: 400; color: var(--muted); display: block; margin-top: 2px; }
.impact-list {
  margin: 14px 0 0; max-height: 210px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.impact-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px;
  font-size: 13px; border-bottom: 1px solid var(--border-soft);
}
.impact-row:last-child { border-bottom: none; }
.impact-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.impact-row.is-people { background: var(--danger-bg); color: #991B1B; }
.confirm-phrase {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: var(--border-soft); padding: 2px 6px; border-radius: var(--r-sm);
  user-select: all; word-break: break-all;
}
.confirm-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); outline: none; margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.confirm-input:focus { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.confirm-input.is-match { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.countdown { font-variant-numeric: tabular-nums; }
.drawer-danger { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- overview ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 15px 16px; }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.tile-value { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--subtle); margin-top: 2px; }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; }
.panel h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-sub { margin: 2px 0 14px; font-size: 12px; color: var(--subtle); }
.panel-wide { grid-column: 1 / -1; }

/* Legend: identity is never colour alone — the swatch sits beside a text label. */
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--subtle); font-size: 10px; font-family: var(--font); }
.chart .val-text { fill: var(--body); font-size: 10px; font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { transition: opacity .12s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar:hover { opacity: .78; }

.hbar-row { display: grid; grid-template-columns: 92px 1fr 40px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.hbar-track { background: var(--border-soft); border-radius: 3px; height: 9px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 3px; }
.hbar-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; }

.attn { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.attn:last-child { border-bottom: none; }
.attn-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.attn-n.is-zero { color: var(--subtle); font-weight: 400; }
.attn-names { font-size: 12px; color: var(--subtle); margin-top: 2px; }

/* ---------- audit log ---------- */
.audit-row { display: flex; gap: 13px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.audit-row:last-child { border-bottom: none; }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.audit-main { flex: 1; min-width: 0; }
.audit-what { font-size: 13px; }
.audit-meta { font-size: 12px; color: var(--subtle); margin-top: 2px; }
.audit-actions { flex: none; }

/* ---------- jobs in the company drawer ---------- */
.job-row { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border-soft); }
.job-row:last-child { border-bottom: none; }
.job-row.is-deleted .job-name, .job-row.is-deleted .job-meta { opacity: .55; text-decoration: line-through; }
.job-main { flex: 1; min-width: 0; }
.job-name { font-size: 13px; font-weight: 500; }
.job-meta { font-size: 12px; color: var(--subtle); margin-top: 1px; }
.danger-hint { margin: -4px 0 12px; font-size: 12px; color: var(--muted); }
