:root {
  --ink: #111111;
  --ink-soft: #1a1a1a;
  --paper: #f4f4f5;
  --card: #ffffff;
  --line: #e6e6e8;
  --muted: #6b6b70;
  --brass: #e10600;
  --brass-dark: #b80500;
  --ok: #1f7a46;
  --warn: #b45309;
  --danger: #e10600;
  --info: #334155;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  --font: Inter, "Segoe UI", sans-serif;
  --display: "Libre Baskerville", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body.admin-body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

a { color: inherit; }

.admin-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: #000;
  color: #f5f5f5;
  padding: 1.2rem 0 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  padding: 0 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.admin-sidebar .brand-lockup { color: #fff; }
.admin-sidebar .brand-lockup small { color: #a3a3a3; opacity: 1; }

.brand-logo {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  margin-bottom: .75rem;
  background: #000;
}

.brand-mark { display: none; }

.brand h1 {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: .04em;
  margin: 0 0 .2rem;
}

.brand p {
  margin: 0;
  color: #a3a3a3;
  font-size: .8rem;
}

.nav-group {
  margin: 1.2rem 0 .4rem;
  padding: 0 1.4rem;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #737373;
}

.admin-sidebar a.nav-link {
  display: block;
  color: #e7e7e7;
  text-decoration: none;
  padding: .58rem 1.4rem;
  border-left: 3px solid transparent;
  font-size: .92rem;
}

.admin-sidebar a.nav-link:hover,
.admin-sidebar a.nav-link.active {
  background: rgba(225, 6, 0, .14);
  border-left-color: var(--brass);
  color: #fff;
}

.admin-main { min-width: 0; }

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.6rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.admin-top .who {
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
}

.admin-content { padding: 1.6rem; }

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.page-title h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
}

.page-title p {
  margin: .25rem 0 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.stat-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.stat-card { padding: 1.1rem 1.2rem; }

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: .35rem;
  font-size: 1.8rem;
  color: var(--ink);
}

.panel { padding: 1.1rem 1.2rem; }
.panel h3 { margin: 0 0 1rem; font-size: 1rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 1rem;
}

table.data { width: 100%; border-collapse: collapse; }
table.data th,
table.data td {
  text-align: left;
  padding: .7rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 650;
}
.badge-ok { background: #e8f7ee; color: var(--ok); }
.badge-warn { background: #fff4e5; color: var(--warn); }
.badge-danger { background: #fde8e8; color: var(--danger); }
.badge-info { background: #eef2f6; color: var(--info); }
.badge-muted { background: #f1f1f3; color: var(--muted); }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: .5rem 1rem;
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}
.btn-brass { background: var(--brass); color: #fff; }
.btn-brass:hover { background: var(--brass-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.alert { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.alert-error { background: #fde8e8; color: var(--danger); }
.alert-success { background: #e8f7ee; color: var(--ok); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 20%, rgba(225,6,0,.28), transparent 32%),
    #000;
}

.login-card {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 24px 70px rgba(0,0,0,.4);
}

.login-logo {
  width: 84px;
  height: 84px;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  display: block;
  margin: 0 auto 1rem;
  background: #000;
}

.login-card h1 {
  margin: 0 0 .3rem;
  font-family: var(--display);
  text-align: center;
  font-size: 1.35rem;
}

.login-card p.lead {
  margin: 0 0 1.4rem;
  color: var(--muted);
  text-align: center;
}

.form-label { font-weight: 600; margin-bottom: .3rem; display: block; }
.form-control, .form-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .75rem;
  background: #fff;
}

.filter-bar { display: flex; gap: .7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b80500; color: #fff; }
.btn-sm { padding: .28rem .75rem; font-size: .82rem; }
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.flag-row { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; object-fit: contain; object-position: center; background: #fff; border-radius: 8px; border: 1px solid var(--line); padding: 4px; }
.thumb-lg { width: 140px; height: 140px; object-fit: contain; object-position: center; background: #fff; border-radius: 10px; border: 1px solid var(--line); padding: 8px; }
.thumb-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.thumb-card { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; }
.thumb-card img { width: 110px; height: 110px; object-fit: contain; object-position: center; background: #fff; border-radius: 8px; border: 1px solid var(--line); padding: 6px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .45rem;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  padding: .8rem;
  border-radius: 8px;
  background: #fff;
}

.spare-parts-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}
.spare-parts-dual {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: .75rem;
  align-items: start;
}
.spare-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
  overflow: hidden;
}
.spare-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .75rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.spare-panel-head strong {
  font-size: .9rem;
}
.spare-panel-catalog .form-control {
  margin: .55rem .75rem 0;
  width: calc(100% - 1.5rem);
}
.spare-panel-hint {
  margin: .4rem .75rem 0;
  font-size: .8rem;
}
.spare-catalog-list,
.spare-panel-selected .spare-part-selected {
  overflow: auto;
  max-height: 340px;
  padding: .45rem .6rem .6rem;
}
.spare-panel-loading,
.spare-panel-empty {
  margin: 0;
  padding: .35rem 0;
  font-size: .84rem;
}
.spare-catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: .3rem;
}
.spare-catalog-row.is-added {
  opacity: .72;
  background: #f3f3f4;
}
.spare-catalog-copy {
  display: grid;
  gap: .15rem;
  min-width: 0;
}
.spare-catalog-copy strong {
  color: var(--brass);
  font-size: .82rem;
}
.spare-catalog-copy span {
  font-size: .88rem;
  line-height: 1.35;
  word-break: break-word;
}
.spare-catalog-add {
  white-space: nowrap;
}
.spare-part-selected {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.spare-part-empty {
  margin: 0 .75rem .6rem;
  font-size: .84rem;
}
.spare-part-chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .45rem;
  align-items: center;
  padding: .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.spare-part-chip-index {
  font-size: .72rem;
  font-weight: 800;
  color: #bbb;
  min-width: 1.2rem;
}
.spare-part-chip-body {
  display: grid;
  gap: 0;
  min-width: 0;
}
.spare-part-chip-body strong {
  color: var(--brass);
  font-size: .78rem;
  line-height: 1.2;
}
.spare-part-chip-body span {
  font-size: .82rem;
  line-height: 1.25;
  word-break: break-word;
}
.spare-part-remove {
  border: 0;
  background: #fff;
  color: var(--danger);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border: 1px solid #f0c4c4;
}
.spare-part-remove:hover {
  background: #fff5f5;
}

.activity-stat-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.activity-stat-grid .stat-small {
  font-size: 1rem;
  line-height: 1.3;
}
.panel-head-row {
  margin-bottom: .85rem;
}
.panel-head-row h3 {
  margin: 0 0 .25rem;
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #ececec;
  font-weight: 800;
  font-size: .9rem;
}
.rank-badge.rank-gold {
  background: #f5d76e;
  color: #5c4300;
}
.rank-badge.rank-silver {
  background: #d7dce2;
  color: #334155;
}
.rank-badge.rank-bronze {
  background: #e8c3a0;
  color: #6b3f1d;
}
.usage-score {
  color: var(--brass);
  font-size: 1.05rem;
}
.activity-rank-table tr.is-inactive td {
  opacity: .62;
}
.score-legend {
  margin: .4rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.7;
}
.score-legend strong {
  color: var(--ink);
}
.mb-0 { margin-bottom: 0 !important; }
.mt-3 { margin-top: 1rem; }
.mt-2 { margin-top: .65rem; }
.admin-video-preview {
  display: block;
  width: 100%;
  max-width: 560px;
  margin-top: .75rem;
  background: #111;
  border-radius: 12px;
}
.admin-video-embed {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
}
.admin-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 760px) {
  .spare-parts-dual {
    grid-template-columns: 1fr;
  }
  .spare-catalog-list,
  .spare-panel-selected .spare-part-selected {
    max-height: 260px;
  }
  .activity-stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { height: auto; position: relative; }
  .stat-grid, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .stat-grid, .grid-2 { grid-template-columns: 1fr 1fr; }
}
