:root {
  --bg-wallpaper: linear-gradient(135deg, #1a3a5c 0%, #0d2137 40%, #1e4976 100%);
  --taskbar: rgba(243, 243, 243, 0.85);
  --taskbar-dark: rgba(32, 32, 32, 0.92);
  --accent: #0067c0;
  --accent-hover: #005a9e;
  --window-bg: #fafafa;
  --titlebar: #f3f3f3;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666;
  --shadow: 0 8px 32px rgba(0,0,0,.25);
  --radius: 8px;
  --font: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

/* ── Login ── */
.login-page {
  background: var(--bg-wallpaper);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 1.4rem; font-weight: 600; }
.login-sub { color: var(--text-muted); font-size: .85rem; margin: 4px 0 24px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: .95rem;
}

.login-card button {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .95rem;
  cursor: pointer;
  font-weight: 500;
}

.login-card button:hover { background: var(--accent-hover); }
.login-error { color: #c42b1c; font-size: .85rem; margin-top: 10px; min-height: 1.2em; }

/* ── Desktop ── */
.desktop {
  height: 100vh;
  background: var(--bg-wallpaper);
  position: relative;
  user-select: none;
}

.desktop-icons {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1;
}

.desktop-icon {
  width: 80px;
  padding: 8px 4px;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  font-size: .72rem;
  line-height: 1.3;
}

.desktop-icon:hover { background: rgba(255,255,255,.15); }
.desktop-icon .icon { font-size: 2rem; display: block; margin-bottom: 4px; }

/* ── Windows ── */
.window-layer { position: absolute; inset: 0 0 48px 0; pointer-events: none; }
.window {
  position: absolute;
  background: var(--window-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 200px;
  pointer-events: all;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.08);
}

.window.maximized { inset: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }

.window-titlebar {
  display: flex;
  align-items: center;
  background: var(--titlebar);
  border-bottom: 1px solid var(--border);
  height: 36px;
  padding: 0 8px 0 12px;
  cursor: move;
  flex-shrink: 0;
}

.window-titlebar .title { flex: 1; font-size: .82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.window-controls { display: flex; gap: 2px; }
.window-controls button {
  width: 36px; height: 28px;
  border: none; background: transparent;
  border-radius: 4px; cursor: pointer;
  font-size: .75rem; color: var(--text);
}
.window-controls button:hover { background: rgba(0,0,0,.06); }
.window-controls .close:hover { background: #c42b1c; color: #fff; }

.window-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-size: .85rem;
}

/* ── Taskbar ── */
.taskbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background: var(--taskbar);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  padding: 0 8px;
  z-index: 9999;
  border-top: 1px solid rgba(0,0,0,.08);
}

.start-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  border-radius: 6px; font-size: 1.2rem;
  cursor: pointer;
}
.start-btn:hover, .start-btn.active { background: rgba(0,0,0,.06); }

.taskbar-apps { flex: 1; display: flex; gap: 4px; padding: 0 8px; overflow-x: auto; }

.taskbar-item {
  height: 40px; min-width: 44px; max-width: 160px;
  padding: 0 12px;
  border: none; background: transparent;
  border-radius: 6px; cursor: pointer;
  font-size: .78rem;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.taskbar-item:hover { background: rgba(0,0,0,.06); }
.taskbar-item.active { background: rgba(0,103,192,.12); border-bottom: 2px solid var(--accent); }

.taskbar-tray {
  display: flex; align-items: center; gap: 12px;
  font-size: .75rem; color: var(--text-muted);
  padding-right: 8px;
}

/* ── Start Menu ── */
.start-menu {
  position: fixed;
  bottom: 52px; left: 8px;
  width: 320px;
  background: rgba(243,243,243,.97);
  backdrop-filter: blur(20px);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 10000;
}

.start-menu.hidden { display: none; }
.start-menu-header { margin-bottom: 12px; }
.start-menu-header span { display: block; font-size: .75rem; color: var(--text-muted); }

.start-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.start-menu-item {
  padding: 12px 8px;
  border: none; background: transparent;
  border-radius: 8px; cursor: pointer;
  font-size: .72rem; text-align: center;
}
.start-menu-item:hover { background: rgba(0,0,0,.06); }
.start-menu-item .icon { font-size: 1.6rem; display: block; margin-bottom: 4px; }

.start-logout {
  width: 100%; padding: 8px;
  border: 1px solid var(--border);
  background: #fff; border-radius: 6px;
  cursor: pointer; font-size: .82rem;
}
.start-logout:hover { background: #f5f5f5; }

/* ── Shared app styles ── */
.toolbar {
  display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap;
}
.toolbar button, .btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: .8rem;
}
.toolbar button:hover, .btn:hover { background: #f0f0f0; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: #c42b1c; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
table.data-table th, table.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.data-table th { background: #f5f5f5; font-weight: 600; position: sticky; top: 0; }
table.data-table tr:hover td { background: #f9f9f9; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.stat-card .label { font-size: .72rem; color: var(--text-muted); }
.stat-card .value { font-size: 1.3rem; font-weight: 600; margin-top: 4px; }

.progress-bar {
  height: 8px; background: #e8e8e8; border-radius: 4px; overflow: hidden; margin-top: 6px;
}
.progress-bar .fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress-bar .fill.warn { background: #f59e0b; }
.progress-bar .fill.danger { background: #c42b1c; }

.path-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: #f5f5f5;
  border-radius: 4px; margin-bottom: 8px;
  font-size: .78rem; font-family: monospace;
}

.log-viewer {
  background: #1e1e1e; color: #d4d4d4;
  padding: 10px; border-radius: 6px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .72rem; white-space: pre-wrap;
  max-height: 300px; overflow: auto;
}

.empty-state { color: var(--text-muted); text-align: center; padding: 40px; }

.file-icon-dir::before { content: "📁 "; }
.file-icon-file::before { content: "📄 "; }

.editor-area {
  width: 100%; min-height: 280px;
  font-family: monospace; font-size: .78rem;
  border: 1px solid var(--border);
  border-radius: 4px; padding: 8px;
  resize: vertical;
}

.terminal-wrap { height: 100%; min-height: 300px; padding: 0 !important; }
.terminal-wrap .xterm { height: 100%; padding: 4px; }

.status-online { color: #107c10; font-weight: 600; }
.status-offline { color: #c42b1c; font-weight: 600; }

@media (max-width: 640px) {
  .desktop-icons { flex-direction: row; flex-wrap: wrap; top: 8px; left: 8px; right: 8px; }
  .window { min-width: 280px; }
  .start-menu { width: calc(100% - 16px); }
}
