:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f5f6f8;
  --surface: #fff;
  --surface-2: #f1f3f6;
  --text: #18181b;
  --muted: #64646f;
  --line: #dfe2e7;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --danger: #bd3e52;
  --ok: #168b66;
  --warn: #9a6700;
  --shadow: 0 8px 24px rgba(22, 24, 32, .07);
}

:root[data-theme="dark"] {
  --bg: #101114;
  --surface: #17191d;
  --surface-2: #202329;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --line: #30343c;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --danger: #f07d87;
  --ok: #42c99a;
  --warn: #eab75e;
  --shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

html { background: var(--bg); }
body { min-width: 320px; min-height: 100vh; line-height: 1.45; }

.ccg-global-nav.topbar {
  height: 56px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.nav-logo { display: flex; align-items: center; gap: 10px; width: 132px; min-width: 132px; height: 40px; padding: 0 10px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 700; }
.nav-logo img { width: 28px; height: 28px; border-radius: 7px; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.site-nav a { height: 34px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.site-nav a:hover,
.site-nav a.active { color: var(--text); background: var(--surface-2); }
.ccg-global-nav .top-actions { display: flex; align-items: center; gap: 6px; }
.workspace-bar { height: 54px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 10px; position: sticky; top: 56px; z-index: 24; }
.workspace-bar > strong { font-size: 14px; }
.workspace-model { font-size: 11px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); }
.desktop-nav { margin-left: 22px; align-self: stretch; display: flex; align-items: center; }
.workspace-nav { display: flex; gap: 4px; }
.workspace-nav a { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--muted); text-decoration: none; font-size: 13px; border-radius: 6px; }
.workspace-nav a:hover,
.workspace-nav a.active { color: var(--text); background: var(--surface-2); }
.workspace-nav a.active { box-shadow: inset 0 -2px var(--accent); }

.account-link { height: 34px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.account-link:hover { background: var(--surface-2); color: var(--text); }
.nav-icon { width: 34px; height: 34px; padding: 0; border-radius: 999px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.nav-icon:hover { background: var(--surface-2); color: var(--text); }
.language-button { margin-left: auto; font-size: 12px; font-weight: 700; }

#root > header { display: none; }

header {
  height: 56px;
  padding: 0 20px;
  gap: 12px;
  border-color: var(--line);
  background: var(--surface);
}

.brand { font-size: 16px; font-weight: 800; }
.crumb { padding-left: 12px; font-size: 12px; }
.actions { gap: 6px; }

.button,
.icon {
  min-height: 36px;
  border-radius: 6px;
  padding: 7px 10px;
}
.icon { width: 36px; padding: 0; }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button:focus-visible,
.icon:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 58%);
  outline-offset: 2px;
}

main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 40px; }
.heading { margin-bottom: 18px; }
.heading h1 { font-size: 24px; line-height: 1.2; letter-spacing: 0; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; }
.section-copy { color: var(--muted); max-width: 680px; }

.layout { gap: 16px; align-items: start; }
.panel {
  border-color: var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; letter-spacing: 0; }
.notice-box,
.empty { border-radius: 6px; background: var(--surface-2); }

input,
select {
  min-height: 40px;
  border-radius: 6px;
  border-color: var(--line);
  background: var(--surface);
}
input:hover,
select:hover { border-color: color-mix(in srgb, var(--accent), var(--line) 60%); }

.record,
.asset {
  border-color: var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.record:hover,
.asset:hover { border-color: color-mix(in srgb, var(--accent), var(--line) 58%); }
.record.selected,
.asset.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent), transparent 84%);
}
.status { border-radius: 999px; font-weight: 700; }
.progress { accent-color: var(--accent); }
.link-value { color: var(--accent); }

.toast,
.dialog {
  border-color: var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.modal { background: rgba(9, 10, 13, .68); }

@media (max-width: 760px) {
  .ccg-global-nav.topbar { height: 56px; padding: 0 12px; }
  .nav-logo { width: auto; min-width: auto; padding: 0 4px; }
  .site-nav { overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { padding: 0 9px; }
  .site-nav a:nth-of-type(5),
  .site-nav a:nth-of-type(6),
  .site-nav a:nth-of-type(7),
  .site-nav a:nth-of-type(8) { display: none; }
  .workspace-bar { height: 54px; padding: 0 12px; gap: 8px; overflow-x: auto; }
  .workspace-model { padding-left: 8px; }
  .desktop-nav { margin-left: 6px; }
  .workspace-nav a { padding: 0 8px; white-space: nowrap; }
  #root > header { height: 44px; padding: 0 12px; }
  header { height: 56px; padding: 0 12px; }
  .crumb { display: none; }
  .actions { margin-left: auto; }
  .button { min-height: 40px; }
  .actions .button { padding-inline: 9px; }
  main { width: 100%; padding: 16px 12px calc(28px + env(safe-area-inset-bottom)); }
  .heading h1 { font-size: 21px; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-radius: 6px; box-shadow: none; }
  .create-row,
  .upload-form { grid-template-columns: 1fr; }
  .record-list,
  .asset-grid { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .brand { font-size: 15px; }
  header .button:not(.primary) span { display: none; }
  .heading { margin-bottom: 14px; }
  .panel { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
