:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1e2636;
  --border: #2a3446;
  --text: #e6ebf4;
  --muted: #8a94a7;
  --accent: #3b82f6;
  --accent-hover: #2f6fd6;
  --new: #f59e0b;
  --blocked: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }

/* --- Login --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; text-align: center; }
.login-card > p { margin: 0 0 8px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; }

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { background: var(--panel-2); color: var(--text); }
.user { display: flex; align-items: center; gap: 12px; }

main { max-width: 1080px; margin: 0 auto; padding: 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; }

/* --- Controls --- */
label { font-size: 13px; }
input, select, button { font-family: inherit; font-size: 14px; }
input, select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 10px; border-radius: 8px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
button {
  background: var(--accent); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: #28324a; }
.btn-danger-ghost { background: transparent; border: 1px solid transparent; color: var(--danger); padding: 6px 10px; }
.btn-danger-ghost:hover { background: rgba(239, 68, 68, .12); }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-form label { display: flex; flex-direction: column; gap: 6px; }
.grid-form .full { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; }
.form-msg { font-size: 13px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--blocked); }
.collapsed { display: none; }

.inline-form { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1; min-width: 180px; }
.inline-form button { flex: none; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 6px; }
.filters input, .filters select { width: auto; }
.filters .grow { flex: 1; min-width: 160px; }
.filters .grow input { width: 100%; }
.filter-actions { display: flex; gap: 8px; }

/* --- Events --- */
.events { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.event-card.is-new { border-left: 3px solid var(--new); }
.event-card.is-blocked { border-left: 3px solid var(--blocked); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.event-id { font-weight: 700; color: var(--muted); }
.event-project { font-weight: 600; }
.card-head button { margin-left: auto; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: .3px; }
.badge.new { background: rgba(245, 158, 11, .15); color: var(--new); }
.badge.blocked { background: rgba(34, 197, 94, .15); color: var(--blocked); }
.event-fields { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.event-fields .k { color: var(--muted); margin-right: 4px; }
.event-images { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.event-images img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.event-meta { display: flex; gap: 18px; color: var(--muted); font-size: 12px; flex-wrap: wrap; margin-top: 6px; }

/* --- Projects --- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card .card-head { justify-content: space-between; margin-bottom: 4px; }
.domains { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 6px 4px 12px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.chip button { background: transparent; color: var(--muted); border: none; padding: 0 4px; font-size: 16px; line-height: 1; }
.chip button:hover { color: var(--danger); background: transparent; }
.add-domain { margin-bottom: 0; }
.add-domain input { min-width: 120px; }

/* --- Operators --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--blocked); }
.switch input:checked + span::before { transform: translateX(18px); }

.error { color: var(--danger); font-size: 13px; }

@media (max-width: 640px) {
  .grid-form { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 12px; }
  main { padding: 12px; }
}
