:root {
  --accent: #d92d20;
  --accent-dark: #b42318;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #1f2937;
  --muted: #667085;
  --green: #12b76a;
  --amber: #f79009;
  --blue: #2e90fa;
  --red: #f04438;
  --gray: #98a2b3;
}

* { box-sizing: border-box; }

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

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.3px;
  color: var(--accent);
}
.sub { color: var(--muted); font-size: 13px; }

.scheduler-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.scheduler-pill.on  { background: #ecfdf3; color: var(--green); }
.scheduler-pill.off { background: #f2f4f7; color: var(--muted); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 28px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Grid + cards */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }

.hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.hint code, .card code {
  background: #f2f4f7;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--accent-dark);
}

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
label input, label textarea { color: var(--text); font-weight: 400; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 900px) { .row2, .row3 { grid-template-columns: 1fr; } }

input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,45,32,0.10); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

label.toggle { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
label.toggle input { width: auto; }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.spacer { flex: 1; }

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
button:hover { background: #f9fafb; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button.danger { color: var(--red); border-color: #fecdca; background: #fffbfa; }
button.danger:hover { background: #fef3f2; }
button.ghost { color: var(--muted); background: transparent; border-color: transparent; }
button.ghost:hover { background: #f2f4f7; }

.meta-line { color: var(--muted); font-size: 12px; margin: 6px 0 10px; }

/* Contacts table */
.table-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.table-head input[type="checkbox"] { width: auto; }
.table-head .count { color: var(--muted); font-size: 12px; }
.table-head input[type="text"] { width: auto; flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td:nth-child(2), td:nth-child(7) { overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.green  { background: #ecfdf3; color: var(--green); }
.badge.blue   { background: #eff8ff; color: var(--blue); }
.badge.amber  { background: #fffaeb; color: var(--amber); }
.badge.red    { background: #fef3f2; color: var(--red); }
.badge.gray   { background: #f2f4f7; color: var(--gray); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #101828;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #101828; }
.toast.err { background: var(--red); }

/* Top-right group + nav link */
.top-right { display: flex; align-items: center; gap: 12px; }
.navlink {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.navlink:hover { background: #f9fafb; color: var(--text); }
