/* ============================================================
   Pindou Admin Pro — SnowAdmin Style (v2)
   White sidebar, blue-primary palette, rounded design
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #409eff;
  --primary-light: #ecf5ff;
  --primary-hover: #66b1ff;
  --primary-active: #3a8ee6;
  --success: #67c23a;
  --success-light: #f0f9eb;
  --warning: #e6a23c;
  --warning-light: #fdf6ec;
  --danger: #f56c6c;
  --danger-light: #fef0f0;
  --info: #909399;
  --info-light: #f4f4f5;

  --text-primary: #303133;
  --text-regular: #606266;
  --text-secondary: #909399;
  --text-placeholder: #c0c4cc;
  --text-title: #303133;

  --bg-base: #f0f2f5;
  --bg-white: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f5f7fa;
  --bg-active: #ecf5ff;

  --border-color: #e4e7ed;
  --border-light: #ebeef5;
  --border-lighter: #f2f6fc;

  --shadow-sm: 0 2px 4px rgba(0,0,0,.04);
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --sidebar-width: 220px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;

  --transition: all .2s ease;
  --font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #60a5fa;
  --primary-light: rgba(96,165,250,.16);
  --primary-hover: #93c5fd;
  --primary-active: #3b82f6;
  --success: #34d399;
  --success-light: rgba(52,211,153,.14);
  --warning: #fbbf24;
  --warning-light: rgba(251,191,36,.14);
  --danger: #fb7185;
  --danger-light: rgba(251,113,133,.14);
  --info: #94a3b8;
  --info-light: rgba(148,163,184,.14);

  --text-primary: #f8fafc;
  --text-regular: #cbd5e1;
  --text-secondary: #94a3b8;
  --text-placeholder: #64748b;
  --text-title: #f8fafc;

  --bg-base: #0f172a;
  --bg-white: #1e293b;
  --bg-sidebar: #1e293b;
  --bg-hover: #263449;
  --bg-active: rgba(96,165,250,.18);

  --border-color: #334155;
  --border-light: #334155;
  --border-lighter: #243247;

  --shadow-sm: 0 2px 4px rgba(0,0,0,.28);
  --shadow: 0 12px 28px rgba(0,0,0,.32);
  --shadow-lg: 0 18px 46px rgba(0,0,0,.42);
}

/* ---------- Reset & Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-family);
  background: var(--bg-base);
  color: var(--text-regular);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}
html[data-sidebar="collapsed"] .app {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .app {
  grid-template-columns: var(--sidebar-width) 1fr;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.content {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  transition: width .22s ease, transform .3s ease, box-shadow .2s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 0 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-collapse-toggle {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-collapse-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.sidebar-collapse-toggle span {
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 3px;
  transition: transform .2s ease, margin .2s ease;
}
html[data-sidebar="collapsed"] .sidebar-collapse-toggle span {
  transform: rotate(-135deg);
  margin-left: -3px;
}

.nav {
  flex: 1;
  padding: 8px 0;
}

.nav-group { margin: 4px 0; }

.nav-parent {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--text-regular);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-parent:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-parent.active {
  background: var(--bg-active);
  color: var(--primary);
}
.nav-parent.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
  background: var(--bg-white);
}
.nav-children.open { max-height: 600px; }
.nav-children > a:first-child { margin-top: 2px; }

.nav-children a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px 9px 48px;
  color: var(--text-regular);
  font-size: 13px;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}

html[data-sidebar="collapsed"] .brand {
  justify-content: center;
  padding: 0;
}
html[data-sidebar="collapsed"] .brand-logo {
  display: none !important;
}
html[data-sidebar="collapsed"] .nav {
  padding-top: 10px;
}
html[data-sidebar="collapsed"] .nav-group {
  margin: 4px 8px;
}
html[data-sidebar="collapsed"] .nav-parent {
  justify-content: center;
  gap: 0;
  height: 44px;
  padding: 0;
  border-radius: 8px;
}
html[data-sidebar="collapsed"] .nav-parent > span:not(.menu-icon):not(.nav-chevron) {
  display: none;
}
html[data-sidebar="collapsed"] .nav-chevron {
  display: none;
}
html[data-sidebar="collapsed"] .nav-children {
  display: none;
}
html[data-sidebar="collapsed"] .nav-parent.expanded,
html[data-sidebar="collapsed"] .nav-parent.active {
  background: var(--bg-active);
  color: var(--primary);
}
html[data-sidebar="collapsed"] .nav-parent.active::before,
html[data-sidebar="collapsed"] .nav-children a.active::before {
  display: none;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .brand {
  justify-content: space-between;
  padding: 0 14px 0 20px;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .brand-logo {
  display: block !important;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav {
  padding: 8px 0;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-group {
  margin: 4px 0;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-parent {
  justify-content: flex-start;
  gap: 10px;
  height: auto;
  padding: 11px 20px;
  border-radius: 0;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-parent > span:not(.menu-icon):not(.nav-chevron) {
  display: inline;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-chevron {
  display: block;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-children {
  display: block;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-parent.active::before,
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .nav-children a.active::before {
  display: block;
}
.nav-children a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-children a.active {
  background: var(--bg-active);
  color: var(--primary);
}
.nav-children a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-chevron {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: .5;
  transition: transform .2s ease;
  flex-shrink: 0;
}
.nav-parent.expanded .nav-chevron { transform: rotate(45deg); }

/* Menu icons — colorful like SnowAdmin */
.menu-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 4px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

