:root {
  --bg: #0d0e1a;
  --bg2: #13152a;
  --border: #1e2240;
  --text: #ffffff;
  --text-muted: #6b7299;
  --accent: #4f6aff;
  --green: #00e676;
  --yellow: #ffd600;
  --red: #ff3d3d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

.access-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  text-align: center;
  padding: 40px;
}
.access-denied-icon { font-size: 48px; }
.access-denied-title { font-size: 20px; font-weight: 700; color: var(--text); }
.access-denied-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Widget ────────────────────────────────────────────── */

.widget-wrap {
  padding: 24px;
  max-width: 1100px;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.logo span { color: var(--accent); }

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

.period-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.period-btn.active,
.period-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sync-info {
  font-size: 12px;
  color: var(--text-muted);
}

.help-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent); }

.help-tooltip {
  display: none;
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}
.help-tooltip.open { display: block; }
.help-close {
  position: absolute;
  top: 10px; right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.help-close:hover { color: var(--text); }
.help-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.help-section { margin-bottom: 12px; }
.help-section:last-child { margin-bottom: 0; }
.help-label {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.help-period { margin-bottom: 3px; }
.help-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 4px;
}
.help-example {
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
}

/* ── Table ─────────────────────────────────────────────── */

.stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.stats-table th {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 16px 16px;
  white-space: nowrap;
}

.stats-table th.name-col {
  text-align: left;
  min-width: 180px;
}

.stats-table th .norm-label {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  margin-top: 2px;
}

.stats-table tr.manager-row td {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.stats-table tr.manager-row:first-of-type td { border-top: none; }

.manager-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
}

.gauge-cell {
  text-align: center;
}

/* ── Gauge ─────────────────────────────────────────────── */

.gauge-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.gauge-wrap canvas {
  display: block;
}

/* ── Circle Metric ─────────────────────────────────────── */

.circle-metric {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--border);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg2);
}

.circle-metric.has-value {
  border-color: var(--accent);
}

/* ── Revenue ───────────────────────────────────────────── */

.revenue-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

/* ── Status bar ────────────────────────────────────────── */

.status-bar {
  margin-top: 24px;
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-bar .ok { color: var(--green); }
.status-bar .err { color: var(--red); }

/* ── Admin ─────────────────────────────────────────────── */

.admin-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px;
}

.admin-wrap h1 {
  font-size: 22px;
  margin-bottom: 28px;
  font-weight: 700;
}

.admin-wrap h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.stage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.stage-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.stage-tag.selected {
  border-color: var(--accent);
  background: rgba(79,106,255,0.15);
  color: var(--accent);
}

.stage-funnel {
  font-size: 11px;
  color: var(--text-muted);
}

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success { background: rgba(0,230,118,0.1); color: var(--green); border: 1px solid rgba(0,230,118,0.3); }
.alert-error { background: rgba(255,61,61,0.1); color: var(--red); border: 1px solid rgba(255,61,61,0.3); }

.sync-status-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
}

.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
