:root {
  --bg: #181818;
  --bg-elevated: #141414;
  --panel: #2a2a2a;
  --panel-soft: #303030;
  --panel-strong: #343434;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #ececec;
  --muted: #a3a3a3;
  --muted-2: #7d7d7d;
  --green: #2aa46a;
  --green-soft: rgba(42, 164, 106, 0.16);
  --yellow: rgba(212, 183, 76, 0.78);
  --yellow-soft: rgba(212, 183, 76, 0.16);
  --danger: #ef4444;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.035), transparent 24%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.02), transparent 30%),
    linear-gradient(180deg, #181818 0%, #141414 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

#app {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card,
.shell,
.panel,
.stat,
.list-card,
.chart-card,
.form-card,
.partner-card,
.empty,
.deposit-row,
.sidebar,
.hero-panel {
  border: 1px solid var(--line);
  background: rgba(42, 42, 42, 0.82);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.login-card {
  width: min(560px, 100%);
  padding: 28px;
  background: rgba(37, 37, 37, 0.94);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-copy {
  min-height: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #262626;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.hero-copy,
.muted,
.status {
  color: var(--muted);
}

.hero-copy {
  margin: 18px 0 26px;
  max-width: 44ch;
  line-height: 1.55;
}

.field,
.toolbar,
.stack,
.list-grid,
.subgrid,
.chart-legend {
  display: grid;
  gap: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 13px 14px;
  background: #1f1f1f;
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #8b8b8b;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.16);
  background: #232323;
}

textarea {
  resize: vertical;
  min-height: 130px;
}

.button,
.ghost-button,
.danger-button,
.icon-button,
.nav-button {
  min-height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.button {
  color: #fff;
  background: #f3f3f3;
  color: #171717;
}

.ghost-button,
.icon-button {
  color: var(--text);
  background: #323232;
  border: 1px solid transparent;
}

.danger-button {
  color: #fff;
  background: #3a2424;
  border: 1px solid rgba(239, 68, 68, 0.18);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover,
.nav-button:hover {
  transform: translateY(-1px);
}

.shell {
  width: min(1440px, calc(100vw - 20px));
  margin: 10px auto;
  padding: 10px;
  background: rgba(24, 24, 24, 0.97);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 10px;
  min-height: calc(100vh - 20px);
}

.sidebar {
  padding: 18px 14px;
  background: rgba(32, 32, 32, 0.98);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
}

.sidebar-brand {
  padding: 6px 6px 14px;
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.sidebar-subtitle {
  display: none;
}

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

.nav-button {
  justify-content: flex-start;
  width: 100%;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-button.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  padding: 8px 6px 4px;
}

.content {
  min-width: 0;
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.05em;
  line-height: 1.08;
}

.page-subtitle {
  margin-top: 8px;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.5;
}

.actions,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-panel,
.panel,
.chart-card,
.form-card,
.empty {
  padding: 20px;
}

.hero-panel {
  background: linear-gradient(180deg, rgba(51, 51, 51, 0.88), rgba(36, 36, 36, 0.92));
  padding: 16px 20px;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat {
  padding: 16px;
  background: rgba(35, 35, 35, 0.96);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 12px;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -0.06em;
}

.fd-unit {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.section-title h2,
.section-title h3 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.admin-grid,
.content-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
}

.panel-column,
.detail-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.toolbar {
  grid-template-columns: 1fr auto;
}

.toolbar + .card-grid,
.toolbar + .directory-list {
  margin-top: 16px;
}

.page-header + .toolbar,
.page-header + .card-grid,
.page-header + .stats-grid,
.page-header + .metric-grid {
  margin-top: 16px;
}

.directory-list,
.card-grid {
  display: grid;
  gap: 14px;
}

.detail-column > .panel,
.detail-column > .form-card,
.detail-column > .chart-card {
  margin: 0;
}

.detail-header + .stats-grid {
  margin-top: 16px;
}

.partner-card,
.list-card {
  padding: 18px;
  background: rgba(36, 36, 36, 0.96);
}

.partner-card {
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.partner-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.partner-card.selected {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.card-head,
.list-card header,
.deposit-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.partner-name,
.list-title {
  margin: 6px 0 0;
  font-size: 17px;
  letter-spacing: -0.03em;
}

.chip,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
}

.chip.success {
  color: #9fe1be;
  background: var(--green-soft);
}

.chip.warn {
  color: #f1d4d4;
  background: rgba(239, 68, 68, 0.12);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.detail-title {
  margin: 2px 0 0;
  font-size: 28px;
  letter-spacing: -0.05em;
}

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

.stats-editor {
  display: grid;
  gap: 14px;
}

.stats-editor-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-stack {
  display: grid;
  gap: 8px;
}

.list-grid {
  gap: 16px;
}

.chart-card {
  overflow: hidden;
}

.chart {
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  min-height: 250px;
  margin-top: 18px;
}

.chart-bar {
  position: relative;
  min-height: 180px;
  border-radius: 16px;
  background: linear-gradient(180deg, #303030, #272727);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 140ms ease, background 140ms ease;
}

.chart-bar:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, #343434, #2a2a2a);
}

.chart-prev,
.chart-current {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  border-radius: 10px 10px 8px 8px;
}

.chart-prev {
  background: var(--yellow);
  opacity: 0.42;
}

.chart-current {
  background: linear-gradient(180deg, #31b072, #228d5f);
}

.chart-tooltip {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translate(-50%, -6px);
  display: grid;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  text-align: center;
  font-size: 11px;
  z-index: 2;
}

.chart-bar:hover .chart-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chart-tooltip-current {
  color: #79d9a8;
}

.chart-tooltip-previous {
  color: #e1c667;
}

.chart-label {
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 10px;
  text-align: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.metric-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel > .stats-grid + *,
.panel > .inline-form + *,
.panel > .stats-editor + *,
.panel > .toolbar + *,
.form-card > .field + *,
.list-card header > div > * + *,
.partner-card > * + * {
  margin-top: 12px;
}

.panel > .section-title:last-child,
.form-card > .field:last-child {
  margin-bottom: 0;
}

.status {
  min-height: 18px;
  font-size: 13px;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(32, 32, 32, 0.98);
  box-shadow: var(--shadow);
  padding: 18px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-rows: auto auto;
  }

  .sidebar-footer {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .admin-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: calc(100vw - 10px);
    margin: 5px auto;
    padding: 5px;
  }

  .content {
    padding: 16px;
  }

  .page-header,
  .section-title,
  .detail-header,
  .toolbar,
  .stats-editor-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .stats-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    gap: 4px;
  }

  .chart-bar {
    min-height: 140px;
  }
}