/* Colorful icon backgrounds */
.icon-dashboard { background: #e6f7ff; color: #1890ff; }
.icon-chart { background: #fff7e6; color: #fa8c16; }
.icon-store { background: #fff2e8; color: #fa8c16; }
.icon-material { background: #f6ffed; color: #52c41a; }
.icon-image { background: #fff0f6; color: #eb2f96; }
.icon-user { background: #f0f5ff; color: #2f54eb; }
.icon-account { background: #f0f5ff; color: #2f54eb; }
.icon-project { background: #e6fffb; color: #13c2c2; }
.icon-download { background: #fff7e6; color: #faad14; }
.icon-log { background: #fff1f0; color: #f5222d; }
.icon-setting { background: #f6ffed; color: #52c41a; }
.icon-role { background: #e6f7ff; color: #1890ff; }
.icon-menu { background: #f9f0ff; color: #722ed1; }
.icon-default { background: #f5f5f5; color: #8c8c8c; }

.nav-parent.active .menu-icon,
.nav-children a.active .menu-icon {
  background: var(--primary-light);
  color: var(--primary);
}

/* Icon shapes using CSS */
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; }

/* Dashboard icon */
.icon-dashboard::before {
  width: 10px; height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}
.icon-dashboard::after {
  width: 2px; height: 10px;
  background: currentColor;
  box-shadow: 4px -2px 0 currentColor, 8px -4px 0 currentColor;
  bottom: 4px; left: 3px;
}

/* Chart/Marketing icon */
.icon-chart::before {
  width: 11px; height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  left: 4px; bottom: 4px;
}
.icon-chart::after {
  width: 2px; height: 4px;
  background: currentColor;
  bottom: 5px; left: 7px;
  box-shadow: 3px -2px 0 currentColor, 6px -5px 0 currentColor;
}

/* Store icon */
.icon-store::before {
  width: 10px; height: 7px;
  border: 2px solid currentColor;
  border-top: 0;
  bottom: 3px;
}
.icon-store::after {
  width: 12px; height: 4px;
  border: 2px solid currentColor;
  border-bottom: 0;
  top: 3px;
  transform: skew(-12deg);
}

/* Image/Material icon */
.icon-image::before, .icon-material::before {
  width: 11px; height: 8px;
  border: 2px solid currentColor;
  border-radius: 2px;
}
.icon-image::after, .icon-material::after {
  width: 4px; height: 4px;
  background: currentColor;
  border-radius: 50%;
  top: 4px; right: 4px;
}

/* User/Account icon */
.icon-user::before, .icon-account::before {
  width: 6px; height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  top: 3px;
}
.icon-user::after, .icon-account::after {
  width: 10px; height: 5px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 2px 2px;
  bottom: 3px;
}

/* Project icon */
.icon-project::before {
  width: 10px; height: 12px;
  border: 2px solid currentColor;
  border-radius: 2px;
}
.icon-project::after {
  width: 6px; height: 1.5px;
  background: currentColor;
  top: 7px; left: 6px;
  box-shadow: 0 3px 0 currentColor;
}

/* Download icon */
.icon-download::before {
  width: 8px; height: 2px;
  background: currentColor;
  bottom: 4px;
}
.icon-download::after {
  width: 5px; height: 5px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  top: 3px;
}

/* Log icon */
.icon-log::before {
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.icon-log::after {
  width: 5px; height: 1.5px;
  background: currentColor;
  top: 7px; left: 7px;
  transform: rotate(35deg);
  transform-origin: left center;
}

/* Setting icon */
.icon-setting::before {
  width: 10px; height: 10px;
  border: 2px dashed currentColor;
  border-radius: 50%;
}
.icon-setting::after {
  width: 3px; height: 3px;
  background: currentColor;
  border-radius: 50%;
}

/* Role icon */
.icon-role::before {
  width: 10px; height: 6px;
  border: 2px solid currentColor;
  border-radius: 2px;
  bottom: 4px;
}
.icon-role::after {
  width: 6px; height: 5px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  top: 3px;
}

/* Menu icon */
.icon-menu::before {
  width: 10px; height: 1.5px;
  background: currentColor;
  top: 4px;
  box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
}

/* Default icon */
.icon-default::before {
  width: 7px; height: 7px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep {
  color: var(--text-placeholder);
  font-size: 12px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-white);
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.theme-toggle.is-dark {
  border-color: #475569;
  background: #0f172a;
  color: #fbbf24;
}
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: var(--transition);
}
.user-menu:hover { background: var(--bg-hover); }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 160px;
  padding: 6px 0;
  display: none;
  z-index: 100;
}
.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown a,
.user-dropdown form button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-regular);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.user-dropdown a:hover,
.user-dropdown form button:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }

/* ---------- Metrics ---------- */
.metric .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.metric .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ---------- Section Title ---------- */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
}

/* ---------- Dialog / Modal ---------- */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
}
dialog[open] {
  display: block;
}
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(7, 22, 46, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.dialog-backdrop.open { opacity: 1; pointer-events: auto; }
.dialog-box {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(7,22,46,.28);
  width: min(460px, 92vw);
  max-height: 86vh;
  overflow: auto;
  transform: scale(.94) translateY(8px);
  transition: transform .25s ease;
}
.dialog-backdrop.open .dialog-box { transform: scale(1) translateY(0); }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.dialog-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-title);
}
.dialog-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--text-secondary);
  padding: 4px;
  line-height: 1;
  transition: color .2s;
}
.dialog-close:hover { color: var(--text-title); }
.dialog-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-regular);
  white-space: pre-wrap;
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-hover);
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-base);
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-lighter);
  vertical-align: middle;
  color: var(--text-regular);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--bg-hover); }
