:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sidebar: #f1f3f4;
  --text: #202124;
  --muted: #5f6368;
  --line: #e2e4e7;
  --accent: #1a73e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Google Sans", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar h2 {
  margin: 0 6px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.nav-links {
  display: grid;
  gap: 3px;
}

.nav-links a {
  text-decoration: none;
  color: #3c4043;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 500;
}

.nav-links a.active,
.nav-links a:hover {
  background: #e8eaed;
  color: #111318;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 0 6px;
}

.content {
  padding: 20px 24px 30px;
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 16px;
}

h1, h2, h3 {
  margin: 0 0 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; color: #3c4043; }

form {
  display: grid;
  gap: 8px;
  max-width: 900px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  border: 1px solid #d6d9de;
  border-radius: 9px;
  background: #fff;
  color: #202124;
  padding: 9px 11px;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #8ab4f8;
  box-shadow: 0 0 0 2px #e8f0fe;
}

textarea {
  min-height: 86px;
  resize: vertical;
  line-height: 1.35;
}

button {
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: #3c4043;
  border-color: #d2d6db;
}

button:disabled {
  opacity: 0.72;
  cursor: wait;
}

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

.inline-row > input,
.inline-row > select,
.inline-row > button {
  flex: 1;
}

.status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.hidden { display: none; }

.counts {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.counts span {
  background: #f7f8f9;
  border: 1px solid #dde1e6;
  border-radius: 10px;
  padding: 6px 10px;
  color: #1f1f1f;
  font-weight: 500;
}

.lead {
  border: 1px solid #dfe3e8;
  border-radius: 11px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.lead h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.lead p { margin: 5px 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid #e1e4e8;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
  table-layout: fixed;
}

th, td {
  border-bottom: 1px solid #eceff3;
  border-right: 1px solid #eceff3;
  padding: 9px;
  vertical-align: top;
}

th:last-child, td:last-child { border-right: 0; }

th {
  background: #f8f9fb;
  color: #3c4043;
  text-align: left;
  font-weight: 600;
}

td textarea {
  min-height: 72px;
  font-size: 13px;
}

#lead-table .col-rownum { width: 3%; }
#lead-table .col-title { width: 37%; }
#lead-table .col-source { width: 8%; }
#lead-table .col-score { width: 5%; }
#lead-table .col-workflow { width: 11%; }
#lead-table .col-message { width: 36%; }

#lead-table td:nth-child(1) strong {
  display: inline-block;
  line-height: 1.35;
}

.lead-brief {
  font-size: 14px;
  line-height: 1.4;
  max-width: 100%;
  overflow: hidden;
}

.lead-brief-title {
  margin-bottom: 4px;
}

.lead-brief ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.lead-brief li {
  margin: 3px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#lead-table td:nth-child(2),
#lead-table th:nth-child(2) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#lead-table td:nth-child(2) a {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

#lead-table td:nth-child(4) textarea {
  min-height: 72px;
  max-width: 100%;
  width: 100%;
  resize: none;
  box-sizing: border-box;
}

#lead-table td:nth-child(5) textarea {
  min-height: 72px;
  max-width: 100%;
  width: 100%;
  resize: none;
  box-sizing: border-box;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid #d2d6db;
  background: #fff;
  color: #2663d3;
  font-size: 16px;
  padding: 0;
}

.icon-btn:hover {
  background: #eef4ff;
  border-color: #b6caf5;
}

.workflow-cell {
  min-width: 140px;
}

.workflow-row {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.workflow-row:last-child {
  margin-bottom: 0;
}

.workflow-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

.workflow-cell select,
.workflow-cell input[type="datetime-local"] {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  width: auto;
  min-width: 120px;
  max-width: 100%;
}

#lead-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

a { color: var(--accent); }

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
  }
}
