:root {
  --page-bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --surface-raised: #fbfcfd;
  --nav: #17202a;
  --nav-soft: #222d38;
  --border: #e2e6ea;
  --border-strong: #c9d0d8;
  --text: #29323c;
  --text-strong: #111820;
  --muted: #687481;
  --primary: #175cd3;
  --primary-hover: #134ba9;
  --primary-soft: #eef4ff;
  --teal: #087f71;
  --amber: #b54708;
  --danger: #b42318;
  --success: #067647;
  --topbar-height: 72px;
  --sidebar-width: 236px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--page-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--border);
  display: flex;
  height: var(--topbar-height);
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-lockup,
.topbar-actions,
.session-summary,
.page-heading,
.dialog-head,
.detail-card-head {
  align-items: center;
  display: flex;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: var(--nav);
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  flex: 0 0 38px;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.topbar-actions,
.session-summary {
  flex-wrap: wrap;
  gap: 10px;
}

.session-summary {
  color: #46515d;
  font-size: 13px;
  font-weight: 700;
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--text-strong);
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.25;
}

h2 {
  font-size: 22px;
  line-height: 1.35;
}

h3 {
  font-size: 16px;
}

.badge,
.environment-tag {
  align-items: center;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 999px;
  color: var(--success);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 28px;
  padding: 4px 10px;
}

.environment-tag {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--amber);
}

.app-shell {
  display: grid;
  min-height: calc(100vh - var(--topbar-height));
}

.authenticated .app-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  align-self: start;
  background: var(--nav);
  color: #cdd5dc;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height));
  min-height: 0;
  overflow-y: auto;
  padding: 20px 14px 16px;
  position: sticky;
  top: var(--topbar-height);
}

.sidebar-heading {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 3px;
  margin: 0 6px 14px;
  padding: 0 4px 18px;
}

.sidebar-heading strong {
  color: #ffffff;
  font-size: 15px;
}

.sidebar-heading span {
  color: #93a0ad;
  font-size: 12px;
}

.sidebar-kicker {
  color: #7db2ff !important;
  font-weight: 800;
}

.menu-grid {
  display: grid;
  gap: 3px;
}

.menu-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #bdc7d0;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  grid-template-columns: 27px minmax(0, 1fr);
  min-height: 40px;
  padding: 7px 9px;
  text-align: left;
  width: 100%;
}

.menu-item:hover {
  background: var(--nav-soft);
  color: #ffffff;
}

.menu-item.is-active {
  background: #ffffff;
  color: var(--nav);
}

.nav-code {
  color: #6d7d8c;
  font-size: 10px;
  font-weight: 900;
}

.menu-item.is-active .nav-code {
  color: var(--primary);
}

.sidebar-footer {
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #93a0ad;
  display: flex;
  font-size: 12px;
  gap: 8px;
  margin-top: auto;
  padding: 16px 10px 2px;
}

.status-dot {
  background: #47cd89;
  border-radius: 50%;
  height: 8px;
  width: 8px;
}

.layout {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 22px 26px 40px;
}

body:not(.authenticated) .layout {
  align-content: start;
  grid-template-columns: minmax(0, 520px);
  justify-content: center;
  padding-top: 64px;
}

.login-panel,
.workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 24px;
}

.login-panel {
  box-shadow: 0 14px 40px rgba(17, 24, 32, 0.08);
  padding: 32px;
}

.workspace {
  overflow: hidden;
}

.page-heading {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
  margin: -2px -2px 22px;
  padding: 0 2px 18px;
}

.hint,
.message {
  color: var(--muted);
  line-height: 1.65;
  margin: 8px 0 18px;
}

.message {
  color: var(--danger);
  min-height: 20px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  color: var(--text);
  cursor: pointer;
  display: block;
  font: inherit;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 18px;
  text-align: left;
  width: 100%;
}

.metric-card:hover {
  background: #fafcff;
  border-color: #a9c8f9;
}

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

.metric-card strong {
  color: var(--text-strong);
  display: block;
  font-size: 20px;
  margin-top: 6px;
}

.metric-card strong small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card p {
  color: var(--muted);
  margin: 9px 0 0;
}

.metric-accent {
  border-top: 3px solid var(--primary);
  padding-top: 16px;
}