.table td .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  flex-wrap: wrap;
}
.pagination-info {
  color: var(--text-secondary);
  font-size: 13px;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pagination-controls a,
.pagination-controls span,
.pagination-controls button {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-regular);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.pagination-controls a:hover,
.pagination-controls button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination-controls .active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.pagination-controls .disabled {
  color: var(--text-placeholder);
  background: var(--bg-hover);
  cursor: not-allowed;
}
.pagination-controls button:disabled {
  color: var(--text-placeholder);
  background: var(--bg-hover);
  cursor: not-allowed;
}

/* ---------- Forms ---------- */
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-regular);
  font-weight: 500;
  margin-bottom: 8px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-regular);
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(64,158,255,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-placeholder); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-hover);
  color: var(--text-placeholder);
  cursor: not-allowed;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  transition: var(--transition);
  font-family: inherit;
}
.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn:active {
  background: var(--primary-active);
  border-color: var(--primary-active);
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--bg-white);
  color: var(--text-regular);
  border-color: var(--border-color);
}
.btn.ghost:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn.dark {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}
.btn.dark:hover {
  background: var(--text-regular);
  border-color: var(--text-regular);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger:hover {
  background: #f78989;
  border-color: #f78989;
}

.btn.success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn.success:hover {
  background: #85ce61;
  border-color: #85ce61;
}

.btn.warn {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.btn.warn:hover {
  background: #ebb563;
  border-color: #ebb563;
}

.btn.link {
  background: transparent;
  border: 0;
  color: var(--primary);
  padding: 0;
}
.btn.link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ---------- Toolbar & Filter ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.toolbar h2 { margin: 0; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: end;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.filter-bar .field {
  flex: 1 1 0;
  min-width: 160px;
  max-width: 260px;
}
.filter-bar .field label {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.filter-bar .btn,
.filter-bar .btn.ghost {
  flex: 0 0 auto;
  margin-bottom: 0;
  height: 40px;
}
.filter-bar .btn.ghost {
  padding: 9px 14px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}
.badge { background: var(--primary-light); color: var(--primary); }
.badge.success { background: var(--success-light); color: var(--success); }
.badge.warn { background: var(--warning-light); color: var(--warning); }
.badge.danger { background: var(--danger-light); color: var(--danger); }
.badge.info { background: var(--info-light); color: var(--info); }

/* ---------- Notices / Alerts ---------- */
.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--success-light);
  color: var(--success);
  font-weight: 500;
  border: 1px solid #c2e7b0;
  font-size: 13px;
}
.notice.warn { background: var(--warning-light); color: var(--warning); border-color: #f5dab1; }
.notice.danger { background: var(--danger-light); color: var(--danger); border-color: #fbc4c4; }
.notice.info { background: var(--primary-light); color: var(--primary); border-color: #b3d8ff; }

.error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid #fbc4c4;
}
.alert-error {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 500;
  border: 1px solid #fbc4c4;
  font-size: 13px;
}

/* ---------- Form Pages ---------- */
.form-page { max-width: 900px; }
.form-heading { margin-bottom: 20px; }
.form-heading .section-title { margin-bottom: 6px; }
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.form-row label {
  font-size: 13px;
  color: var(--text-regular);
  font-weight: 500;
}
/* Form card (centered, compact) */
.form-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 36px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.form-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 24px;
}
.form-card-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  text-align: left;
}
.form-card-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.form-card-close:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.form-card .form-row:last-child {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
  margin-bottom: 0;
  margin-top: 28px;
}
.form-card .form-row:last-child .btn {
  min-width: 120px;
  flex: 0 0 auto;
}

.form-row .btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 20px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-secondary); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }

.readonly-code {
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-regular);
  font-family: Consolas, "Courier New", monospace;
  font-weight: 500;
  font-size: 13px;
}

/* Preview / media cells */
.preview {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-base);
}
.media-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}
.media-cell .preview { flex: 0 0 40px; width: 40px; height: 40px; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-hover);
}
.upload-row .preview { flex: 0 0 64px; width: 64px; height: 64px; }

/* Checkbox grid */
.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.check-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg-white);
  transition: var(--transition);
}
.check-item:hover { border-color: var(--primary); }

/* Color swatch */
.color-swatch {
  width: 30px;
  height: 20px;
  display: inline-block;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
  vertical-align: middle;
}

/* ---------- Brand Logo ---------- */
.brand-logo {
  max-width: 100%;
  max-height: 36px;
  display: block;
}
.theme-asset-dark { display: none !important; }
html[data-theme="dark"] .theme-asset-light { display: none !important; }
html[data-theme="dark"] .theme-asset-dark { display: block !important; }
html[data-sidebar="collapsed"] .brand-logo,
html[data-sidebar="collapsed"][data-theme="dark"] .brand-logo {
  display: none !important;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .theme-asset-light {
  display: block !important;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"] .theme-asset-dark {
  display: none !important;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"][data-theme="dark"] .theme-asset-light {
  display: none !important;
}
html[data-sidebar="collapsed"][data-sidebar-hover="expanded"][data-theme="dark"] .theme-asset-dark {
  display: block !important;
}

/* ---------- Login Page ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-white);
}
.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.55) 100%);
}
.login-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.login-hero-text {
  position: relative;
  z-index: 1;
  padding: 60px;
  color: #fff;
}
.login-brand-logo {
  max-width: 160px;
  max-height: 60px;
  margin-bottom: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.login-brand h1 {
  font-size: 36px;
  margin: 0 0 16px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.login-brand p {
  max-width: 480px;
  color: rgba(255,255,255,.9);
  line-height: 1.7;
  font-size: 15px;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.login-card {
  margin: auto;
  width: min(400px, calc(100% - 48px));
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-brand-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 0 20px;
}
.login-card-logo {
  max-width: 180px;
  max-height: 56px;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.06));
}
.login-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--text-primary);
}
.login-card .hint {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
}
.login-card .field { margin-bottom: 20px; }
.login-card .field label {
  font-size: 13px;
  color: var(--text-regular);
  margin-bottom: 6px;
}
.login-card input {
  padding: 12px 14px;
  font-size: 14px;
}
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
}

/* ---------- Empty State ---------- */
.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--text-placeholder);
  background: var(--bg-hover);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ============================================================
   PRESERVED: Pixel / Lab Specific Styles (unchanged from v1)
   ============================================================ */

/* ---------- Pixel Engine Lab ---------- */
.pixel-test-layout { align-items: stretch; }
.pixel-summary {
  background: linear-gradient(135deg, #ffffff 0%, #f6fbfa 100%);
}
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-lighter);
}
.summary-row:last-child { border-bottom: 0; }
.summary-row span { color: var(--text-secondary); }
.summary-row strong { font-size: 18px; color: var(--text-primary); }

