@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #f9fbff;
  --panel-3: #eef4ff;
  --line: #dde5f1;
  --line-soft: #eef2f7;
  --text: #162033;
  --muted: #66758a;
  --faint: #8b9aaf;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --danger: #ef4444;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(15, 23, 42, .07);
  --font-family: 'Outfit', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-family);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .09), transparent 30%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 42%);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1, h2, h3, p { margin-top: 0; }

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand-mark, .target-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .22);
}

.brand small, .hero-title p, .filter-title small, .muted-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 8px;
  flex: 1;
}

.topnav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 600;
}

.topnav a.active, .topnav a:hover {
  color: var(--primary);
  background: var(--panel-3);
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.userbar form { margin: 0; }

.user-avatar {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--primary);
  font-weight: 700;
}

.role-pill {
  padding: 4px 9px;
  border-radius: 999px;
  color: #1e40af;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  font-size: 12px;
  font-weight: 700;
}

.page { padding: 24px; }

.operations-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.filter-panel {
  position: sticky;
  top: 88px;
  min-height: calc(100vh - 112px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filter-title {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 700;
  font-size: 18px;
}

.filter-stack, .form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-group-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfdff;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
  font: inherit;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

button:disabled, input:disabled, select:disabled, textarea:disabled {
  opacity: .65;
  cursor: not-allowed;
  background: #f1f5f9;
}

.btn, button.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary { color: white; background: var(--primary); box-shadow: 0 10px 22px rgba(37, 99, 235, .18); }
.btn-primary:hover { background: var(--primary-2); color: white; }
.btn-secondary { color: #334155; background: #ffffff; border-color: var(--line); }
.btn-secondary:hover { color: var(--primary); border-color: #bfdbfe; background: #f8fbff; }
.btn-ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.btn-ghost:hover { color: var(--danger); background: #fff7f7; border-color: #fecaca; }
.full-width { width: 100%; }

.filter-actions-stack {
  display: grid;
  gap: 10px;
}

.sidebar-counter {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sidebar-counter span {
  padding: 12px;
  border-radius: var(--radius);
  background: #f8fbff;
  border: 1px solid var(--line-soft);
}

.sidebar-counter strong {
  display: block;
  font-size: 18px;
}

.sidebar-counter small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.operations-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-bar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-title, .hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-title h1 {
  margin-bottom: 2px;
  font-size: 24px;
  letter-spacing: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}

.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.metric-icon {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  font-weight: 800;
}

.metric-icon.blue { color: #1d4ed8; background: #dbeafe; }
.metric-icon.teal { color: #0f766e; background: #ccfbf1; }
.metric-icon.amber { color: #b45309; background: #fef3c7; }
.metric-icon.green { color: #15803d; background: #dcfce7; }

.table-panel, .card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.table-toolbar h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.table-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-toolbar span {
  color: var(--muted);
  white-space: nowrap;
}

.table-panel { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f8fafc;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 12px;
}

tbody tr:hover { background: #f8fbff; }
.locked-row { color: #475569; }
.company-name { color: var(--text); font-weight: 700; }
.empty-row { text-align: center; color: var(--muted); padding: 30px; }

.phone-cell {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 6px;
  color: #1d4ed8;
  background: #eff6ff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  cursor: pointer;
}

.owner-badge, .status-pill, .lock-note {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.owner-badge { color: #334155; background: #f1f5f9; border: 1px solid #e2e8f0; }
.owner-badge.mine { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.owner-badge.unassigned { color: #92400e; border-color: #fde68a; background: #fffbeb; }

.status-ready { color: #166534; background: #dcfce7; }
.status-pending-verification { color: #92400e; background: #fef3c7; }
.status-rejected { color: #991b1b; background: #fee2e2; }
.status-pill.neutral { color: #475569; background: #f1f5f9; }
.lock-note { color: #64748b; background: #f1f5f9; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
}

.icon-button:hover { border-color: #bfdbfe; background: #eff6ff; }
.icon-button.call { color: var(--danger); }

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.detail-header, .page-header {
  margin-bottom: 20px;
}

.detail-header h1, .page-header h1 { margin: 8px 0; }
.back-link { color: var(--muted); }
.lead-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); }

.detail-grid, .grid-2 {
  display: grid;
  grid-template-columns: minmax(420px, 1.35fr) minmax(320px, .9fr);
  gap: 18px;
}

.card {
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2 { margin: 0 0 4px; font-size: 18px; }
.card-header p { margin: 0; color: var(--muted); font-size: 13px; }

.inline-detail-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 { grid-column: 1 / -1; }

.detail-readonly {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #f8fafc;
}

.detail-readonly div {
  display: grid;
  gap: 3px;
}

.detail-readonly span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-readonly strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.assign-form {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.alert-success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.alert-warning { color: #92400e; background: #fffbeb; border-color: #fde68a; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.advanced-options {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
}

.toast {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .operations-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; min-height: auto; }
  .filter-group-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .hero-bar { align-items: stretch; flex-direction: column; }
  .hero-actions { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .topbar { height: auto; align-items: flex-start; flex-direction: column; padding: 14px; }
  .topnav, .userbar { width: 100%; flex-wrap: wrap; }
  .page { padding: 14px; }
  .metric-grid, .detail-grid, .grid-2, .form-row, .filter-group-card, .inline-detail-form, .detail-readonly { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .assign-form { grid-template-columns: 1fr; }
  .hero-actions .btn { width: 100%; }
}
