:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --text: #14171a;
  --muted: #64707d;
  --line: #d9e0e7;
  --line-strong: #bfc9d4;
  --blue: #0b74de;
  --blue-dark: #075db7;
  --green: #138a65;
  --red: #c63838;
  --shadow: 0 18px 42px rgba(17, 31, 44, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 68px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  min-width: 58px;
  height: 38px;
  place-items: center;
  border: 2px solid #111820;
  border-radius: 6px;
  color: #111820;
  font-weight: 900;
  letter-spacing: 0;
}

.search {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.account {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-trigger {
  display: inline-grid;
  grid-template-columns: 28px minmax(0, auto) 14px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  max-width: 240px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #0b2f73;
  font-weight: 800;
}

.account-trigger:hover,
.account-trigger[aria-expanded="true"] {
  background: #eef4ff;
}

.account-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #c7cfda;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.account-label {
  max-width: 170px;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-caret {
  color: #365078;
  font-size: 14px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  min-width: 230px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(17, 31, 44, 0.16);
}

.account-menu button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #1c2733;
  padding: 0 10px;
  text-align: left;
  font-weight: 750;
}

.account-menu button:hover {
  background: #eef4ff;
}

.account-menu-logout {
  margin-top: 8px;
  border-top: 1px solid var(--line) !important;
  color: var(--red) !important;
}

.workspace {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.view-grid {
  display: block;
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.list-surface,
.detail-surface,
.admin-surface {
  padding: 18px;
}

.detail-surface {
  box-shadow: var(--shadow);
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

p,
.muted,
small {
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.model-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.model-card:hover,
.model-card:focus-visible {
  outline: 0;
  border-color: var(--blue);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e8edf2;
}

.thumb img,
.viewer-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-thumb {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.model-card-body {
  padding: 12px;
}

.model-card h2 {
  display: -webkit-box;
  min-height: 44px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.meta-line span {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 0 7px;
  border-radius: 5px;
  background: #eef3f7;
  color: #4f5d6b;
  font-size: 12px;
  font-weight: 700;
}

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

.viewer-frame {
  display: grid;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
}

.viewer-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.model-page {
  display: grid;
  gap: 18px;
}

.model-page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.model-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(300px, 1fr);
  gap: 18px;
  padding: 18px;
}

.model-viewer {
  min-height: 276px;
}

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

.model-summary h1 {
  overflow-wrap: anywhere;
}

.model-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.model-actions {
  margin: 0;
}

.model-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: start;
  gap: 18px;
}

.model-section {
  padding: 18px;
}

.detail-block {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.part-list,
.version-list,
.table-list {
  display: grid;
  gap: 8px;
}

.part-row,
.version-row,
.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-alt);
  color: var(--text);
  text-align: left;
  text-decoration: none;
}

.part-row.active {
  border-color: var(--blue);
  background: #eef6ff;
}

.version-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.part-row span,
.version-row strong,
.admin-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-row small,
.version-row small,
.admin-row small {
  display: block;
  margin-top: 3px;
}

.version-info {
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

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

.print-button {
  min-height: 34px;
}

.download-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: #e8f2ff;
  color: var(--blue);
  font-weight: 900;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(198, 56, 56, 0.35);
  background: #fff2f2;
  color: var(--red);
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 22px;
}

.empty-state,
.empty-detail,
.auth-required {
  display: grid;
  min-height: 260px;
  place-items: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-detail strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.notice {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(19, 138, 101, 0.28);
  border-radius: 7px;
  background: #edfff8;
  color: var(--green);
  box-shadow: var(--shadow);
  font-weight: 750;
}

.notice.error {
  border-color: rgba(198, 56, 56, 0.3);
  background: #fff2f2;
  color: var(--red);
}

.dialog {
  width: min(460px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.dialog.wide,
.dialog-card.wide {
  width: min(680px, calc(100vw - 28px));
}

.dialog::backdrop {
  background: rgba(16, 25, 37, 0.45);
}

.dialog-card {
  width: 100%;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(10, 22, 36, 0.26);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head {
  margin-bottom: 18px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 7px;
  color: #2d3640;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.admin-row select {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field.full {
  grid-column: 1 / -1;
}

.form-message {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-alt);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1280px;
  margin: 12px auto 0;
}

.profile-sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
}

.profile-card {
  overflow: hidden;
}

.profile-cover {
  height: 128px;
  background:
    linear-gradient(135deg, rgba(11, 116, 222, 0.4), rgba(19, 138, 101, 0.24)),
    repeating-linear-gradient(45deg, #8aa0b8 0 18px, #9fb4c6 18px 36px, #728ba6 36px 54px);
}

.profile-avatar {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  margin: -43px auto 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #a4acb5;
  color: #fff;
  font-size: 34px;
  font-weight: 900;
}

.profile-identity {
  padding: 12px 16px 4px;
}

.profile-identity h1 {
  margin-bottom: 4px;
  color: #061f62;
}

.profile-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 0 16px;
}

.profile-mini-stats div {
  padding: 12px 8px;
  text-align: center;
}

.profile-mini-stats div + div {
  border-left: 1px solid var(--line);
}

.profile-mini-stats strong,
.profile-mini-stats span {
  display: block;
}

.profile-mini-stats strong {
  color: #061f62;
  font-size: 17px;
}

.profile-mini-stats span {
  color: var(--muted);
  font-size: 12px;
}

.profile-card > .primary-button,
.profile-card > .ghost-button {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
}

.profile-info-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.profile-info-card h2 {
  margin: 0;
  color: #061f62;
  font-size: 20px;
}

.profile-pill {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 6px;
  background: #f0f3f7;
  color: #596675;
  font-size: 12px;
  font-weight: 800;
}

.profile-main {
  display: grid;
  align-content: start;
  gap: 24px;
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 12px;
}

.profile-tab {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: left;
}

.profile-tab.active {
  border-color: #3154ff;
}

.profile-tab strong,
.profile-tab span {
  display: block;
}

.profile-tab strong {
  color: #061f62;
  font-size: 16px;
}

.profile-tab span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.profile-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 0.5fr) minmax(180px, 0.7fr) minmax(240px, 1.3fr);
  gap: 12px;
}

.profile-toolbar select,
.profile-search {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-toolbar select {
  padding: 0 12px;
  color: #061f62;
}

.profile-search {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
}

.profile-search input {
  border: 0;
  outline: 0;
  background: transparent;
}

.profile-design-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 360px));
  gap: 28px 24px;
}

.profile-design-card {
  display: grid;
  gap: 12px;
  cursor: pointer;
}

.profile-design-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

.profile-design-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #d7dce2;
}

.profile-design-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-design-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.profile-design-meta h2 {
  color: #061f62;
  font-size: 15px;
}

.profile-design-meta p {
  font-size: 12px;
}

.admin-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.admin-row select {
  width: 120px;
}

@media (max-width: 1180px) {
  .model-hero,
  .model-content-grid,
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .profile-sidebar {
    grid-template-columns: minmax(260px, 320px) minmax(260px, 1fr);
  }

  .profile-tabs {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .model-viewer {
    min-height: 216px;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 14px;
  }

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

  .search {
    order: 3;
  }

  .workspace {
    padding: 14px;
  }

  .section-head,
  .detail-head,
  .admin-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .card-grid,
  .metric-grid,
  .model-metrics,
  .profile-sidebar,
  .profile-toolbar,
  .profile-design-grid,
  .admin-columns {
    grid-template-columns: 1fr;
  }

  .model-page-top {
    align-items: stretch;
    flex-direction: column;
  }

  .model-hero,
  .model-section {
    padding: 14px;
  }

  .model-viewer {
    min-height: 168px;
  }
}

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

  .account {
    justify-content: end;
  }

  .account-label {
    display: none;
  }
}