.pixel-result-image {
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: linear-gradient(45deg, #f8fafc 25%, #eef2f7 25%, #eef2f7 50%, #f8fafc 50%, #f8fafc 75%, #eef2f7 75%);
  background-size: 22px 22px;
}

/* Pixel Engine Lab */
.pixel-lab { display: grid; gap: 20px; }
.lab-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--text-primary);
  color: #fff;
  box-shadow: var(--shadow);
}
.lab-hero h2 { margin: 0 0 8px; font-size: 26px; }
.lab-hero p { margin: 0; color: #b9c4d6; }
.lab-status {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #b9c4d6;
  font-weight: 600;
}
.lab-status.running { background: var(--primary); color: #fff; }

.lab-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 20px; }
.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.upload-zone {
  position: relative;
  min-height: 220px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg-hover);
  margin-bottom: 14px;
}
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone img { width: 100%; height: 260px; object-fit: contain; }
.upload-zone div { display: grid; gap: 8px; text-align: center; color: var(--text-secondary); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-hover);
  padding: 4px;
  border-radius: var(--radius);
}
.segmented button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.segmented button.active {
  background: var(--bg-white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.lab-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  align-items: end;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-weight: 600;
  color: var(--text-regular);
}
.toggle input { width: auto; }
.compact-toggle { margin: 10px 0; line-height: 1.45; font-size: 13px; }

.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.result-images { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.result-images div { display: grid; gap: 8px; }
.result-images span { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.result-images img {
  width: 100%;
  min-height: 260px;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: linear-gradient(45deg, #f8fafc 25%, #eef2f7 25%, #eef2f7 50%, #f8fafc 50%, #f8fafc 75%, #eef2f7 75%);
  background-size: 22px 22px;
}
.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.result-meta span {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.analysis-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.analysis-grid div {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  display: grid;
  gap: 6px;
}
.analysis-grid span { color: var(--text-secondary); font-size: 12px; }
.analysis-grid strong { font-size: 20px; color: var(--text-primary); }

.tips { display: grid; gap: 8px; margin-top: 14px; }
.tips div {
  padding: 10px 14px;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
}

.palette-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.palette-row span {
  width: 30px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,.1);
}

.debug-log {
  max-height: 430px;
  overflow: auto;
  display: grid;
  gap: 10px;
}
.debug-log > div {
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg-white);
}
.debug-log > div.fail { border-left-color: var(--danger); }
.debug-log span { margin-left: 8px; color: var(--text-secondary); font-size: 12px; }
.debug-log pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--text-regular);
}
.debug-log em { display: block; margin-top: 8px; color: var(--danger); }

/* Lab compact */
.lab-compact { gap: 14px; }
.lab-hero.compact { padding: 18px 22px; }
.lab-hero.compact h2 { font-size: 22px; }
.lab-workbench { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.lab-sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding-right: 4px;
}
.lab-sidebar::-webkit-scrollbar, .debug-log.compact::-webkit-scrollbar { width: 6px; }
.lab-sidebar::-webkit-scrollbar-thumb, .debug-log.compact::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.lab-main-panel { min-width: 0; display: grid; gap: 20px; }

.upload-zone.compact { min-height: 154px; margin-bottom: 12px; }
.upload-zone.compact img { height: 170px; }
.lab-form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lab-form-grid.compact .field label { margin-bottom: 5px; }
.lab-form-grid.compact input, .lab-form-grid.compact select { padding: 9px 10px; }

.lab-actions-sticky {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  background: linear-gradient(rgba(255,255,255,.9), #fff 30%);
}
.lab-actions-sticky .btn.dark { grid-column: 1 / -1; }

.auto-pipeline { display: grid; gap: 8px; margin: 10px 0; }
.auto-pipeline div {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-hover);
}
.auto-pipeline strong { font-size: 12px; color: var(--text-primary); }
.auto-pipeline span { font-size: 12px; color: var(--text-secondary); }

.sidebar-summary .mini-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sidebar-summary .mini-metrics div {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 4px;
}
.sidebar-summary .mini-metrics span { font-size: 12px; color: var(--text-secondary); }
.sidebar-summary .mini-metrics strong { font-size: 16px; }

.compact-results { gap: 14px; }
.result-card.compact { padding: 16px; }

/* Bead editor */
.bead-editor-frame {
  width: 100%;
  height: 1180px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-white);
}
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.result-head .panel-title { margin-bottom: 0; }
.result-meta.compact { margin-top: 0; justify-content: flex-end; }
.result-images.compact { gap: 10px; }
.result-images.compact img { min-height: 220px; max-height: 360px; }

.lab-info-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; align-items: start; }
.analysis-grid.compact { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.analysis-grid.compact div { padding: 10px; }
.tips.compact { gap: 6px; margin-top: 10px; }
.tips.compact div { padding: 8px 10px; }
.palette-row.compact { gap: 5px; margin-top: 10px; }
.palette-row.compact span { width: 26px; height: 20px; }
.empty-state.compact { min-height: 96px; }
.debug-log.compact { max-height: 360px; }
.debug-log.compact pre { max-height: 120px; overflow: auto; }

.create-workbench { grid-template-columns: 380px minmax(0, 1fr); }
.create-field { display: grid; gap: 7px; margin: 12px 0; }
.create-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  color: var(--text-regular);
  background: var(--bg-white);
}

/* Style chips */
.style-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.style-chip {
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  background: var(--bg-white);
  color: var(--text-regular);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.style-chip:hover { border-color: var(--primary); color: var(--primary); }
.style-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Result grids */
.create-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.create-result-grid .visual-card { min-width: 190px; }
.create-result-grid .visual-card img { height: 220px; }
.create-result-grid .visual-card img.pixel-art { image-rendering: pixelated; image-rendering: crisp-edges; }

.material-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 8px 14px;
}
.mat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--text-regular);
  font-size: 13px;
}
.mat-row .mini {
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  flex: 0 0 auto;
}

/* Enhanced compare */
.enhanced-compare { display: grid; gap: 14px; }
.enhanced-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.enhanced-head .panel-title { margin-bottom: 6px; }
.enhanced-head p { margin: 0; color: var(--text-secondary); }
.enhanced-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) repeat(2, minmax(240px, .75fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.visual-card {
  min-width: 240px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-white);
}
.visual-card.diff-card { min-width: 360px; }
.visual-card strong { font-size: 13px; }
.visual-card span { color: var(--text-secondary); font-size: 12px; }
.visual-card img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: linear-gradient(45deg, #f8fafc 25%, #eef2f7 25%, #eef2f7 50%, #f8fafc 50%, #f8fafc 75%, #eef2f7 75%);
  background-size: 20px 20px;
}

.metric-compare-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.metric-compare-grid div {
  min-width: 140px;
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--bg-hover);
}
.metric-compare-grid span { color: var(--text-secondary); font-size: 12px; }
.metric-compare-grid strong { font-size: 22px; color: var(--text-primary); }
.metric-compare-grid em { color: var(--primary); font-style: normal; font-size: 12px; font-weight: 600; }

/* Config / crop */
.config-groups { display: grid; gap: 20px; }
.config-table td:first-child { min-width: 190px; }
.config-table input, .config-table select { min-width: 150px; }
.crop-box-wrap {
  position: relative;
  width: 100%;
  height: 230px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--text-primary);
  user-select: none;
  margin-bottom: 12px;
}
.crop-box-wrap img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.crop-rect {
  position: absolute;
  border: 2px solid var(--success);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  cursor: move;
}
.crop-rect span {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid #fff;
}
.crop-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.config-hint { margin-top: 10px; line-height: 1.7; }

