/* Client Hunt Command Center — premium local-first UI */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e6eb;
  --text: #111318;
  --muted: #5c6370;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --success: #0f766e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 19, 24, 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  --sidebar-w: 220px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

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

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
}

.brand {
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.brand-title {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover {
  background: var(--bg);
}
.nav-btn.active {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
  font-weight: 600;
}
.nav-btn svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.safety-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  max-width: 420px;
}
.safety-badge strong {
  color: var(--text);
  font-weight: 600;
}

.content {
  padding: 20px 24px 48px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1024px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    min-height: auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .app-shell {
    flex-direction: column;
  }
}

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

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}
.card-hint {
  font-size: 12px;
  color: var(--muted);
}

.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="url"],
input[type="email"],
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
textarea {
  min-height: 120px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: #111318;
  color: #fff;
  border-color: #111318;
}
.btn-primary:hover:not(:disabled) {
  background: #000;
}
.btn-secondary {
  background: #fff;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}
.chip-hot {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}
.chip-ok {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 520px;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th,
table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}
table.data th {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 1;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}
table.data tr:hover td {
  background: #fafbff;
}
table.data tr.selected td {
  background: var(--accent-soft);
}
table.data tr.overdue td {
  box-shadow: inset 3px 0 0 var(--danger);
}

.sticky-context {
  position: sticky;
  top: 58px;
  z-index: 15;
  background: linear-gradient(to bottom, var(--bg), var(--bg) 90%, transparent);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.context-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 12px;
}
.context-card .sep {
  color: var(--border);
}

.collapsible summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
  list-style: none;
}
.collapsible summary::-webkit-details-marker {
  display: none;
}
.collapsible summary::before {
  content: "▸ ";
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.15s;
}
.collapsible[open] summary::before {
  transform: rotate(90deg);
}

.pre-block {
  font-family: var(--mono);
  font-size: 11px;
  background: #0b1020;
  color: #e5e7eb;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 280px;
}

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 220px;
  max-width: 360px;
  background: #111318;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.2s ease;
}
.toast.info {
  background: #111318;
}
.toast.warn {
  background: #92400e;
}
.toast.err {
  background: #7f1d1d;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #fafafa;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.meter {
  font-size: 12px;
  color: var(--muted);
}
.meter strong {
  color: var(--text);
}

.warn-banner {
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 12px;
}

.privacy-banner {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
}
.stat .n {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.stat .l {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.icon-inline {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

hr.soft {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.sequence-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}
.sequence-step h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
}
