:root {
  --bg: #f4f6fb;
  --card-bg: #fff;
  --border: #e2e8f0;
  --text: #1f2933;
  --muted: #6c7a89;
  --accent: #2563eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 0 1.5rem 4rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.5rem 0 1.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--muted);
}

.current-user {
  background: #1d2433;
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  min-width: 220px;
  text-align: right;
}

.current-user strong {
  display: block;
  font-size: 1.1rem;
  margin-top: 0.3rem;
}

.card {
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  position: relative;
}

.card + .card {
  margin-top: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.card-header p {
  color: var(--muted);
  margin-top: 0.35rem;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  align-items: end;
}

.split-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input,
select,
button {
  font-family: inherit;
}

input,
select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.2s ease;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.6rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  font-weight: 600;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  text-align: center;
}

.color-dot {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.summary-total {
  background: rgba(37, 99, 235, 0.08);
  border-radius: 16px;
  padding: 1rem 1.5rem;
}

.summary-total h3 {
  font-size: 2rem;
  margin-top: 0.3rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.summary-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.summary-card strong {
  font-size: 1.4rem;
}

.summary-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.summary-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.summary-progress {
  margin-top: 0.5rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.progress-fill.status-ok {
  background: var(--ok);
}

.progress-fill.status-warning {
  background: var(--warn);
}

.progress-fill.status-exceeded {
  background: var(--danger);
}

.progress-fill.status-no_limit {
  background: var(--muted);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.summary-card .status-pill {
  align-self: flex-start;
}

.status-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: #fff;
}

.status-ok {
  background: var(--ok);
}

.status-warning {
  background: var(--warn);
}

.status-exceeded {
  background: var(--danger);
}

.status-no_limit {
  background: var(--muted);
  color: #fff;
}

.status-period {
  background: #7c3aed;
}

.status-category {
  background: #3b82f6;
}

.map {
  height: 420px;
  border-radius: 16px;
  overflow: hidden;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1f2933;
  color: #fff;
  padding: 0.9rem 1.2rem;
  border-radius: 12px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toast.is-visible {
  opacity: 0.95;
}

[data-requires-user].is-locked::after {
  content: "Сначала выберите пользователя";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--muted);
}

[data-requires-user].is-locked > *:not(.card-header) {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.summary-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
}

.summary-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.summary-form input {
  min-width: 150px;
}

.status-legend {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.legend-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-content strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
}

.legend-content span {
  color: var(--muted);
  font-size: 0.8rem;
}

.mt-24 {
  margin-top: 1.5rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.chart-block {
  background: rgba(15, 23, 42, 0.02);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 320px;
}

.chart-block canvas {
  width: 100%;
  max-height: 260px;
}

.chart-empty {
  text-align: center;
  margin-top: auto;
}

.insights-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.insight-item {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.insight-badge {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.insight-badge::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
}

.insight-badge.is-danger {
  color: var(--danger);
}

.insight-badge.is-warning {
  color: var(--warn);
}

.insight-badge.is-success {
  color: var(--ok);
}

.insight-title {
  font-weight: 600;
}

.insight-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 768px) {
  body {
    padding: 0 1rem 3rem;
  }

  .app-header {
    flex-direction: column;
  }

  .summary-form {
    width: 100%;
  }

  .summary-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
