/* ===== CSS Variables - Light Theme (Default) ===== */
:root {
  /* Brand Colors (shared) */
  --primary: #0D7C66;
  --primary-light: #10A37F;
  --primary-dark: #095E4E;
  --secondary: #1A3A2A;
  --accent: #C9963B;
  --accent-light: #DDB05E;
  --success: #2ECC71;
  --warning: #F39C12;
  --error: #E74C3C;
  --info: #3498DB;

  /* Light Theme - Main Content */
  --bg-dark: #F0F2F5;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F7F8FA;
  --border: #E2E6EC;
  --border-light: #D0D5DD;
  --text-primary: #1A2332;
  --text-secondary: #5A6B82;
  --text-muted: #8B9BB4;

  /* Light Theme - Sidebar keeps dark green */
  --sidebar-bg: #0D1F17;
  --sidebar-border: #153026;
  --sidebar-text: #C8D6CF;
  --sidebar-text-muted: #6B8A7A;
  --sidebar-hover: rgba(13,124,102,0.15);
  --sidebar-active: rgba(13,124,102,0.25);
  --sidebar-active-text: #10A37F;
  --sidebar-group-title: #4A6B5A;

  /* Light Theme - Navbar */
  --navbar-bg: #FFFFFF;
  --navbar-border: #E2E6EC;
  --navbar-text: #1A2332;
  --navbar-text-secondary: #5A6B82;

  /* Light Theme - Login */
  --login-bg: #F0F2F5;
  --login-card-bg: #FFFFFF;
  --login-input-bg: #F5F6F8;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --navbar-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 300ms ease-out;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg-dark: #0B1426;
  --bg-card: #111D2E;
  --bg-card-hover: #162640;
  --border: #1E3048;
  --border-light: #2A4060;
  --text-primary: #E8ECF1;
  --text-secondary: #8B9BB4;
  --text-muted: #5A6B82;

  --sidebar-bg: #111D2E;
  --sidebar-border: #1E3048;
  --sidebar-text: #8B9BB4;
  --sidebar-text-muted: #5A6B82;
  --sidebar-hover: rgba(13,124,102,0.08);
  --sidebar-active: rgba(13,124,102,0.12);
  --sidebar-active-text: #10A37F;
  --sidebar-group-title: #5A6B82;

  --navbar-bg: #111D2E;
  --navbar-border: #1E3048;
  --navbar-text: #E8ECF1;
  --navbar-text-secondary: #8B9BB4;

  --login-bg: #0B1426;
  --login-card-bg: #111D2E;
  --login-input-bg: #0B1426;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--accent-light);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--login-bg);
  position: relative;
  overflow: hidden;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image:
    radial-gradient(circle at 25% 25%, var(--primary) 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, var(--accent) 1px, transparent 1px);
  background-size: 60px 60px;
}

.login-mountain {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 100%;
  pointer-events: none;
}

.login-container {
  display: flex;
  align-items: center;
  gap: 80px;
  z-index: 1;
  padding: 0 40px;
  width: 100%;
  max-width: 1200px;
}

.login-brand {
  flex: 1;
  max-width: 480px;
}

.login-brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-brand-logo .logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.login-brand-logo .logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.login-brand h1 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-brand p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.login-card {
  width: 420px;
  flex-shrink: 0;
  background: var(--login-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-card .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--login-input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,124,102,0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 13px;
}

.form-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-row label input[type="checkbox"] {
  accent-color: var(--primary);
}

.form-row a {
  color: var(--primary-light);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 12px;
  font-size: 15px;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-dark);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  filter: brightness(1.1);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

/* ===== Main Layout ===== */
.app-layout {
  display: none;
  height: 100vh;
  overflow: hidden;
}

.app-layout.active {
  display: flex;
  flex-direction: column;
}

.login-page.hidden {
  display: none;
}

/* ===== Navbar ===== */
.navbar {
  height: var(--navbar-height);
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--navbar-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: var(--sidebar-width);
  flex-shrink: 0;
  transition: width var(--transition);
}

.navbar-brand.collapsed {
  width: var(--sidebar-collapsed);
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.navbar-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--navbar-text);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.navbar-brand.collapsed .brand-name {
  opacity: 0;
  width: 0;
}
.navbar-brand .brand-slogan {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 12px;
  white-space: nowrap;
  opacity: 0.7;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}
.navbar-brand.collapsed .brand-slogan {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.navbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--navbar-text-secondary);
  padding-left: 20px;
}

.navbar-breadcrumb .sep {
  color: var(--text-muted);
}

.navbar-breadcrumb .current {
  color: var(--navbar-text);
  font-weight: 500;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--navbar-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--accent);
  background: rgba(13,124,102,0.06);
}

[data-theme="dark"] .theme-toggle-btn {
  color: var(--accent-light);
}

