:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #171c23;
  --panel-2: #202633;
  --field: #11161d;
  --line: #2b3340;
  --line-strong: #465466;
  --text: #f5f5f7;
  --muted: #9ca3af;
  --blue: #0a84ff;
  --green: #30d158;
  --cyan: #64d2ff;
  --amber: #ffd60a;
  --red: #ff453a;
  --violet: #bf5af2;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #242b36;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

button:hover,
.file-btn:hover {
  border-color: var(--line-strong);
  background: #2c3542;
}

button.primary {
  border-color: rgba(10, 132, 255, 0.55);
  background: rgba(10, 132, 255, 0.16);
}

button.danger {
  border-color: rgba(223, 97, 87, 0.58);
  background: rgba(223, 97, 87, 0.1);
  color: #ffb6ae;
}

button.danger:hover {
  border-color: rgba(223, 97, 87, 0.9);
  background: rgba(223, 97, 87, 0.18);
  color: #ffd0cb;
}

button.mini {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

input,
select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus-visible,
.file-btn:focus-within {
  outline: 2px solid rgba(10, 132, 255, 0.48);
  outline-offset: 2px;
}

input[type="checkbox"] {
  min-height: auto;
}

input[type="file"] {
  display: none;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 18px 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  color: #d4dde4;
}

#syncStatus {
  margin-top: 8px;
  color: var(--muted);
}

.actions,
.filters,
.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.actions button,
.actions .file-btn {
  height: 36px;
}

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 18px 0;
}

.tab.is-active,
.segmented button.is-active {
  background: #2a3341;
  border-color: #465466;
  color: #fff;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.segmented {
  display: flex;
  background: #11161d;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

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

.inline-field input {
  width: 96px;
}

.chart {
  min-height: 260px;
}

.ruler {
  position: relative;
  height: 24px;
  border-bottom: 1px solid var(--line);
  color: #7f8a93;
  font-size: 11px;
}

.ruler span {
  position: absolute;
  transform: translateX(-4px);
}

.bar-row {
  display: grid;
  grid-template-columns: 190px 1fr 190px;
  gap: 16px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.bar-name {
  min-width: 0;
}

.bar-name strong {
  display: inline-block;
  margin-right: 6px;
}

.bar-name small,
.bar-value small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.bar-track {
  height: 24px;
  border-radius: 4px;
  background: #242b36;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(216, 167, 72, 0.35), var(--amber));
}

.bar-fill.recharge {
  background: linear-gradient(90deg, rgba(90, 200, 216, 0.34), var(--cyan));
}

.bar-fill.best {
  background: linear-gradient(90deg, rgba(84, 209, 138, 0.34), var(--green));
}

.bar-value {
  text-align: right;
}

.bar-value b {
  font-size: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.pill.sub {
  border-color: rgba(216, 167, 72, 0.42);
  color: #f2c56d;
}

.pill.re {
  border-color: rgba(90, 200, 216, 0.42);
  color: #8ce2ed;
}

.pill.best {
  border-color: rgba(84, 209, 138, 0.45);
  color: #8df0b5;
}

.pill.duplicate {
  border-color: rgba(196, 90, 165, 0.55);
  background: rgba(196, 90, 165, 0.1);
  color: #f2a8da;
}

.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

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

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

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

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

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

.num {
  text-align: right;
  white-space: nowrap;
}

.highlight {
  color: var(--green);
  font-weight: 700;
}

.manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.stack {
  display: grid;
  gap: 12px;
}

.empty {
  border: 1px dashed #46515c;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.fx-panel {
  display: grid;
  gap: 12px;
}

.fx-stat {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.fx-stat b {
  font-size: 22px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.duration-multipliers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.compact-field input {
  width: 90px;
}

.model-row,
.platform-card,
.rate-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.platform-card,
.rate-card {
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.platform-card:hover,
.rate-card:hover {
  border-color: var(--line-strong);
}

.model-row {
  display: flex;
  gap: 8px;
}

.model-row input {
  flex: 1;
}

.platform-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.platform-head input {
  flex: 1;
  min-width: 180px;
}

.edit-table input,
.edit-table select {
  width: 100%;
  min-width: 96px;
}

.rate-card {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.7fr 0.8fr 0.9fr auto;
  gap: 8px;
  align-items: center;
}

.rate-card.is-duplicate {
  border-color: rgba(196, 90, 165, 0.65);
  background: linear-gradient(90deg, rgba(196, 90, 165, 0.13), var(--panel-2) 22%);
  box-shadow: inset 3px 0 0 rgba(196, 90, 165, 0.9);
}

.rate-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  color: #7d8790;
  padding: 14px 18px 32px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .actions > *,
  .filters > * {
    flex: 1 1 auto;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 0;
  }

  .bar-value {
    text-align: left;
  }

  .manage-grid {
    grid-template-columns: 1fr;
  }

  .platform-head,
  .rate-card {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .edit-table,
  .edit-table tbody,
  .edit-table tr,
  .edit-table td {
    display: block;
    width: 100%;
  }

  .edit-table tr:first-child {
    display: none;
  }

  .edit-table td {
    border-bottom: 0;
    padding: 6px 0;
  }

  .edit-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
  }
}
