:root {
  --bg: #f7f6f2;
  --panel: #ffffff;
  --line: #dad7cf;
  --text: #1f2420;
  --muted: #546057;
  --accent: #0a7d53;
  --accent-strong: #075639;
  --error: #9f2b2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f1efe8 0%, var(--bg) 100%);
  color: var(--text);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1200px, 96vw);
  margin: 24px auto 48px;
}

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

.page-header h1 {
  margin: 0;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.header-links {
  display: flex;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.notice {
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid;
}

.notice.success {
  background: #e6f3ec;
  border-color: #a4d1ba;
}

.notice.error {
  background: #fce9e9;
  border-color: #e0b1b1;
  color: var(--error);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-grid strong {
  font-size: 1.5rem;
  line-height: 1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.86rem;
}

h2,
h3 {
  margin-top: 0;
}

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

.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.oauth-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f8f8f5;
  margin-bottom: 12px;
}

.oauth-card h3 {
  margin-bottom: 8px;
}

.oauth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.artist-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.artist-filter {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f8f5;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
}

.artist-filter:hover {
  text-decoration: none;
  border-color: #bfc4be;
  background: #f0f2ed;
}

.artist-filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

input,
select,
button,
.button {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

button,
.button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  text-align: center;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  text-decoration: none;
}

.button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.button.secondary:hover {
  background: #f6f6f6;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
}

.track-link {
  font-weight: 700;
}

.sub,
.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.back-link {
  display: inline-block;
  margin-bottom: 12px;
}

.inline-form {
  margin-top: 10px;
}

.sync-actions .inline-form {
  margin-top: 0;
}

.managed-status-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.managed-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8f8f5;
}

.pill {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.ok {
  color: #0b5f3f;
  background: #ddf0e7;
  border-color: #b7ddcb;
}

.pill.warn {
  color: #925814;
  background: #fff1dd;
  border-color: #e8cd9f;
}

.error-text {
  color: var(--error);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

.details-grid article {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

dt {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--muted);
}

dd {
  margin: 0;
}

ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .grid-form,
  .search-form,
  .details-grid {
    grid-template-columns: 1fr;
  }
}