.navbar-actions .btn-home-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: rgba(13,124,102,0.12);
  border: 1px solid rgba(13,124,102,0.3);
  border-radius: var(--radius);
  color: var(--primary-light);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.navbar-actions .btn-home-link:hover {
  background: rgba(13,124,102,0.2);
  border-color: var(--primary);
}

.navbar-actions .notification-btn {
  position: relative;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--navbar-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.navbar-actions .notification-btn:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.navbar-actions .notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--error);
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.navbar-user:hover {
  border-color: var(--primary);
}

.navbar-user .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: white;
  font-weight: 600;
}

.navbar-user .user-name {
  font-size: 13px;
  color: var(--navbar-text);
  font-weight: 500;
}

.navbar-user .user-role {
  font-size: 11px;
  color: var(--navbar-text-secondary);
}

/* ===== Content Wrapper ===== */
.content-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Content Area (tab-bar + iframe) ===== */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-toggle button {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  color: var(--sidebar-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 16px;
}

.sidebar-toggle button:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-group-title);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-group-title {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active-text);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--primary-light);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 16px;
}

.nav-item .nav-label {
  flex: 1;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
}

.nav-item .nav-arrow {
  font-size: 12px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.nav-item .nav-arrow.open {
  transform: rotate(90deg);
}

.sidebar.collapsed .nav-arrow {
  opacity: 0;
}

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.nav-submenu.open {
  max-height: 300px;
}

.sidebar.collapsed .nav-submenu {
  max-height: 0 !important;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 8px 52px;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 13px;
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  text-align: left;
}

.nav-sub-item:hover {
  color: var(--sidebar-active-text);
  background: var(--sidebar-hover);
}

.nav-sub-item.active {
  color: var(--sidebar-active-text);
}

.nav-sub-item::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.nav-sub-item.active::before {
  opacity: 1;
  background: var(--primary-light);
}

/* ===== Main Content ===== */
/* ===== Main Content iframe ===== */
/* ===== Tab Bar (PearAdmin style) ===== */
.tab-bar {
  height: 40px;
  min-height: 40px;
  background: var(--card-dark, #111D2E);
  border-bottom: 1px solid var(--border-dark, #1E3048);
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  position: relative;
  z-index: 5;
}

[data-theme="light"] .tab-bar {
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
}

.tab-bar-scroll {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tab-bar-scroll::-webkit-scrollbar {
  display: none;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-secondary, #8B9BB4);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
  user-select: none;
}

.tab-item:hover {
  color: var(--text-primary, #E8ECF1);
  background: rgba(13,124,102,.08);
}

[data-theme="light"] .tab-item {
  color: #6B7280;
}

[data-theme="light"] .tab-item:hover {
  color: #0D7C66;
  background: rgba(13,124,102,.06);
}

.tab-item.active {
  color: var(--accent, #0D7C66);
  background: rgba(13,124,102,.12);
  border-color: rgba(13,124,102,.25);
  font-weight: 500;
}

[data-theme="light"] .tab-item.active {
  color: #0D7C66;
  background: rgba(13,124,102,.08);
  border-color: rgba(13,124,102,.2);
}

.tab-item .tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 12px;
  color: inherit;
  opacity: 0.5;
  border-radius: 50%;
  transition: all 0.15s ease;
  line-height: 1;
}

.tab-item .tab-close:hover {
  opacity: 1;
  background: rgba(231,76,60,.15);
  color: #E74C3C;
}

.tab-item.home-tab .tab-close {
  display: none;
}

.main-frame {
  flex: 1;
  width: 100%;
  height: 0; /* flex:1 需要配合 height:0 让 iframe 自动填充剩余空间 */
  min-height: 0;
  border: none;
  background: var(--bg-dark);
}

.page {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
}

.card:hover {
  border-color: var(--border-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header .card-actions {
  display: flex;
  gap: 8px;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.green::after { background: var(--primary); }
.stat-card.gold::after { background: var(--accent); }
.stat-card.blue::after { background: var(--info); }
.stat-card.red::after { background: var(--error); }

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-card.green .stat-icon { background: rgba(13,124,102,0.15); color: var(--primary-light); }
.stat-card.gold .stat-icon { background: rgba(201,150,59,0.15); color: var(--accent-light); }
.stat-card.blue .stat-icon { background: rgba(52,152,219,0.15); color: var(--info); }
.stat-card.red .stat-icon { background: rgba(231,76,60,0.15); color: var(--error); }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-card .stat-change {
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--error); }

/* ===== Tables ===== */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: rgba(13,124,102,0.05);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-warning { background: rgba(243,156,18,0.15); color: var(--warning); }
.badge-error { background: rgba(231,76,60,0.15); color: var(--error); }
.badge-info { background: rgba(52,152,219,0.15); color: var(--info); }
.badge-primary { background: rgba(13,124,102,0.15); color: var(--primary-light); }

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* ===== Search & Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.search-input input:focus {
  border-color: var(--primary);
}

.search-input .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.filter-select {
  padding: 8px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: var(--primary);
}

/* ===== Chart Placeholder ===== */
.chart-placeholder {
  height: 240px;
  background: linear-gradient(135deg, rgba(13,124,102,0.05), rgba(201,150,59,0.05));
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
}

.chart-placeholder .chart-icon {
  font-size: 36px;
  opacity: 0.5;
}

/* ===== Progress Bar ===== */
.progress-bar {
  height: 6px;
  background: var(--bg-dark);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-fill.green { background: var(--primary-light); }
.progress-fill.gold { background: var(--accent); }
.progress-fill.blue { background: var(--info); }

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
}

.timeline-item .time {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-item .content {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 18px;
}

.modal-close:hover {
  border-color: var(--error);
  color: var(--error);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== Pulse Animation ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ===== Tag ===== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  gap: 4px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

/* ===== Service Card ===== */
.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.service-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.service-card .service-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.service-card h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.service-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  flex: 1;
}

.service-card .service-price {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.service-card .service-price span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== Trace Chain ===== */
.trace-chain {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 20px 0;
}

.trace-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  position: relative;
}

.trace-node .node-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(13,124,102,0.15);
  color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 8px;
  border: 2px solid var(--primary);
}

.trace-node .node-label {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  text-align: center;
}

.trace-node .node-detail {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
}

.trace-arrow {
  width: 40px;
  height: 2px;
  background: var(--primary);
  position: relative;
  flex-shrink: 0;
}

.trace-arrow::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -3px;
  width: 0;
  height: 0;
  border-left: 6px solid var(--primary);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* ===== Equipment Status ===== */
.equipment-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.equipment-card:hover {
  border-color: var(--border-light);
}

.equipment-card .eq-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.equipment-card .eq-info {
  flex: 1;
}

.equipment-card .eq-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.equipment-card .eq-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.equipment-card .eq-status {
  text-align: right;
}

/* ===== Gantt Placeholder ===== */
.gantt-bar {
  height: 28px;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  color: white;
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}

/* ===== Hexagon Grid ===== */
.hex-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  padding: 20px;
}

.hex-item {
  width: 100px;
  height: 110px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--bg-card);
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  gap: 4px;
}

.hex-item:hover {
  background: rgba(13,124,102,0.2);
}

.hex-item .hex-icon {
  font-size: 22px;
}

.hex-item .hex-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab:hover {
  color: var(--text-primary);
}
.tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}
.tab-content {
  display: none;
}
.tab-content[style*="display:block"], .tab-content[style*="display: block"] {
  display: block;
}

/* ===== Trace Chain ===== */
.trace-chain {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 8px;
  overflow-x: auto;
}
.trace-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
  text-align: center;
}
.trace-node .node-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(13,124,102,0.15);
  border: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.trace-node .node-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.trace-node .node-detail {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}
.trace-arrow {
  width: 32px;
  height: 2px;
  background: var(--primary-light);
  position: relative;
  flex-shrink: 0;
}
.trace-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  border: 5px solid transparent;
  border-left-color: var(--primary-light);
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
  padding-left: 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--bg-card);
}
.timeline-item .time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: 'Inter', monospace;
}
.timeline-item .content {
  font-size: 13px;
  color: var(--text-primary);
}

