
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde5;
  --text: #16202a;
  --muted: #607080;
  --primary: #006f5f;
  --primary-strong: #004d43;
  --danger: #9b2d20;
  --danger-strong: #762116;
  --ok: #0c7a4b;
  --warn: #9a6a00;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.user-badge {
  color: var(--muted);
  font-size: 13px;
}
h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
h2 { margin: 28px 0 12px; font-size: 18px; letter-spacing: 0; }
p { margin: 6px 0 0; color: var(--muted); }
main { max-width: 1180px; margin: 0 auto; padding: 22px; }
.toolbar, .actions, .summary {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}
.custom-period {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; height: 38px; }
input, select {
  min-height: 38px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { background: var(--primary-strong); }
.button.secondary { background: #e7ecef; color: var(--text); }
.button.secondary:hover { background: #d7e0e5; }
.button.danger { background: var(--danger); }
.button.danger:hover { background: var(--danger-strong); }
.summary { align-items: stretch; }
.metric {
  min-width: 150px;
  border-right: 1px solid var(--line);
  padding-right: 14px;
}
.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 22px; }
.metric span { color: var(--muted); font-size: 13px; }
.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
td { font-size: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 650;
  font-size: 12px;
}
.badge.ok { background: #dff3ea; color: var(--ok); }
.badge.warn { background: #fff0c7; color: var(--warn); }
.badge.muted { background: #eef2f5; color: var(--muted); }
.jobs {
  display: grid;
  gap: 10px;
}
.job {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.job pre {
  margin: 10px 0 0;
  max-height: 220px;
  overflow: auto;
  background: #111820;
  color: #ecf3f7;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  background: #111820;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
}
.hidden { display: none; }
.meta-main {
  display: grid;
  grid-template-columns: minmax(280px, 430px) 1fr;
  gap: 16px;
  align-items: start;
}
.meta-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.meta-form {
  display: grid;
  gap: 12px;
}
.meta-form input,
.meta-form select,
.meta-form textarea {
  width: 100%;
  min-width: 0;
}
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
}
.integration-status {
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  font-weight: 650;
}
.integration-status.ok { background: #dff3ea; color: var(--ok); }
.integration-status.warn { background: #fff0c7; color: var(--warn); }
.send-now {
  justify-content: flex-start;
  height: auto;
}
.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.meta-events {
  display: grid;
  gap: 10px;
}
.event-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.event-main { font-weight: 650; }
.event-meta {
  color: var(--muted);
  font-size: 13px;
}
.event-error {
  color: var(--danger);
  background: #fff0ed;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  main { padding: 14px; }
  input, select { min-width: 100%; }
  .toolbar label { width: 100%; }
  .custom-period { width: 100%; }
  .button { width: 100%; }
  .meta-main { grid-template-columns: 1fr; padding: 12px; }
  .events-header { align-items: stretch; flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card p { margin-bottom: 18px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card input { width: 100%; min-width: 0; }
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
}
.auth-links a { color: var(--primary); font-weight: 650; text-decoration: none; }
.auth-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}
.auth-message.ok { color: var(--ok); }