/* V5 Pixel results */
.result-stats { display: flex; gap: 20px; align-items: center; }
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}
.stat-value { font-size: 20px; font-weight: 900; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 600; letter-spacing: 0.02em; }

.download-bar {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
}
.download-bar .btn { font-size: 13px; padding: 8px 14px; }

.pixel-showcase {
  background: repeating-conic-gradient(#e8ecf1 0% 25%, #fff 0% 50%) 50% / 20px 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.pixel-hd {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  max-width: 720px;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.material-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}
.material-table thead th {
  background: var(--bg-hover);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-light);
  text-align: left;
}
.material-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-lighter);
  vertical-align: middle;
}
.material-table tbody tr:hover { background: var(--bg-hover); }
.material-table .color-swatch {
  display: inline-block;
  width: 28px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
  vertical-align: middle;
}

/* Debug toggle */
.debug-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
}
.debug-chevron {
  width: 10px;
  height: 10px;
  border-right: 2.5px solid var(--text-secondary);
  border-bottom: 2.5px solid var(--text-secondary);
  transform: rotate(45deg);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.debug-chevron.open { transform: rotate(-135deg); }
.debug-content { margin-top: 14px; }
.debug-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.debug-cell { display: grid; gap: 8px; align-content: start; }
.debug-cell strong {
  font-size: 12px;
  color: var(--text-regular);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.debug-cell img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: linear-gradient(45deg, #f8fafc 25%, #eef2f7 25%, #eef2f7 50%, #f8fafc 50%, #f8fafc 75%, #eef2f7 75%);
  background-size: 16px 16px;
}
.debug-pre {
  background: var(--text-primary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.6;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.quality-info {
  padding: 10px 14px;
  background: var(--success-light);
  border: 1px solid #c2e7b0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .lab-workbench { grid-template-columns: 320px minmax(0, 1fr); }
  .create-workbench { grid-template-columns: 340px minmax(0, 1fr); }
  .result-images.compact { grid-template-columns: 1fr; }
  .result-images.compact img { max-height: 300px; }
  .create-result-grid, .material-grid { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
}

@media (max-width: 1180px) {
  .lab-grid, .compare-grid, .grid.cols-2.lab-bottom { grid-template-columns: 1fr; }
  .lab-form-grid, .analysis-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1040px) {
  .app { grid-template-columns: 1fr; }
  html[data-sidebar="collapsed"] .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    width: 240px;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-collapse-toggle { display: none; }
  html[data-sidebar="collapsed"] .brand {
    justify-content: flex-start;
    padding: 0 20px;
  }
  html[data-sidebar="collapsed"] .brand-logo {
    display: block !important;
  }
  html[data-sidebar="collapsed"] .theme-asset-dark {
    display: none !important;
  }
  html[data-sidebar="collapsed"] .theme-asset-light {
    display: block !important;
  }
  html[data-sidebar="collapsed"][data-theme="dark"] .theme-asset-light {
    display: none !important;
  }
  html[data-sidebar="collapsed"][data-theme="dark"] .theme-asset-dark {
    display: block !important;
  }
  html[data-sidebar="collapsed"] .nav-group { margin: 4px 0; }
  html[data-sidebar="collapsed"] .nav-parent {
    justify-content: flex-start;
    gap: 10px;
    height: auto;
    padding: 11px 20px;
    border-radius: 0;
  }
  html[data-sidebar="collapsed"] .nav-parent > span:not(.menu-icon):not(.nav-chevron) {
    display: inline;
  }
  html[data-sidebar="collapsed"] .nav-chevron {
    display: inline-block;
  }
  html[data-sidebar="collapsed"] .nav-children.open {
    display: block;
  }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }

  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar .field { min-width: 100%; max-width: 100%; }
  .lab-workbench, .lab-info-grid, .compare-grid.compact-results { grid-template-columns: 1fr; }
  .lab-sidebar { position: static; max-height: none; overflow: visible; }
  .enhanced-grid { grid-template-columns: minmax(330px, 1.1fr) repeat(2, minmax(220px, .8fr)); }
  .visual-card img { height: 200px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .debug-grid { grid-template-columns: 1fr; }
  .result-stats { gap: 12px; }
  .compare-grid.compact-results {
    grid-template-columns: repeat(2, minmax(390px, 1fr)) !important;
  }
  .compare-grid.compact-results > .result-card { min-width: 390px; }
}

@media (max-width: 980px) {
  .sidebar { width: 240px; }
  .enhanced-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .lab-hero { display: grid; }
  .result-images, .lab-form-grid, .analysis-grid { grid-template-columns: 1fr; }
  .lab-form-grid.compact, .analysis-grid.compact, .sidebar-summary .mini-metrics { grid-template-columns: 1fr; }
  .lab-actions-sticky { grid-template-columns: 1fr; }
  .lab-actions-sticky .btn.dark { grid-column: auto; }
  .create-result-grid, .material-grid { grid-template-columns: 1fr; }
  .result-stats { flex-wrap: wrap; gap: 8px; }
  .download-bar { flex-direction: column; }
  .download-bar .btn { width: 100%; text-align: center; }
  .compare-grid.compact-results {
    grid-template-columns: repeat(2, minmax(340px, 1fr)) !important;
  }
  .compare-grid.compact-results > .result-card { min-width: 340px; }
  .crop-actions { grid-template-columns: 1fr; }
}

/* Mobile menu toggle */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-regular);
}
.mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  margin: 5px 0;
  border-radius: 1px;
  transition: var(--transition);
}
@media (max-width: 1040px) {
  .mobile-toggle { display: block; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
@media (max-width: 1040px) {
  .sidebar-overlay.open { display: block; }
}

/* v-cloak */
[v-cloak] { display: none; }

/* ---------- Dark Theme Page Overrides ---------- */
html[data-theme="dark"] body,
html[data-theme="dark"] .content,
html[data-theme="dark"] .main {
  background: var(--bg-base);
  color: var(--text-regular);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .table,
html[data-theme="dark"] .admin-table,
html[data-theme="dark"] [class$="-table-wrap"],
html[data-theme="dark"] [class$="-filter"],
html[data-theme="dark"] [class$="-dialog"],
html[data-theme="dark"] [class$="-modal"],
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .form-dialog,
html[data-theme="dark"] .publish-dialog,
html[data-theme="dark"] .detail-dialog,
html[data-theme="dark"] .dialog-box,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .dict-type-list,
html[data-theme="dark"] .dict-item-panel,
html[data-theme="dark"] .position-card,
html[data-theme="dark"] .dash-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .visual-card,
html[data-theme="dark"] .result-card,
html[data-theme="dark"] .lab-sidebar,
html[data-theme="dark"] .lab-main-panel {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] [class$="-table"] th,
html[data-theme="dark"] .table th,
html[data-theme="dark"] .admin-table th,
html[data-theme="dark"] .detail-head,
html[data-theme="dark"] .publish-head,
html[data-theme="dark"] .dialog-head,
html[data-theme="dark"] .dialog-foot,
html[data-theme="dark"] .modal-head,
html[data-theme="dark"] .modal-foot,
html[data-theme="dark"] .form-head,
html[data-theme="dark"] .wb-modal-head,
html[data-theme="dark"] .wb-dialog-head {
  background: var(--bg-hover) !important;
  border-color: var(--border-light) !important;
  color: var(--text-primary) !important;
}

html[data-theme="dark"] td,
html[data-theme="dark"] [class$="-table"] td,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .admin-table td,
html[data-theme="dark"] .dict-type-item,
html[data-theme="dark"] .info-item,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .task-field,
html[data-theme="dark"] .spec-item,
html[data-theme="dark"] .color-card,
html[data-theme="dark"] .edit-node,
html[data-theme="dark"] .edit-record,
html[data-theme="dark"] .edit-meta,
html[data-theme="dark"] .text-block,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .empty-box,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .pixel-task-empty {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] tr:hover td,
html[data-theme="dark"] [class$="-table"] tr:hover td,
html[data-theme="dark"] .table tr:hover td,
html[data-theme="dark"] .admin-table tr:hover td,
html[data-theme="dark"] .dict-type-item:hover,
html[data-theme="dark"] .edit-node:hover {
  background: var(--bg-hover) !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .wb-select,
html[data-theme="dark"] .wb-rail-search,
html[data-theme="dark"] .wb-replace-input,
html[data-theme="dark"] .create-field textarea {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--text-placeholder) !important;
}

html[data-theme="dark"] label,
html[data-theme="dark"] small,
html[data-theme="dark"] .muted-mini,
html[data-theme="dark"] .user-id,
html[data-theme="dark"] .user-meta,
html[data-theme="dark"] .profile-meta,
html[data-theme="dark"] .task-time,
html[data-theme="dark"] .detail-subtitle,
html[data-theme="dark"] .preview-label,
html[data-theme="dark"] .pagination-info,
html[data-theme="dark"] .pixel-pagination-info,
html[data-theme="dark"] .color-meta,
html[data-theme="dark"] .wb-status,
html[data-theme="dark"] .wb-info-box span,
html[data-theme="dark"] .wb-stat-label,
html[data-theme="dark"] .wb-color-name,
html[data-theme="dark"] .wb-current-meta {
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] strong,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .topbar-title,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .task-code,
html[data-theme="dark"] .task-id,
html[data-theme="dark"] .detail-title,
html[data-theme="dark"] .detail-title *,
html[data-theme="dark"] .detail-title,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .profile-name,
html[data-theme="dark"] .task-no,
html[data-theme="dark"] .block-title,
html[data-theme="dark"] .kpi strong,
html[data-theme="dark"] .spec-item strong,
html[data-theme="dark"] .info-item strong,
html[data-theme="dark"] .task-field strong,
html[data-theme="dark"] .wb-sidebar-header h3,
html[data-theme="dark"] .wb-stat-val,
html[data-theme="dark"] .wb-color-rail-title,
html[data-theme="dark"] .wb-current-title,
html[data-theme="dark"] .wb-dialog-title,
html[data-theme="dark"] .wb-modal-title {
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .btn.ghost,
html[data-theme="dark"] .pagination-controls a,
html[data-theme="dark"] .pagination-controls span,
html[data-theme="dark"] .pixel-pagination-controls a,
html[data-theme="dark"] .pixel-pagination-controls span,
html[data-theme="dark"] .detail-links a,
html[data-theme="dark"] .detail-links span,
html[data-theme="dark"] .task-links a,
html[data-theme="dark"] .task-links span,
html[data-theme="dark"] .edit-record-links a,
html[data-theme="dark"] .edit-record-links span,
html[data-theme="dark"] .wb-dl-btn,
html[data-theme="dark"] .wb-modal-btn,
html[data-theme="dark"] .wb-dialog-close,
html[data-theme="dark"] .dialog-close,
html[data-theme="dark"] .dialog-close:hover {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .btn.ghost:hover,
html[data-theme="dark"] .pagination-controls a:hover,
html[data-theme="dark"] .pixel-pagination-controls a:hover,
html[data-theme="dark"] .detail-links a:hover,
html[data-theme="dark"] .task-links a:hover,
html[data-theme="dark"] .edit-record-links a:hover,
html[data-theme="dark"] .wb-dl-btn:hover {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  background: var(--primary-light) !important;
}

html[data-theme="dark"] .pill,
html[data-theme="dark"] .badge,
html[data-theme="dark"] .status-pill,
html[data-theme="dark"] .task-tag,
html[data-theme="dark"] .score-pill {
  background: rgba(96,165,250,.16) !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .pill.ok,
html[data-theme="dark"] .badge.success,
html[data-theme="dark"] .status-approved,
html[data-theme="dark"] .score-pill,
html[data-theme="dark"] .quality-item {
  background: rgba(52,211,153,.16) !important;
  border-color: rgba(52,211,153,.3) !important;
  color: #86efac !important;
}

html[data-theme="dark"] .pill.fail,
html[data-theme="dark"] .pill.danger,
html[data-theme="dark"] .badge.danger,
html[data-theme="dark"] .status-rejected,
html[data-theme="dark"] .status-taken,
html[data-theme="dark"] .error,
html[data-theme="dark"] .edit-error {
  background: rgba(251,113,133,.16) !important;
  border-color: rgba(251,113,133,.3) !important;
  color: #fda4af !important;
}

html[data-theme="dark"] .pill.run,
html[data-theme="dark"] .pill.warn,
html[data-theme="dark"] .badge.warn,
html[data-theme="dark"] .status-pending,
html[data-theme="dark"] .status-type,
html[data-theme="dark"] .detail-note,
html[data-theme="dark"] .tips div {
  background: rgba(251,191,36,.16) !important;
  border-color: rgba(251,191,36,.32) !important;
  color: #fde68a !important;
}

html[data-theme="dark"] .preview-box,
html[data-theme="dark"] .thumb,
html[data-theme="dark"] .detail-image,
html[data-theme="dark"] .detail-shot a,
html[data-theme="dark"] .detail-shot-empty,
html[data-theme="dark"] .upload-zone,
html[data-theme="dark"] .pixel-showcase,
html[data-theme="dark"] .result-images img,
html[data-theme="dark"] .visual-card img,
html[data-theme="dark"] .debug-cell img {
  background-color: #111827 !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .media-frame img,
html[data-theme="dark"] .media-frame iframe,
html[data-theme="dark"] .wb-modal-body img {
  background: #fff !important;
}

html[data-theme="dark"] .wb-body,
html[data-theme="dark"] #pixelCreate,
html[data-theme="dark"] .wb-workspace,
html[data-theme="dark"] .wb-sidebar,
html[data-theme="dark"] .wb-topbar,
html[data-theme="dark"] .wb-tabs,
html[data-theme="dark"] .wb-color-rail,
html[data-theme="dark"] .wb-modal,
html[data-theme="dark"] .wb-dialog,
html[data-theme="dark"] .wb-side-editor,
html[data-theme="dark"] .wb-edit-section,
html[data-theme="dark"] .wb-info-box,
html[data-theme="dark"] .wb-current-bar,
html[data-theme="dark"] .wb-mini-popover,
html[data-theme="dark"] .wb-replace-picker,
html[data-theme="dark"] .wb-suggest-row,
html[data-theme="dark"] .wb-replace-option,
html[data-theme="dark"] .wb-edit-selected,
html[data-theme="dark"] .wb-dev-panel {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .wb-img-viewer,
html[data-theme="dark"] .wb-grid-viewer,
html[data-theme="dark"] .wb-grid-stage,
html[data-theme="dark"] .wb-modal-body,
html[data-theme="dark"] .wb-empty,
html[data-theme="dark"] .wb-rail-status,
html[data-theme="dark"] .wb-color-list,
html[data-theme="dark"] .wb-materials {
  background: var(--bg-base) !important;
}

html[data-theme="dark"] .wb-tab,
html[data-theme="dark"] .wb-field label,
html[data-theme="dark"] .wb-toggle-row span,
html[data-theme="dark"] .wb-info-box strong,
html[data-theme="dark"] .wb-style-chip,
html[data-theme="dark"] .wb-crop-ratio-btn,
html[data-theme="dark"] .wb-color-tools button,
html[data-theme="dark"] .wb-current-actions button,
html[data-theme="dark"] .wb-edit-actions button,
html[data-theme="dark"] .wb-action-line button,
html[data-theme="dark"] .wb-suggest-row button,
html[data-theme="dark"] .wb-suggest-footer button,
html[data-theme="dark"] .wb-dev-link {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .wb-tab.active,
html[data-theme="dark"] .wb-crop-ratio-btn.active,
html[data-theme="dark"] .wb-style-chip.active,
html[data-theme="dark"] .wb-color-tools button.primary,
html[data-theme="dark"] .wb-current-actions button.primary,
html[data-theme="dark"] .wb-edit-actions button.primary,
html[data-theme="dark"] .wb-action-line button.primary,
html[data-theme="dark"] .wb-suggest-footer button.primary,
html[data-theme="dark"] .wb-dl-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

html[data-theme="dark"] .wb-generate-btn {
  background: #ff6a00 !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(255, 106, 0, .28);
}

html[data-theme="dark"] .wb-generate-btn:hover:not(:disabled) {
  background: #f97316 !important;
}

html[data-theme="dark"] .wb-generate-btn:disabled {
  background: #475569 !important;
  color: #cbd5e1 !important;
  box-shadow: none;
}

html[data-theme="dark"] .lab-actions-sticky {
  background: linear-gradient(rgba(30,41,59,.9), #1e293b 30%) !important;
}

html[data-theme="dark"] .menu-icon {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}

html[data-theme="dark"] .icon-dashboard { background: rgba(56,189,248,.14); color: #7dd3fc; }
html[data-theme="dark"] .icon-chart { background: rgba(251,146,60,.16); color: #fdba74; }
html[data-theme="dark"] .icon-store { background: rgba(251,146,60,.16); color: #fdba74; }
html[data-theme="dark"] .icon-material { background: rgba(74,222,128,.15); color: #86efac; }
html[data-theme="dark"] .icon-image { background: rgba(244,114,182,.16); color: #f9a8d4; }
html[data-theme="dark"] .icon-user,
html[data-theme="dark"] .icon-account { background: rgba(129,140,248,.16); color: #c4b5fd; }
html[data-theme="dark"] .icon-project { background: rgba(45,212,191,.16); color: #5eead4; }
html[data-theme="dark"] .icon-download { background: rgba(251,191,36,.16); color: #fde68a; }
html[data-theme="dark"] .icon-log { background: rgba(248,113,113,.16); color: #fca5a5; }
html[data-theme="dark"] .icon-setting { background: rgba(132,204,22,.16); color: #bef264; }
html[data-theme="dark"] .icon-role { background: rgba(96,165,250,.16); color: #bfdbfe; }
html[data-theme="dark"] .icon-menu { background: rgba(168,85,247,.18); color: #d8b4fe; }
html[data-theme="dark"] .icon-default { background: rgba(148,163,184,.16); color: #cbd5e1; }

/* Dict management page */
html[data-theme="dark"] .dict-container .dict-sidebar,
html[data-theme="dark"] .dict-container .dict-main,
html[data-theme="dark"] .dialog-overlay .dialog-box {
  background: var(--bg-white) !important;
  border: 1px solid var(--border-light) !important;
  color: var(--text-regular) !important;
  box-shadow: var(--shadow) !important;
}

html[data-theme="dark"] .dict-container .sidebar-header,
html[data-theme="dark"] .dict-container .main-header {
  border-bottom-color: var(--border-light) !important;
}

html[data-theme="dark"] .dict-container .sidebar-header h3,
html[data-theme="dark"] .dict-container .main-header h3,
html[data-theme="dark"] .dialog-overlay .dialog-title,
html[data-theme="dark"] .dialog-overlay .form-group label,
html[data-theme="dark"] .dict-container .type-name {
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .dict-container .type-code,
html[data-theme="dark"] .dict-container .empty-tip,
html[data-theme="dark"] .dict-container .loading {
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .dict-container .type-list li {
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .dict-container .type-list li:hover {
  background: var(--bg-hover) !important;
}

html[data-theme="dark"] .dict-container .type-list li.active {
  background: var(--bg-active) !important;
  border-left-color: var(--primary) !important;
}

html[data-theme="dark"] .dict-container .type-actions button:hover,
html[data-theme="dark"] .dict-container .type-actions a:hover {
  background: var(--bg-hover) !important;
}

html[data-theme="dark"] .dialog-overlay .btn-default {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .dialog-overlay .btn-default:hover {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

html[data-theme="dark"] .form-card {
  background: var(--bg-white);
  border-color: var(--border-light);
}
html[data-theme="dark"] .form-card-title {
  color: var(--text-primary);
}

/* Dashboard page */
html[data-theme="dark"] .dashboard .dash-title,
html[data-theme="dark"] .dashboard .dash-card-title,
html[data-theme="dark"] .dashboard .metric-value,
html[data-theme="dark"] .dashboard .trend-total,
html[data-theme="dark"] .dashboard .funnel-name,
html[data-theme="dark"] .dashboard .funnel-value,
html[data-theme="dark"] .dashboard .material-title,
html[data-theme="dark"] .dashboard .action-user {
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .dashboard .dash-subtitle,
html[data-theme="dark"] .dashboard .metric-label,
html[data-theme="dark"] .dashboard .metric-foot,
html[data-theme="dark"] .dashboard .dash-card-note,
html[data-theme="dark"] .dashboard .trend-date,
html[data-theme="dark"] .dashboard .legend span,
html[data-theme="dark"] .dashboard .funnel-meta,
html[data-theme="dark"] .dashboard .material-sub,
html[data-theme="dark"] .dashboard .action-meta {
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .dashboard .metric-card,
html[data-theme="dark"] .dashboard .dash-card {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
  box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] .dashboard .time-switch {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
}

html[data-theme="dark"] .dashboard .time-switch a {
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .dashboard .time-switch a:hover {
  background: var(--bg-hover) !important;
  color: var(--primary) !important;
}

html[data-theme="dark"] .dashboard .time-switch a.active {
  background: var(--primary-light) !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .dashboard .trend-bars {
  border-bottom-color: var(--border-color) !important;
}

html[data-theme="dark"] .dashboard .funnel-track {
  background: #334155 !important;
}

html[data-theme="dark"] .dashboard .table-quiet th {
  background: var(--bg-hover) !important;
  border-bottom-color: var(--border-light) !important;
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .dashboard .table-quiet td {
  border-bottom-color: var(--border-lighter) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .dashboard .table-quiet tr:hover td {
  background: var(--bg-hover) !important;
}

html[data-theme="dark"] .dashboard .material-thumb,
html[data-theme="dark"] .dashboard .material-thumb.empty {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .dashboard .rank-num {
  background: var(--primary-light) !important;
  color: #bfdbfe !important;
}

/* Projects page */
html[data-theme="dark"] .project-empty,
html[data-theme="dark"] .project-table-wrap {
  background: var(--bg-white) !important;
  border-color: var(--border-light) !important;
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .project-table th {
  background: var(--bg-hover) !important;
  border-bottom-color: var(--border-light) !important;
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .project-table td {
  border-bottom-color: var(--border-lighter) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .project-table tr:hover td {
  background: var(--bg-hover) !important;
}

html[data-theme="dark"] .project-nickname,
html[data-theme="dark"] .project-task-no,
html[data-theme="dark"] .project-spec-item strong {
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .project-user-meta,
html[data-theme="dark"] .project-time,
html[data-theme="dark"] .project-artifact-label,
html[data-theme="dark"] .project-spec-item span,
html[data-theme="dark"] .project-pagination-info {
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .project-avatar,
html[data-theme="dark"] .project-avatar-fallback,
html[data-theme="dark"] .project-preview-box,
html[data-theme="dark"] .project-preview-box.pdf,
html[data-theme="dark"] .project-spec-item {
  background-color: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

html[data-theme="dark"] .project-preview-box {
  background-image:
    linear-gradient(45deg, rgba(148,163,184,.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148,163,184,.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148,163,184,.16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148,163,184,.16) 75%) !important;
}

html[data-theme="dark"] .project-preview-box.pdf {
  color: #fb7185 !important;
}

html[data-theme="dark"] .project-tag {
  background: rgba(96,165,250,.16) !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .project-tag.neutral {
  background: rgba(148,163,184,.16) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .project-pagination-controls a,
html[data-theme="dark"] .project-pagination-controls span {
  background: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-regular) !important;
}

html[data-theme="dark"] .project-pagination-controls a:hover {
  background: var(--bg-hover) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

html[data-theme="dark"] .project-pagination-controls .active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

html[data-theme="dark"] .project-pagination-controls .disabled {
  background: #0f172a !important;
  border-color: var(--border-lighter) !important;
  color: var(--text-placeholder) !important;
}

/* ---------- Admin Image Upload Preview ---------- */
.admin-image-upload {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  width: 100%;
}
.admin-image-upload-preview {
  position: relative;
  width: 112px;
  min-height: 112px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-base);
  overflow: hidden;
  cursor: pointer;
}
.admin-image-upload-preview img {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 112px;
  object-fit: cover;
}
.admin-image-upload.has-image .admin-image-upload-preview img {
  display: block;
}
.admin-image-upload-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}
.admin-image-upload.has-image .admin-image-upload-placeholder {
  display: none;
}
.admin-image-upload-plus {
  width: 32px;
  height: 32px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 300;
}
.admin-image-upload-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.admin-image-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.admin-image-upload-filename {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}
.admin-image-upload input[type="file"] {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
  pointer-events: none;
}
html[data-theme="dark"] .admin-image-upload-preview {
  background: #0f172a;
  border-color: var(--border-color);
}
html[data-theme="dark"] .admin-image-upload-filename,
html[data-theme="dark"] .admin-image-upload-placeholder {
  color: var(--text-secondary);
}
@media (max-width: 640px) {
  .admin-image-upload {
    grid-template-columns: 1fr;
  }
  .admin-image-upload-preview {
    width: 100%;
    min-height: 160px;
  }
}