/* ===== Extra Badge Colors ===== */
.badge-gold {
  background: rgba(201,150,59,0.15);
  color: var(--accent);
}
.badge-muted {
  background: rgba(139,155,180,0.15);
  color: var(--text-muted);
}

/* ===== SPC Chart Placeholder ===== */
.spc-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.spc-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.spc-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 90px;
  text-align: right;
}
.spc-bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-dark);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.spc-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.spc-bar-fill.green { background: rgba(46,204,113,0.4); }
.spc-bar-fill.gold { background: rgba(201,150,59,0.4); }
.spc-bar-fill.red { background: rgba(231,76,60,0.4); }
.spc-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 50px;
}

/* ===== Gantt Row ===== */
.gantt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.gantt-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 120px;
  text-align: right;
}
.gantt-track {
  flex: 1;
  height: 28px;
  background: var(--bg-dark);
  border-radius: 4px;
  position: relative;
}
.gantt-bar {
  position: absolute;
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}
.gantt-bar.green { background: rgba(13,124,102,0.7); }
.gantt-bar.gold { background: rgba(201,150,59,0.7); }
.gantt-bar.red { background: rgba(231,76,60,0.6); }
.gantt-bar.blue { background: rgba(52,152,219,0.7); }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .login-container {
    flex-direction: column;
    gap: 40px;
  }
  .login-brand {
    text-align: center;
  }
  .login-brand h1 {
    font-size: 28px;
  }
  .login-card {
    width: 100%;
    max-width: 400px;
  }

  /* Navbar mobile */
  .navbar {
    padding: 0 12px;
  }
  .navbar-brand {
    width: auto;
    flex-shrink: 0;
  }
  .navbar-brand .brand-name {
    font-size: 14px;
  }
  .navbar-breadcrumb {
    display: none;
  }
  .navbar-actions .notification-btn {
    width: 32px;
    height: 32px;
  }
  .navbar-actions .btn-home-link {
    padding: 4px 10px;
    font-size: 12px;
  }
  .navbar-user .user-role {
    display: none;
  }

  /* Hamburger button */
  .hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 8px 6px;
    transition: all 0.2s;
  }
  .hamburger-btn:hover {
    border-color: var(--primary);
  }
  .hamburger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: all 0.3s;
  }

  /* Sidebar mobile */
  .sidebar {
    position: fixed;
    left: -260px;
    top: var(--navbar-height);
    bottom: 0;
    width: 260px;
    z-index: 300;
    transition: left 0.3s ease;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .sidebar.collapsed {
    width: 260px;
  }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-group-title,
  .sidebar.collapsed .nav-arrow {
    opacity: 1;
    height: auto;
    width: auto;
    overflow: visible;
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 250;
    transition: opacity 0.3s;
  }
  .sidebar-overlay.active {
    display: block;
  }

  /* Content takes full width */
  .main-frame {
    width: 100%;
  }

  /* Page body mobile adjustments */
  body.page-body {
    padding: 12px;
  }
}

