:root {
  color-scheme: light;
  --ink: #17151f;
  --muted: #696579;
  --line: #dedce8;
  --panel: #ffffff;
  --wash: #f6f3fb;
  --coral: #ff4d6d;
  --teal: #06a985;
  --blue: #2f72e8;
  --gold: #c98700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 77, 109, 0.18), transparent 34rem),
    linear-gradient(135deg, #fbfbfe 0%, #f0f5f2 52%, #fff6e2 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
}

button.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.panel {
  border: 1px solid rgba(32, 29, 45, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(35, 29, 68, 0.09);
}

.auth-panel {
  max-width: 460px;
  padding: 18px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.admin-card {
  padding: 14px;
}

.admin-card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.rate-card {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.collapsible-head {
  margin-bottom: 0;
}

.collapse-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 2px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.collapse-toggle:hover {
  transform: none;
}

.collapse-toggle span:first-child {
  font-size: 1.05rem;
  font-weight: 900;
}

.collapse-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 900;
}

.collapse-icon::before {
  content: "+";
}

.collapse-toggle[aria-expanded="true"] .collapse-icon::before {
  content: "-";
}

.collapsible-content {
  margin-top: 12px;
}

.section-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.rate-matrix {
  overflow-x: auto;
}

.rate-matrix table {
  min-width: 760px;
}

.rate-input {
  min-width: 96px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  letter-spacing: 0;
}

.metric:nth-child(1) {
  border-top: 5px solid var(--coral);
}

.metric:nth-child(2) {
  border-top: 5px solid var(--teal);
}

.metric:nth-child(3) {
  border-top: 5px solid var(--blue);
}

.metric:nth-child(4) {
  border-top: 5px solid var(--gold);
}

.table-panel {
  overflow: hidden;
}

.table-head {
  padding: 10px 14px;
}

.table-panel .collapsible-content {
  overflow-x: auto;
  margin-top: 0;
}

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

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(23, 21, 31, 0.04);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 40px 18px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 840px) {
  .filters,
  .admin-grid,
  .admin-form,
  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .table-panel {
    overflow-x: auto;
  }

  table {
    min-width: 760px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head,
  .section-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters,
  .admin-grid,
  .admin-form,
  .metrics {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }
}