.dashboard-section-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 26px 0 12px;
}

.dashboard-section-heading .eyebrow {
  margin-bottom: 3px;
}

.dashboard-section-heading h3 {
  font-size: 18px;
}

.dashboard-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.signal-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signal-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid #64748b;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 4px;
  min-height: 118px;
  min-width: 0;
  padding: 16px 17px;
  text-align: left;
  width: 100%;
}

.signal-card:hover {
  background: #fafcff;
  border-color: #9bbef3;
}

.signal-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.signal-card strong {
  color: var(--text-strong);
  font-size: 28px;
  line-height: 1.15;
}

.signal-card small {
  color: var(--muted);
  line-height: 1.45;
}

.signal-card[data-tone="blue"] { border-left-color: #1769d2; }
.signal-card[data-tone="green"] { border-left-color: #16835a; }
.signal-card[data-tone="cyan"] { border-left-color: #087e8b; }
.signal-card[data-tone="amber"] { border-left-color: #c87a14; }
.signal-card[data-tone="red"] { border-left-color: #c2413b; }
.signal-card[data-tone="slate"] { border-left-color: #52606d; }

.dashboard-band {
  align-items: start;
  background: var(--nav);
  border-radius: 8px;
  color: #ffffff;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  margin-top: 16px;
  padding: 24px;
}

.dashboard-band h3 {
  color: #ffffff;
}

.dashboard-band .hint {
  color: #aeb9c3;
  margin-bottom: 0;
}

.dashboard-band .eyebrow {
  color: #7db2ff;
}

.workflow-list {
  display: grid;
  gap: 9px;
}

.workflow-list span {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.workflow-list b {
  color: #7db2ff;
  font-size: 11px;
}

.login-form,
.data-form {
  display: grid;
  gap: 14px;
}

.login-form {
  max-width: 420px;
}

.data-form {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin: 20px 0;
  padding: 18px;
}

.login-form label,
.data-form label,
.import-panel label {
  color: #3b4651;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.login-form input,
.data-form input,
.data-form select,
.data-form textarea,
.import-panel input,
.import-panel select,
.import-panel textarea {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

.login-form input:focus,
.data-form input:focus,
.data-form select:focus,
.data-form textarea:focus,
.import-panel input:focus,
.import-panel select:focus,
.import-panel textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 92, 211, 0.12);
}

.data-form textarea,
.import-panel textarea {
  min-height: 96px;
  resize: vertical;
}

.import-panel {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 18px;
}

.import-panel h3 {
  margin: 0;
}

.import-panel input,
.import-panel select {
  max-width: 460px;
}

.archive-export-panel {
  gap: 14px;
}

.archive-exhibitor-list {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  max-height: 260px;
  min-height: 54px;
  overflow: auto;
  padding: 8px;
}

.archive-exhibitor-option {
  align-items: start;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: grid;
  gap: 4px 10px;
  grid-template-columns: 18px minmax(0, 1fr);
  padding: 10px;
}

.archive-exhibitor-option:hover {
  background: var(--surface-soft);
}

.archive-exhibitor-option input {
  margin-top: 2px;
  min-height: 16px;
  width: 16px;
}

.archive-exhibitor-option strong,
.archive-exhibitor-option span {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.archive-exhibitor-option span {
  color: var(--muted);
  font-size: 12px;
}

.archive-exhibitor-empty {
  color: var(--muted);
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px;
}

.archive-actions {
  align-items: center;
}

.import-message {
  color: var(--muted);
  margin: 0;
  white-space: pre-wrap;
}

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

.list-toolbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 20px 0 12px;
}

.list-toolbar h3,
.list-toolbar p {
  margin: 0;
}

.list-toolbar .hint {
  margin-top: 4px;
}

.list-toolbar-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.list-toolbar-actions .message {
  margin: 0;
  text-align: right;
}

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

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 13px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f7f9;
  color: #53606d;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #34404b;
}

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

tbody tr:hover td {
  background: #fafcff;
}

button {
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 15px;
}

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

.secondary-action,
.icon-button,
.menu-toggle {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-strong);
}

.secondary-action:hover,
.icon-button:hover,
.menu-toggle:hover {
  background: var(--surface-soft);
}

.secondary-action {
  min-height: 34px;
  padding: 6px 10px;
}

.menu-toggle {
  display: none;
  font-size: 19px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  width: 36px;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 22px;
  height: 38px;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  width: 38px;
}

a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.action-row button {
  font-size: 13px;
  min-height: 34px;
  padding: 6px 10px;
}

.review-actions button:last-child {
  background: #ffffff;
  border: 1px solid #fda29b;
  color: var(--danger);
}

.review-actions button:last-child:hover {
  background: #fff5f4;
}

.operation-state {
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  line-height: 1.5;
  max-width: 94px;
}

.link-list {
  min-width: 140px;
}

.link-list a,
.link-list span {
  display: block;
  line-height: 1.7;
}

.drawing-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  min-width: 176px;
}

.drawing-thumb {
  color: var(--text);
  display: grid !important;
  font-size: 11px;
  font-weight: 700;
  gap: 4px;
  line-height: 1.25 !important;
  text-decoration: none;
}

.drawing-thumb:hover {
  color: var(--primary);
  text-decoration: none;
}

.thumb-frame {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: #edf1f4;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  display: flex !important;
  justify-content: center;
  overflow: hidden;
}

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

.drawing-thumb.is-missing {
  color: var(--muted);
}

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

.preview-grid[hidden] {
  display: none;
}

.file-search-panel {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.file-search-panel .action-row,
.file-search-panel .message {
  align-self: end;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.preview-card img {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
  width: 100%;
}

.preview-card span {
  color: var(--muted);
  font-size: 13px;
}

.detail-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  max-height: calc(100vh - 48px);
  padding: 24px;
  width: min(1040px, calc(100% - 32px));
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.detail-dialog.compact-dialog {
  width: min(520px, calc(100% - 32px));
}

.dialog-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.dialog-head,
.detail-card-head {
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
}

.detail-content {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.detail-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 16px;
}

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

.detail-file-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  margin-top: 14px;
}

.detail-file {
  color: var(--text);
  display: grid;
  gap: 5px;
  min-width: 0;
  text-decoration: none;
}

.detail-file:hover {
  color: var(--primary);
  text-decoration: none;
}

.detail-file-preview {
  aspect-ratio: 4 / 3;
  background: #e9edf1;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
  overflow: hidden;
}

.detail-file-preview img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.detail-file strong,
.detail-file > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-file > span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.detail-card-head span {
  background: var(--primary-soft);
  border-radius: 6px;
  color: var(--primary);
  font-weight: 700;
  padding: 4px 8px;
}

.detail-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
}

.detail-card li {
  line-height: 1.7;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .authenticated .app-shell {
    display: block;
  }

  .sidebar {
    box-shadow: 16px 0 40px rgba(17, 24, 32, 0.22);
    height: calc(100vh - var(--topbar-height));
    left: 0;
    overflow-y: auto;
    position: fixed;
    top: var(--topbar-height);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    width: min(82vw, 280px);
    z-index: 25;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
    justify-content: center;
  }

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

  .signal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-band {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 64px;
  }

  .topbar {
    padding: 0 12px;
  }

  .brand-mark {
    flex-basis: 34px;
    height: 34px;
    width: 34px;
  }

  .brand-lockup .eyebrow,
  .topbar .badge,
  .adminSessionLabel {
    display: none;
  }

  h1 {
    font-size: 15px;
  }

  .session-summary > span {
    display: none;
  }

  .layout,
  body:not(.authenticated) .layout {
    padding: 14px 12px 28px;
  }

  .login-panel,
  .workspace {
    padding: 18px 15px;
  }

  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .list-toolbar-actions {
    align-items: stretch;
    min-width: 0;
  }

  .list-toolbar-actions .message {
    text-align: left;
  }

  .page-heading {
    gap: 12px;
  }

  .dashboard-section-heading {
    align-items: flex-start;
    gap: 8px;
  }

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

  .environment-tag {
    white-space: nowrap;
  }

  .data-form,
  .import-panel,
  .dashboard-band {
    padding: 15px;
  }

  .detail-dialog {
    max-height: calc(100vh - 24px);
    padding: 18px;
    width: calc(100% - 20px);
  }

  .detail-content {
    grid-template-columns: 1fr;
  }
}
