* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%; 
    font-family: -apple-system, 'SF Pro SC', 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #eef2f7 0%, #e0e7ff 100%);
    color: #1f2937; 
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
:root {
    --bg: linear-gradient(135deg, #eef2f7 0%, #e0e7ff 100%);
    --bg-flat: #eef2f7;
    --bg-card: rgba(255, 255, 255, 0.9); 
    --bg-subtle: #f9fafb; 
    --bg-hover: #f3f4f6;
    --border: rgba(0,0,0,0.06); 
    --text: #1f2937; 
    --text-secondary: #6b7280;
    --text-muted: #9ca3af; 
    --accent: #3b82f6; 
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 16px; 
    --radius-lg: 24px;
    --radius-xl: 32px;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', 'Consolas', monospace;
    --sidebar-width: 64px;
    --sidebar-bg: #ffffff;
    --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-md: 0 10px 25px -5px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    --bg: linear-gradient(135deg, #0f1117 0%, #151825 100%);
    --bg-flat: #0f1117;
    --bg-card: rgba(30, 32, 40, 0.9);
    --bg-subtle: #1e2028;
    --bg-hover: #282a34;
    --border: rgba(255,255,255,0.07);
    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #60a5fa;
    --sidebar-bg: rgba(30, 32, 40, 0.95);
    --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.2);
    --shadow-md: 0 10px 25px -5px rgba(0,0,0,0.3);
    color-scheme: dark;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #0f1117 0%, #151825 100%);
    color: #e5e7eb;
}

[data-theme="dark"] .sidebar {
    background: var(--sidebar-bg);
    border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .nav-item {
    color: #6b7280;
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #9ca3af;
}

[data-theme="dark"] .nav-item.active {
    background: rgba(96,165,250,0.1);
    color: #60a5fa;
}

[data-theme="dark"] .nav-item .nav-dot {
    background: #60a5fa;
}

[data-theme="dark"] .nav-tooltip {
    background: #374151;
}

[data-theme="dark"] .nav-divider {
    background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .sidebar-traffic div {
    opacity: 0.7;
}

/* Disable transitions during theme switch to prevent flicker */
.theme-switching,
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: none !important;
}

/* View Transition for theme toggle */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  z-index: 1;
}

* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; }

/* ===== Window Traffic Lights ===== */
.window-traffic {
  position: fixed;
  left: 16px;
  top: 0;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  --wails-draggable: no-drag;
  z-index: 201;
}

/* macOS 使用原生窗口控件，隐藏自定义红绿灯 */
.platform-darwin .window-traffic {
  display: none;
}

.window-traffic div {
  width: 11px; height: 11px;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s;
}

.window-traffic div:hover {
  opacity: 0.8;
}

/* ===== Sidebar (Floating) ===== */
.sidebar {
  position: fixed;
  left: 16px; top: 44px; bottom: 16px;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 200;
  --wails-draggable: drag;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  --wails-draggable: no-drag;
}

.nav-item {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #6b7280;
  position: relative;
}

.nav-item:hover {
  background: #e5e7eb;
  color: #374151;
}

.nav-item.active {
  background: #dbeafe;
  color: #2563eb;
}

.nav-item svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon-img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  opacity: 0.8;
  transition: all 0.3s ease;
}

.nav-item:hover .nav-icon-img {
  opacity: 0.9;
}

.nav-item.active .nav-icon-img {
  opacity: 1;
}

.nav-item .nav-dot {
  position: absolute;
  left: -2px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 20px;
  border-radius: 2px;
  background: #3b82f6;
  opacity: 0;
  transition: opacity 0.2s;
}

.nav-item.active .nav-dot {
  opacity: 1;
}

.nav-tooltip {
  display: none;
  position: absolute;
  left: calc(var(--sidebar-width) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.nav-item:hover .nav-tooltip {
  display: block;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 20px;
  gap: 6px;
  --wails-draggable: no-drag;
}

.nav-divider {
  width: 32px;
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: 6px 0;
}

/* ===== Window Titlebar ===== */
.app-titlebar {
  position: fixed;
  top: 0; left: var(--sidebar-width); right: 0;
  height: 38px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  --wails-draggable: drag;
  z-index: 100;
}

.app-titlebar-text {
  position: absolute;
  left: calc(50% - var(--sidebar-width) / 2);
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.3px;
  pointer-events: none;
}

/* ===== Main Layout ===== */
.app-layout {
  margin-left: calc(var(--sidebar-width) + 32px);
  margin-right: 16px;
  margin-top: 38px;
  height: calc(100vh - 38px);
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  background: transparent;
}

/* ===== Pages ===== */
.page { display: none; }
.page.active { display: block; }

.page-scroll {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ===== Placeholder pages ===== */
.page-placeholder {
  display: none;
  height: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.page-placeholder.active { display: flex; }

.placeholder-icon {
  width: 64px; height: 64px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.placeholder-icon svg {
  width: 28px; height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.placeholder-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.placeholder-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Iframe page ===== */
.page-iframe {
  display: none;
  height: 100%;
}
.page-iframe.active { display: block; }
.page-iframe iframe {
  width: 100%; height: 100%;
  border: none;
}

/* ===== Tabs ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  z-index: 10;
  padding: 0 32px;
}

.tab-item {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
}

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

.tab-item.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  padding: 0 32px 32px;
}

.tab-panel.active {
  display: block;
}

/* ===== Logs Page (统一日志) ===== */
.logs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.logs-panel {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
[data-theme="dark"] .logs-panel {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
}
.logs-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.logs-panel .log-box {
  border: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.log-filter-btn {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.log-filter-btn:hover {
  background: var(--bg-hover);
}
.log-filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@media (max-width: 1024px) {
  .dashboard-grid { 
    grid-template-columns: 1fr; 
  }
  .db-stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .db-detail-grid {
    grid-template-columns: 1fr;
  }
  .db-outlook-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* MoeMail 在小屏幕上保持 2 列 */
  .db-detail-card:has(#ov-moemail-count) .db-outlook-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .input-grid-3 { 
    grid-template-columns: 1fr; 
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
  .btn-row {
    flex-direction: column;
  }
  .btn-row .btn {
    width: 100%;
    justify-content: center;
  }
}
