:root {
  --bg: #e9eef0;
  --bg-deep: #d7e0e3;
  --ink: #162229;
  --muted: #5a6a72;
  --panel: rgba(248, 251, 252, 0.94);
  --line: rgba(22, 34, 41, 0.12);
  --accent: #0f6e56;
  --accent-2: #1d5f7a;
  --danger: #9b2f2f;
  --A: #0f6e56;
  --B: #1d5f7a;
  --C: #4f6b57;
  --D: #8a5a2b;
  --E: #8b3a3a;
  --shadow: 0 18px 50px rgba(22, 34, 41, 0.08);
  --radius: 14px;
  --font: "Manrope", sans-serif;
  --display: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(29, 95, 122, 0.14), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(15, 110, 86, 0.16), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(233, 238, 240, 0.8);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand a {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
}

.topbar__sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.page {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.page-head h1,
.section h2,
.auth-form h2,
.client-hero h1 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.muted { color: var(--muted); }
.tiny { font-size: 0.82rem; }
.danger { color: var(--danger); font-weight: 600; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  color: #f7fff9;
}

.btn--primary:hover {
  filter: brightness(1.05);
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--wide { width: 100%; }

.auth-body {
  min-height: 100vh;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  width: min(960px, 100%);
  margin: 0 auto;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  width: 100%;
  align-items: stretch;
}

.auth-hero {
  padding: 2.5rem 2rem;
  border-radius: 24px;
  color: #f4f7f4;
  background:
    linear-gradient(145deg, rgba(28, 36, 32, 0.92), rgba(31, 107, 79, 0.88)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 420px;
}

.auth-hero__mark {
  font-family: var(--display);
  font-size: 2.6rem;
  margin: 0;
  color: #8fd6b8;
}

.auth-hero__title {
  font-family: var(--display);
  font-size: 2rem;
  margin: 0.4rem 0 0.8rem;
}

.auth-hero__lead {
  max-width: 28ch;
  line-height: 1.5;
  color: rgba(244, 247, 244, 0.84);
  margin: 0;
}

.auth-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.auth-form input,
.filters input,
.filters select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #f7fbfc;
  color: var(--ink);
}

.auth-form input:focus,
.filters input:focus,
.filters select:focus {
  outline: 2px solid rgba(31, 107, 79, 0.35);
  border-color: var(--accent);
}

.form-error {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(155, 47, 47, 0.1);
  color: var(--danger);
  font-weight: 600;
}

.auth-demo {
  margin-top: 0.5rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-demo ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.auth-demo code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(28, 36, 32, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 1.25rem 0;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
}

.stat__label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat strong {
  font-family: var(--display);
  font-size: 1.35rem;
}

.stat--A strong { color: var(--A); }
.stat--B strong { color: var(--B); }
.stat--C strong { color: var(--C); }
.stat--D strong { color: var(--D); }
.stat--E strong { color: var(--E); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.filters input { flex: 1 1 240px; }
.filters select { min-width: 180px; }

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.clients-table th,
.clients-table td {
  text-align: left;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.clients-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(215, 224, 227, 0.55);
}

.clients-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.clients-table tbody tr:hover {
  background: rgba(31, 107, 79, 0.06);
}

.tickets-table tbody tr { cursor: default; }

.client-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.reasons-cell {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 280px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.pts {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
}

.pts--A, .badge--A { color: var(--A); }
.pts--B, .badge--B { color: var(--B); }
.pts--C, .badge--C { color: var(--C); }
.pts--D, .badge--D { color: var(--D); }
.pts--E, .badge--E { color: var(--E); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: rgba(28, 36, 32, 0.05);
  border: 1px solid currentColor;
}

.back-link { margin-bottom: 1rem; }

.client-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.client-hero__info,
.score-panel,
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.score-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border-top: 4px solid var(--accent);
}

.score-panel--A { border-top-color: var(--A); }
.score-panel--B { border-top-color: var(--B); }
.score-panel--C { border-top-color: var(--C); }
.score-panel--D { border-top-color: var(--D); }
.score-panel--E { border-top-color: var(--E); }

.score-panel__label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-panel__pts strong {
  font-family: var(--display);
  font-size: 3.2rem;
  line-height: 1;
  display: block;
}

.score-panel__scale {
  color: var(--muted);
  font-size: 0.9rem;
}

.score-panel__meta p { margin: 0.45rem 0 0; }

.section { margin-top: 1rem; }
.section h2 { margin-bottom: 0.85rem; font-size: 1.25rem; }

.reason-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
}

.contrib-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.contrib {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.contrib--plus strong { color: var(--A); }
.contrib--minus strong { color: var(--E); }

.outcome {
  font-weight: 700;
  font-size: 0.86rem;
}

.outcome--redeemed { color: var(--A); }
.outcome--sold, .outcome--open_overdue { color: var(--E); }
.outcome--open, .outcome--prolonged { color: var(--B); }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flash-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(31, 107, 79, 0.1);
}

.flash--error { background: rgba(155, 47, 47, 0.12); color: var(--danger); }

@media (max-width: 900px) {
  .auth-shell,
  .client-hero {
    grid-template-columns: 1fr;
  }

  .auth-hero { min-height: 260px; }

  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .contrib-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .filters { flex-direction: column; }
  .filters input, .filters select, .filters .btn { width: 100%; }
}