/* Hamburger hidden on desktop */
.hamburger-btn {
  display: none;
}

/* Sidebar overlay hidden on desktop */
.sidebar-overlay {
  display: none;
}

/* ===== 条码标签 ===== */
.barcode-tag {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: var(--bg-dark);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ===== Badge 扩展 ===== */
.badge-muted {
  background: rgba(139,155,180,0.12);
  color: var(--text-muted);
}

.badge-error {
  background: rgba(231,76,60,0.12);
  color: var(--error);
}

/* ===== 追溯链（水平） ===== */
.trace-chain {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  overflow-x: auto;
}
.trace-chain .trace-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  text-align: center;
}
.trace-chain .trace-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}
.trace-chain .trace-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trace-chain .trace-label {
  font-size: 11px;
  color: var(--text-muted);
}
.trace-chain .trace-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.trace-chain .trace-detail {
  font-size: 10px;
  color: var(--text-muted);
}
.trace-chain .trace-arrow {
  font-size: 18px;
  color: var(--primary-light);
  flex-shrink: 0;
}

/* ===== iframe Page Body ===== */
body.page-body {
  margin: 0;
  padding: 24px;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: auto !important; /* iframe内容页需要可滚动 */
  height: auto !important;
}

/* ===== Mobile Page Content Responsive ===== */
@media (max-width: 768px) {
  body.page-body {
    padding: 12px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header h1 {
    font-size: 20px;
  }
  .filter-bar {
    flex-direction: column;
    gap: 8px;
  }
  .filter-bar .filter-group {
    width: 100%;
  }
  .filter-bar .form-input,
  .filter-bar select {
    width: 100%;
  }
  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    min-width: 600px;
  }
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .tab-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .card {
    padding: 12px;
  }
  .modal-content {
    margin: 10px;
    max-height: 85vh;
    overflow-y: auto;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .trace-chain {
    padding: 12px 8px;
  }
  .gantt-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .gantt-bar-area {
    width: 100%;
  }
}

/* ===== Light Theme Specific Adjustments ===== */
[data-theme="light"] .stat-card,
[data-theme="light"] .info-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="light"] .data-table th {
  background: #F5F6F8;
  color: #1A2332;
  border-bottom: 2px solid #E2E6EC;
}

[data-theme="light"] .data-table td {
  border-bottom: 1px solid #F0F1F3;
}

[data-theme="light"] .data-table tr:hover td {
  background: #F7F8FA;
}

[data-theme="light"] .tab-btn {
  border-bottom-color: #E2E6EC;
}

[data-theme="light"] .tab-btn.active {
  border-bottom-color: var(--primary);
  background: rgba(13,124,102,0.04);
}

[data-theme="light"] .modal-content {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

[data-theme="light"] .login-brand h1 {
  -webkit-text-fill-color: var(--primary);
}

[data-theme="light"] .badge-muted {
  background: #F0F1F3;
  color: #5A6B82;
}

/* ===== Dark Theme Specific Adjustments ===== */
[data-theme="dark"] .stat-card,
[data-theme="dark"] .info-card {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

[data-theme="dark"] .modal-content {
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
