:root {
  --paper: #fbf7ed;
  --paper-2: #fffdf8;
  --line: #e7d9c4;
  --ink: #30291f;
  --muted: #6d6254;
  --sage: #5f8b71;
  --sage-dark: #2e725c;
  --blue: #4f82bd;
  --clay: #db8841;
  --rose: #c95865;
  --gold: #dfa743;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(95, 139, 113, 0.08), transparent 32%),
    radial-gradient(circle at 92% 20%, rgba(79, 130, 189, 0.06), transparent 28%),
    var(--paper);
}

button,
select,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.admin-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  background: rgba(255, 253, 248, 0.78);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.admin-brand span {
  color: var(--sage-dark);
  font-size: 26px;
}

.admin-rail nav {
  display: grid;
  gap: 8px;
}

.admin-nav,
.back-link,
.admin-actions button,
.admin-actions a,
.table-tools select,
.table-tools input,
.panel-head select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  padding: 0 12px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.admin-nav {
  text-align: left;
  cursor: pointer;
}

.admin-nav.active,
.admin-actions button {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}

.admin-nav:hover,
.back-link:hover,
.admin-actions a:hover,
.admin-actions button:hover,
.row-action:hover,
.drawer-actions button:hover,
.status-chip:hover {
  transform: translateY(-1px);
  border-color: var(--sage);
}

.back-link {
  margin-top: auto;
  display: grid;
  place-items: center;
  color: var(--sage-dark);
  font-weight: 800;
}

.admin-main {
  padding: 28px;
}

.operator-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.operator-summary div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 253, 248, 0.84);
  box-shadow: 0 14px 34px rgba(48, 41, 31, 0.06);
}

.operator-summary strong {
  color: var(--sage-dark);
  font-size: 13px;
}

.operator-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.admin-topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

h2 {
  font-size: 20px;
}

.panel-head p,
.metric-card span,
.metric-card small {
  color: var(--muted);
}

.admin-actions,
.table-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  box-shadow: 0 18px 44px rgba(48, 41, 31, 0.08);
  backdrop-filter: blur(10px);
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card strong {
  font-size: 32px;
  letter-spacing: 0;
}

.metric-card small {
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.dashboard-grid.lower {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.75fr);
}

.panel {
  padding: 18px;
}

.chart-box {
  height: 280px;
  margin-top: 18px;
}

.pipeline-chart {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pipeline-bar {
  height: 16px;
  border-radius: 999px;
  background: #efe3d2;
  overflow: hidden;
}

.pipeline-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage-dark);
}

.table-panel {
  margin-top: 14px;
}

.table-tools input {
  width: min(340px, 100%);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.status-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.status-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

.status-chip.active {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-paid { background: #e4eddf; color: var(--sage-dark); }
.status-trial { background: #edf3fb; color: #315f91; }
.status-past_due { background: #fff0d9; color: #9a5d1d; }
.status-cancelled { background: #f5dddd; color: #9d3d49; }

.row-action {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff9ef;
  color: var(--sage-dark);
  font-weight: 800;
  cursor: pointer;
}

.account-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(48, 41, 31, 0.34);
}

.account-modal-backdrop[hidden] {
  display: none;
}

.review-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(48, 41, 31, 0.34);
}

.review-modal-backdrop[hidden] {
  display: none;
}

.account-drawer {
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--paper-2);
  box-shadow: -24px 0 70px rgba(48, 41, 31, 0.18);
  padding: 22px;
}

.review-modal {
  width: min(620px, 100%);
  max-height: min(760px, 92vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  box-shadow: 0 24px 80px rgba(48, 41, 31, 0.22);
  padding: 22px;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.drawer-head h2 {
  font-size: 28px;
}

.drawer-head p:last-child,
.drawer-section p,
.drawer-note,
.account-summary span,
.billing-grid span {
  color: var(--muted);
}

.drawer-head button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}

.account-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.account-summary div,
.drawer-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff9ef;
  padding: 14px;
}

.account-summary div {
  display: grid;
  gap: 5px;
}

.drawer-section {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.billing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.billing-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.billing-grid select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  padding: 0 10px;
}

.review-modal textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.4;
  resize: vertical;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.drawer-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--sage-dark);
  font-weight: 800;
  cursor: pointer;
}

.drawer-actions button:first-child {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}

.drawer-note {
  min-height: 20px;
  font-size: 13px;
  font-weight: 800;
}

.support-list,
.finance-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.support-item,
.finance-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff9ef;
}

.support-item {
  align-items: flex-start;
}

.support-item.reviewed {
  opacity: 0.74;
  background: #f7f3ea;
}

.support-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.finance-list span {
  color: var(--muted);
}

.billing-admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.billing-admin-grid article {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff9ef;
  padding: 14px;
}

.billing-admin-grid span {
  color: var(--muted);
  line-height: 1.4;
}

svg {
  width: 100%;
  height: 100%;
  display: block;
}

.axis-text {
  fill: var(--muted);
  font-size: 12px;
}

.grid-line {
  stroke: #eadfce;
  stroke-width: 1;
}

@media (max-width: 980px) {
  .admin-shell {
    display: block;
  }

  .admin-rail {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-rail nav {
    display: flex;
    overflow-x: auto;
  }

  .admin-nav {
    white-space: nowrap;
  }

  .metric-grid,
  .operator-summary,
  .billing-admin-grid,
  .dashboard-grid,
  .dashboard-grid.lower {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .admin-main {
    padding: 18px 12px;
  }

  .admin-topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    gap: 10px;
  }
}
