/* ========== 全局变量与基础 ========== */
:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --border: #e4e7ed;
  --text: #303133;
  --text-muted: #909399;
  --primary: #409eff;
  --primary-hover: #66b1ff;
  --primary-dark: #337ecc;
  --danger: #f56c6c;
  --success: #67c23a;
  --warning: #e6a23c;
  --sidebar-bg: #001529;
  --sidebar-bg-hover: #1890ff;
  --sidebar-text: rgba(255, 255, 255, 0.75);
  --sidebar-text-active: #ffffff;
  --sidebar-sub-bg: #000c17;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --sidebar-width: 230px;
  --sidebar-width-collapsed: 64px;
  --topbar-height: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ========== 按钮 ========== */
.btn {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #f78989; color: #fff; border-color: #f78989; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ========== 框架布局 ========== */
.frame-body { margin: 0; padding: 0; }

.frame-layout {
  display: flex;
  min-height: 100vh;
}

/* ========== 左侧菜单 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: width .25s ease;
  position: relative;
  flex-shrink: 0;
}

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

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  overflow: hidden;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #36cfc9);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-title {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-title h2 {
  margin: 0;
  font-size: 15px;
  color: #fff;
  font-weight: 600;
}

.sidebar-title p {
  margin: 2px 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

.sidebar.collapsed .sidebar-title {
  display: none;
}

/* 菜单容器 */
.sidebar-menu {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

/* 一级菜单项 */
.menu-item {
  user-select: none;
}

.menu-title {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--sidebar-text);
  transition: all .2s;
  font-size: 14px;
  white-space: nowrap;
}

.menu-title:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

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

.menu-title .menu-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-title .menu-arrow {
  font-size: 10px;
  transition: transform .25s;
  flex-shrink: 0;
}

.menu-item.open > .menu-title .menu-arrow {
  transform: rotate(90deg);
}

/* 折叠状态下隐藏文本和箭头 */
.sidebar.collapsed .menu-title .menu-text,
.sidebar.collapsed .menu-title .menu-arrow {
  display: none;
}

/* 二级菜单 */
.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
  background: var(--sidebar-sub-bg);
}

.menu-item.open > .submenu {
  max-height: 500px;
}

.submenu .submenu-item {
  padding: 10px 20px 10px 52px;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all .2s;
  white-space: nowrap;
}

.submenu .submenu-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.submenu .submenu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.submenu .submenu-item:hover::before {
  background: var(--primary);
}

.submenu .submenu-item.active {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

.submenu .submenu-item.active::before {
  background: #fff;
}

/* 折叠状态下 - 二级菜单变成 hover 弹出 */
.sidebar.collapsed .submenu {
  display: none;
}

.sidebar.collapsed .menu-title {
  justify-content: center;
  padding: 12px;
}

/* 底部版本号 */
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.sidebar.collapsed .sidebar-footer .version {
  font-size: 10px;
}

/* ========== 右侧主区域 ========== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 顶部栏 */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.menu-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background .2s;
}

.menu-toggle:hover {
  background: #f5f7fa;
}

.menu-toggle span {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all .2s;
}

.breadcrumb {
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.breadcrumb .sep {
  color: var(--border);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

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

.logout-btn {
  padding: 6px 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}

.logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* 内容区 */
.content-wrap {
  flex: 1;
  background: var(--bg);
  overflow: hidden;
}

.content-frame {
  width: 100%;
  height: calc(100vh - var(--topbar-height));
  border: none;
  display: block;
}

/* ========== 登录页面 ========== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), #36cfc9);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 8px 20px rgba(64, 158, 255, 0.4);
}

.login-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.login-sub {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.login-form .form-group {
  margin-bottom: 16px;
  position: relative;
}

.login-form label {
  display: block;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  outline: none;
  transition: all .3s;
}

.login-form input[type="text"]::placeholder,
.login-form input[type="password"]::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  border-color: rgba(64, 158, 255, 0.8);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.25);
}

.pwd-toggle {
  position: absolute;
  right: 10px;
  top: 36px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  opacity: .6;
  transition: opacity .2s;
  filter: grayscale(1) brightness(1.5);
}

.pwd-toggle:hover { opacity: 1; }

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
}

.checkbox input { cursor: pointer; accent-color: var(--primary); }

.link { color: #69b1ff; font-size: 13px; text-decoration: none; transition: color 0.3s; }
.link:hover { color: #40a9ff; text-decoration: underline; }

.login-msg {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

.login-msg.error {
  display: block;
  background: rgba(254, 240, 240, 0.9);
  color: #ff7875;
  border: 1px solid rgba(251, 196, 196, 0.5);
}

.login-msg.success {
  display: block;
  background: rgba(240, 249, 235, 0.9);
  color: #95de64;
  border: 1px solid rgba(194, 231, 176, 0.5);
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--primary), #36cfc9);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(64, 158, 255, 0.4);
}

.btn-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(64, 158, 255, 0.5);
}

.btn-block:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.login-footer code {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  color: #69b1ff;
  font-family: Consolas, Monaco, monospace;
}

.copyright {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  margin-top: 20px;
}

/* ========== 子页面通用样式（iframe 内部使用） ========== */
.page-content {
  padding: 20px 24px;
  min-height: 100%;
  background: var(--bg);
}

.page-header {
  background: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.page-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.page-header .page-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.page-body {
  background: #fff;
  padding: 20px 24px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
}

.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.danger { color: var(--danger); }

.panel {
  background: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar input[type="text"],
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color .2s;
}

.toolbar input[type="text"]:focus,
.toolbar select:focus {
  border-color: var(--primary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: #fafafa;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.data-table tbody tr:hover { background: #f5f7fa; }
.price { color: var(--success); font-weight: 600; }

.pager {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  font-size: 13px;
  color: var(--text-muted);
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.item-list li:last-child { border-bottom: none; }
.item-list .empty { text-align: center; color: var(--text-muted); padding: 30px 16px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.info-item {
  padding: 12px;
  background: #fafafa;
  border-radius: 6px;
}

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

.info-item .value {
  font-size: 14px;
  font-weight: 500;
}

pre {
  background: #1e1e2e;
  color: #e2e8f0;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 12.5px;
  overflow-x: auto;
  line-height: 1.7;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 10px;
  background: #ecf5ff;
  color: var(--primary);
}

.tag.success { background: #f0f9eb; color: var(--success); }
.tag.warning { background: #fdf6ec; color: var(--warning); }
.tag.danger { background: #fef0f0; color: var(--danger); }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-width-collapsed); }
  .sidebar:not(.collapsed) { width: var(--sidebar-width); }
  .sidebar-title { display: none; }
  .sidebar .menu-title .menu-text,
  .sidebar .menu-title .menu-arrow { display: none; }
  .sidebar .menu-title { justify-content: center; padding: 12px; }
  .submenu { display: none; }
  .welcome { display: none; }
  .page-content { padding: 12px; }
  .login-card { padding: 32px 24px 24px; }
}
