:root {
  --red: #c62828;
  --red-dark: #9f1f1f;
  --red-soft: #fdecec;
  --red-line: #f3c2c2;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #6b7280;
  --line: #e5e7eb;
  --green: #15803d;
  --shadow: 0 2px 10px rgba(31, 35, 41, 0.06);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
button, input, select { font: inherit; }

/* 登录 */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #fdecec 0%, #fff8f8 45%, #f6f7f9 100%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 14px; box-shadow: 0 12px 36px rgba(158, 30, 30, 0.12); padding: 34px; border-top: 5px solid var(--red); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand h1 { font-size: 20px; margin: 0 0 4px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.brand-mark { width: 48px; height: 48px; border-radius: 12px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 700; flex: none; }
.brand-mark.small { width: 36px; height: 36px; font-size: 18px; border-radius: 9px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 7px; color: #374151; font-weight: 600; font-size: 13px; }
.field input:not([type=checkbox]), .field select, .input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); outline: none; }
.field input:focus, .field select:focus, .input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.form-error { color: var(--red); background: var(--red-soft); border: 1px solid var(--red-line); padding: 9px 11px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.login-tip { color: #9ca3af; font-size: 12px; text-align: center; margin: 18px 0 0; line-height: 1.6; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand strong { display: block; font-size: 16px; }
.sidebar-brand small { color: var(--muted); font-size: 12px; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item { border: 0; background: transparent; text-align: left; padding: 11px 13px; border-radius: 8px; color: #4b5563; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.nav-item span { color: var(--red); font-size: 16px; width: 18px; text-align: center; }
.nav-item:hover { background: #f9fafb; }
.nav-item.active { background: var(--red-soft); color: var(--red); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 18px; color: #9ca3af; font-size: 11px; line-height: 1.7; border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h2 { margin: 0 0 4px; font-size: 22px; }
.topbar p { margin: 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 通用组件 */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 15px; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: #fff; color: #4b5563; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--red); color: var(--red); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-soft); }
.btn-mini { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.file-label { position: relative; overflow: hidden; display: inline-block; }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.banner { background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red); padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.panel-head h3 { margin: 0 0 4px; font-size: 16px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools .input { width: auto; min-width: 130px; }
.tools .input[type=search] { min-width: 200px; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .sub { color: #9ca3af; font-size: 11px; margin-top: 4px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #fafafa; text-align: left; padding: 11px 12px; color: #4b5563; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--line); }
.data-table th.check-col, .data-table td.check-col { width: 34px; padding-left: 14px; padding-right: 4px; }
.data-table input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--red); }
.check-all-label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.sel-count { display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 1.5; }
.data-table tr.selected td { background: var(--red-soft); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: var(--red-soft); color: var(--red); }
.data-table th.sorted { color: var(--red); background: var(--red-soft); }
.data-table th .sort-ind { display: inline-block; margin-left: 5px; font-size: 11px; color: #b6bcc5; font-weight: 400; }
.data-table th.sorted .sort-ind { color: var(--red); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f1f2f4; white-space: nowrap; }
.data-table tr:hover td { background: #fffafa; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .trade { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: #6b7280; font-size: 12px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; background: var(--red-soft); color: var(--red); }
.tag.gray { background: #f3f4f6; color: #6b7280; }
.tag.green { background: #ecfdf3; color: var(--green); }
.empty { padding: 40px; text-align: center; color: #9ca3af; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.page-size-wrap { display: inline-flex; align-items: center; gap: 5px; margin-right: auto; }
.page-size-select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 12px; cursor: pointer; }
.page-size-select:focus { outline: none; border-color: var(--red); }

/* 服务器卡片 */
.server-groups { padding: 18px 20px; }
.group-title { font-weight: 700; color: var(--red); margin: 6px 0 12px; font-size: 14px; }
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 22px; }
.server-card { border: 1px solid var(--line); border-radius: 10px; padding: 15px; background: #fff; }
.server-card.off { opacity: .7; }
.server-card h4 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.server-url { color: #6b7280; font-size: 12px; word-break: break-all; line-height: 1.6; min-height: 34px; }
.server-meta { color: #9ca3af; font-size: 11px; margin: 10px 0 12px; }
.server-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 弹窗 / 提示 */
.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .4); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { width: 100%; max-width: 480px; background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-card h3 { margin: 0 0 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.checkbox { display: flex; align-items: center; gap: 7px; padding-bottom: 10px; }
.checkbox span { font-weight: 600; font-size: 13px; color: #374151; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #1f2329; color: #fff; padding: 12px 18px; border-radius: 9px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 420px; }
.toast.error { background: var(--red); }
.about { padding: 22px; line-height: 1.8; }
.about h3 { margin: 22px 0 8px; font-size: 15px; }
.about h3:first-child { margin-top: 0; }
.about ol { margin: 0; padding-left: 20px; }
.about code { background: var(--red-soft); color: var(--red); padding: 1px 5px; border-radius: 4px; }
.about pre { background: #f8f9fa; border: 1px solid var(--line); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12px; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-brand { padding: 12px 16px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 40px; }
}
