:root {
  --bg: #f4f2ed;
  --surface: #fffefa;
  --surface-2: #ebe7dc;
  --ink: #191711;
  --muted: #6f6a5f;
  --line: #d9d1c1;
  --line-strong: #b9ae9b;
  --accent: #17624a;
  --accent-2: #9b2f23;
  --accent-3: #245c88;
  --warn: #9a5b00;
  --shadow: 0 12px 30px rgb(40 35 24 / 9%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgb(25 23 17 / 3%) 1px, transparent 1px),
    linear-gradient(0deg, rgb(25 23 17 / 3%) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: ui-sans-serif, "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  padding: 0 22px;
  background: #171610;
  color: #fffefa;
  border-bottom: 3px solid #cbbf9f;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 178px;
}

.brand strong {
  font-size: 15px;
  letter-spacing: .02em;
}

.brand span {
  color: #c9c0ae;
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav a,
.logout button {
  color: #f9f4e9;
  border: 1px solid rgb(255 255 255 / 15%);
  background: rgb(255 255 255 / 7%);
  border-radius: 6px;
  padding: 8px 11px;
  font-weight: 700;
}

.nav a:hover,
.logout button:hover {
  background: rgb(255 255 255 / 14%);
  text-decoration: none;
}

.logout {
  margin-left: auto;
}

.logout button {
  cursor: pointer;
  font: inherit;
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 42px;
}

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

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.subtitle {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

h2 {
  margin: 28px 0 10px;
  font-size: 18px;
}

.panel,
.stat,
.api-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin: 16px 0;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
}

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

.narrow {
  max-width: 420px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #312d24;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c8bead;
  border-radius: 6px;
  font: inherit;
}

textarea {
  min-height: 92px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgb(23 98 74 / 22%);
  border-color: var(--accent);
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
  min-height: auto;
}

button,
.button,
.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button:hover,
.actions a:hover {
  filter: brightness(.95);
  text-decoration: none;
}

.button.secondary {
  background: #3b4654;
}

.button.danger,
button.danger {
  background: var(--accent-2);
}

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

.alert {
  padding: 12px 14px;
  margin: 12px 0 16px;
  border: 1px solid #e0b76c;
  border-radius: 8px;
  background: #fff7e5;
  color: #5e3b00;
  font-weight: 700;
}

.alert.ok {
  background: #e8f6ef;
  border-color: #91c7ad;
  color: #174d39;
}

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

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 32px;
  line-height: 1;
  font-family: Georgia, "Times New Roman", serif;
}

.stat span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8e0d3;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.42;
  overflow: hidden;
  color: #211d16;
}

th {
  background: #ded6c8;
  color: #342f26;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #fbf7ee;
}

.cell-strong {
  color: #15120d;
  font-weight: 800;
}

code,
.mono {
  display: inline-block;
  max-width: 100%;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  background: #ece5d8;
  border-radius: 5px;
  padding: 2px 5px;
  vertical-align: middle;
}

.clip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
}

.chips span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #d8ccba;
  border-radius: 999px;
  background: #f5efe4;
  color: #393227;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7e2d7;
  color: #352f25;
  font-size: 12px;
  font-weight: 800;
}

.pill,
.runtime-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  border: 1px solid #b8ac99;
  border-radius: 6px;
  background: #fff9ec;
  color: #17130d;
  font-size: 12px;
  font-weight: 900;
}

.pill {
  padding: 3px 8px;
}

.runtime-pill {
  overflow: hidden;
}

.runtime-pill strong,
.runtime-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
}

.runtime-pill strong {
  background: #1f4f3f;
  color: #fff;
}

.runtime-pill span {
  background: #fff9ec;
  color: #17130d;
}

.badge.ok {
  background: #dceee4;
  color: #15533a;
}

.badge.warn {
  background: #f7e6ba;
  color: #684100;
}

.badge.fail {
  background: #f4d5cf;
  color: #7d2017;
}

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

.row-actions form {
  margin: 0;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.col-actions {
  width: 86px;
}

.col-enabled,
.col-preferred,
.col-tested_status,
.col-source_type,
.col-priority,
.col-rollout_percent {
  width: 96px;
}

.col-template_version,
.col-model_version,
.col-archive_format,
.col-arch,
.col-cuda_version,
.col-published_at {
  width: 132px;
}

.col-size_bytes {
  width: 120px;
}

.col-sha256,
.col-digest {
  width: 210px;
}

.col-image,
.col-url,
.col-package_url,
.col-loaded_image,
.col-repo_id {
  width: 280px;
}

.col-match_tags_json,
.col-customer_ids_json {
  width: 250px;
}

.models-table {
  min-width: 760px;
}

details.panel summary {
  cursor: pointer;
  font-weight: 900;
}

details.panel[open] summary {
  margin-bottom: 14px;
}

.api-card {
  padding: 16px;
  margin: 16px 0;
}

.api-card pre {
  margin: 10px 0 0;
  padding: 12px;
  overflow-x: auto;
  background: #1f211b;
  color: #fff5d6;
  border-radius: 7px;
}

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

.login-shell main {
  width: min(440px, 100%);
  padding: 0;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .logout {
    margin-left: 0;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
