:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;

  --status-new-bg: #fef2f2;
  --status-new-text: #b91c1c;
  --status-new-border: #fca5a5;

  --status-progress-bg: #fffbeb;
  --status-progress-text: #b45309;
  --status-progress-border: #fcd34d;

  --status-done-bg: #f3f4f6;
  --status-done-text: #6b7280;
  --status-done-border: #d1d5db;

  --vk-color: #2f5fa8;
  --tg-color: #229ed9;

  --client-a: #1d4ed8;
  --client-b: #7c3aed;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* Stats */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-card--accent {
  border-color: var(--status-new-border);
  background: linear-gradient(180deg, var(--status-new-bg), var(--surface) 70%);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12.5px;
}

.stat-sub {
  color: var(--text-faint);
}

/* Filters */

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
}

.filters input {
  min-width: 220px;
  flex: 1 1 220px;
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  background: #f9fafb;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Table */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

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

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #fafbfc;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #fafbfc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.col-date {
  white-space: nowrap;
}

.date-main {
  display: block;
  font-weight: 600;
  font-size: 13px;
}

.date-time {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
}

.source-name {
  max-width: 160px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-cell {
  max-width: 460px;
  color: var(--text);
}

.keyword {
  display: inline-block;
  background: #f1f2f4;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.link-open {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.link-open:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  color: var(--text-faint);
  padding: 40px 0;
}

/* Badges: source */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.badge-source-vk {
  background: var(--vk-color);
}

.badge-source-telegram {
  background: var(--tg-color);
}

/* Tags: client */

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag {
  color: var(--tag-color, var(--text-muted));
  background: color-mix(in srgb, var(--tag-color, var(--text-muted)) 10%, white);
  border-color: color-mix(in srgb, var(--tag-color, var(--text-muted)) 25%, white);
}

/* Status select styled as pill */

.status-form {
  margin: 0;
}

.status-select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 999px;
  padding: 5px 26px 5px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid;
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23888' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
}

.status-select--new {
  background-color: var(--status-new-bg);
  color: var(--status-new-text);
  border-color: var(--status-new-border);
}

.status-select--in_progress {
  background-color: var(--status-progress-bg);
  color: var(--status-progress-text);
  border-color: var(--status-progress-border);
}

.status-select--done {
  background-color: var(--status-done-bg);
  color: var(--status-done-text);
  border-color: var(--status-done-border);
}

tr.row-status-done {
  opacity: 0.6;
}

/* Admin */

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  display: inline-block;
  margin-bottom: 12px;
}

.back-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.add-project-form {
  display: flex;
  gap: 8px;
  margin: 20px 0 24px;
}

.add-project-form input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  min-width: 280px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  border-top: 3px solid var(--tag-color, var(--accent));
}

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

.project-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--tag-color, var(--text));
}

.project-delete-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}

.project-delete-btn:hover {
  color: var(--status-new-text);
  background: var(--status-new-bg);
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 20px;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f2f4;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12px;
}

.keyword-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  padding: 2px;
}

.keyword-chip button:hover {
  color: var(--status-new-text);
}

.keyword-empty {
  color: var(--text-faint);
  font-size: 12.5px;
}

.add-keyword-form {
  display: flex;
  gap: 6px;
}

.add-keyword-form input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}

.add-keyword-form button {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.add-keyword-form button:hover {
  background: #f9fafb;
}

/* Login */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.login-card h1 {
  font-size: 18px;
}

.login-card .subtitle {
  margin-bottom: 6px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.login-card input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-submit {
  justify-content: center;
  margin-top: 6px;
  padding: 10px;
}

.login-error {
  background: var(--status-new-bg);
  color: var(--status-new-text);
  border: 1px solid var(--status-new-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .page {
    padding: 16px;
  }
  .page-header {
    flex-direction: column;
  }
}
