:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --sidebar: #ffffff;
  --sidebar-hover: #f3f4f6;
  --header: #ffffff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

button, input { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* login */
.login-page { min-height: 100vh; display: flex; }
.login-left { flex: 1; background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 64px; position: relative; overflow: hidden; }
.login-left::before { content: ''; position: absolute; top: -50%; right: -20%; width: 600px; height: 600px; background: rgba(255,255,255,0.08); border-radius: 50%; }
.login-left .brand { display: flex; align-items: center; gap: 16px; margin-bottom: 40px; z-index: 1; }
.login-left .brand img { width: 64px; height: 64px; border-radius: 50%; background: #fff; padding: 4px; }
.login-left h1 { font-size: 32px; margin: 0 0 16px; }
.login-left p { font-size: 16px; opacity: 0.9; line-height: 1.6; max-width: 420px; }
.login-left .features { margin-top: 48px; display: flex; flex-direction: column; gap: 16px; z-index: 1; }
.login-left .feature { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.login-left .feature .dot { width: 8px; height: 8px; border-radius: 50%; background: #93c5fd; }

.login-right { width: 480px; background: var(--card); display: flex; flex-direction: column; justify-content: center; padding: 48px; box-shadow: -4px 0 24px rgba(0,0,0,0.04); }
.login-box { width: 100%; max-width: 360px; margin: 0 auto; }
.login-logo { display: none; }
.login-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.login-tab { flex: 1; padding: 12px; text-align: center; cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; font-weight: 500; }
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-form { display: none; }
.login-form.active { display: block; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); outline: none; transition: border .2s; font-size: 14px; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.field-row { display: flex; gap: 12px; }
.field-row input { flex: 1; }
.captcha-img { height: 40px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: #fff; }
.btn { width: 100%; padding: 12px; border: none; border-radius: var(--radius); background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); margin-top: 12px; }
.btn-outline:hover { background: var(--primary-light); }
.agreement { margin-top: 24px; text-align: center; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.error { color: var(--danger); font-size: 12px; margin-top: 6px; }

/* layout */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 240px; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .2s; }
.sidebar.collapsed { width: 64px; }
.sidebar-header { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.sidebar-header img { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.sidebar-header .title { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .title { display: none; }
.menu { flex: 1; overflow-y: auto; padding: 8px 0; }
.menu-item { cursor: pointer; }
.menu-item-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; color: var(--text); transition: background .2s; user-select: none; }
.menu-item-header:hover { background: var(--sidebar-hover); }
.menu-item.active > .menu-item-header { color: var(--primary); background: var(--primary-light); }
.menu-item-left { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.menu-icon { width: 18px; height: 18px; flex-shrink: 0; }
.menu-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .menu-text, .sidebar.collapsed .menu-arrow { display: none; }
.menu-arrow { width: 12px; height: 12px; transition: transform .2s; opacity: .6; }
.menu-arrow.open { transform: rotate(90deg); }
.submenu { display: none; padding-left: 20px; }
.submenu.open { display: block; }
.submenu .menu-item-header { padding: 9px 16px; font-size: 13px; color: var(--text-secondary); }
.submenu .menu-item.active .menu-item-header { color: var(--primary); background: var(--primary-light); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; }
.sidebar.collapsed .sidebar-footer { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header { height: 64px; background: var(--header); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.header-left { display: flex; align-items: center; gap: 16px; }
.toggle-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.breadcrumb { color: var(--text-secondary); font-size: 14px; }
.breadcrumb span:not(:last-child)::after { content: ' / '; margin: 0 6px; color: var(--border); }
.header-right { display: flex; align-items: center; gap: 16px; }
.user { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-dropdown { position: absolute; top: 44px; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 120px; display: none; z-index: 100; }
.user.open .user-dropdown { display: block; }
.user-dropdown div { padding: 10px 16px; cursor: pointer; }
.user-dropdown div:hover { background: var(--sidebar-hover); }

.content { flex: 1; overflow-y: auto; padding: 24px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #ecfdf5; color: var(--success); }
.stat-icon.orange { background: #fff7ed; color: var(--warning); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-value { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.stat-label { color: var(--text-secondary); font-size: 13px; }

.section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.chart { height: 260px; display: flex; align-items: flex-end; gap: 8px; padding-top: 20px; border-bottom: 1px solid var(--border); }
.chart-bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; transition: opacity .2s; position: relative; min-height: 8px; }
.chart-bar:hover { opacity: 1; }
.chart-bar::after { content: attr(data-label); position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

/* placeholder */
.placeholder { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 60px 20px; text-align: center; }
.placeholder-icon { width: 64px; height: 64px; margin: 0 auto 16px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.placeholder h3 { margin: 0 0 8px; font-size: 18px; }
.placeholder p { color: var(--text-secondary); margin: 0; }
.submodule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.submodule-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all .2s; }
.submodule-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.submodule-card h4 { margin: 0 0 6px; font-size: 15px; }
.submodule-card p { margin: 0; color: var(--text-secondary); font-size: 13px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 420px; max-width: 90%; padding: 24px; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.modal-actions .btn { width: auto; padding: 8px 16px; }

/* agreement pages */
.article { max-width: 800px; margin: 0 auto; background: var(--card); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); line-height: 1.8; }
.article h2 { margin-top: 0; }

@media (max-width: 900px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
  .login-logo img { width: 48px; height: 48px; border-radius: 50%; }
  .login-logo span { font-size: 18px; font-weight: 700; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
