/* ============================================================
   妙妙屋 X 管理面板 —— 暖白纸质 / 新粗野主义设计系统
   页面底 #FAF6F0 · 白卡片 · 橙棕描边 · 右下硬阴影 · 陶土橙 #D96B3F
   ============================================================ */
:root {
  --bg: #FAF6F0;
  --card: #FFFFFF;
  --card-inner: #FAF3EA;
  --border: #E5C9B8;
  --border-strong: #D8BCA6;
  --shadow-color: #E8D9CC;
  --shadow: 3px 3px 0 var(--shadow-color);
  --shadow-sm: 2px 2px 0 var(--shadow-color);
  --primary: #D96B3F;
  --primary-deep: #C05530;
  --primary-light: #F8DCC8;
  --primary-bg: #FDEBDD;
  --text: #2B2622;
  --text-sub: #9C8E80;
  --green: #2FA36B;
  --green-bg: #DCF5E3;
  --green-border: #9ED9B6;
  --red: #E5484D;
  --red-bg: #FDE3E4;
  --red-border: #F2A9AC;
  --yellow: #C58A20;
  --yellow-bg: #FBF0DC;
  --yellow-border: #EBD3A0;
  --blue: #2563EB;
  --blue-bg: #E2ECFD;
  --blue-border: #B3CDF6;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #211C18;
  --card: #2C2620;
  --card-inner: #241F1A;
  --border: #4A4036;
  --border-strong: #5A4E42;
  --shadow-color: #14100D;
  --shadow: 3px 3px 0 var(--shadow-color);
  --shadow-sm: 2px 2px 0 var(--shadow-color);
  --primary-bg: #3D2A1F;
  --primary-light: #4A3223;
  --text: #EDE5DC;
  --text-sub: #A2948A;
  --green-bg: #1E3A2B;
  --red-bg: #40201F;
  --yellow-bg: #3B3117;
  --blue-bg: #1D2B44;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
[data-theme="dark"] body { color-scheme: dark; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary-light);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
  overflow: hidden;
}
.brand .logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.brand .name { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.brand .name .x { color: var(--primary); font-style: italic; font-size: 22px; }

.nav { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .05s;
}
.nav-btn:hover { background: var(--primary-bg); }
.nav-btn.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-deep);
}
[data-theme="dark"] .nav-btn.active { color: #F4A87E; }
.nav-btn:active { transform: translate(2px, 2px); box-shadow: none; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.admin-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 4px 12px 4px 5px;
}
.admin-badge .avatar {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  overflow: hidden;
}
.admin-badge .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-badge .who { font-size: 12px; font-weight: 700; line-height: 1.15; }
.admin-badge .who small { display: block; font-size: 10px; color: var(--primary); font-weight: 800; letter-spacing: 1px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 150px;
  background: var(--card); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; display: none; z-index: 60;
}
.menu.open { display: block; }
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
  background: none; border: none; border-radius: 6px; color: var(--text);
}
.menu button:hover { background: var(--primary-bg); }
.menu button.danger { color: var(--red); }

/* ---------- 布局 ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { font-size: 20px; font-weight: 800; }
.page-sub { font-size: 12.5px; color: var(--text-sub); }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .nav { order: 3; width: 100%; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; margin-bottom: 12px; }
.card-title .sub { font-weight: 500; font-size: 12px; color: var(--text-sub); }

.stat-label { font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 27px; font-weight: 800; margin-top: 6px; letter-spacing: -.3px; }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--primary); }
.stat-value .unit { font-size: 14px; font-weight: 600; color: var(--text-sub); margin-left: 2px; }
.stat-note { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

.duo { display: flex; gap: 26px; flex-wrap: wrap; }
.duo .item { min-width: 130px; }
.duo .k { font-size: 12px; color: var(--text-sub); }
.duo .v { font-size: 16px; font-weight: 800; margin-top: 2px; }
.duo .v.up { color: var(--primary); }
.duo .v.down { color: var(--green); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 700; line-height: 1;
  padding: 4px 8px; border-radius: 6px; border: 1px solid;
  white-space: nowrap;
}
.tag-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.tag-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.tag-yellow { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); }
.tag-blue { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue); }
.tag-orange { background: var(--primary-bg); border-color: var(--primary-light); color: var(--primary-deep); }
[data-theme="dark"] .tag-orange { color: #F4A87E; }
.tag-gray { background: var(--card-inner); border-color: var(--border); color: var(--text-sub); }
.tag-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-weight: 700;
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .05s;
}
.btn:hover { background: var(--primary-bg); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary-deep); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-soft { background: var(--primary-light); border-color: var(--primary); color: var(--primary-deep); }
[data-theme="dark"] .btn-soft { color: #F4A87E; }
.btn-danger { background: none; border-color: var(--red-border); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 4px 9px; font-size: 12px; box-shadow: 1.5px 1.5px 0 var(--shadow-color); }
.btn-link { border: none; box-shadow: none; background: none; color: var(--primary); padding: 4px 6px; }
.btn-link:hover { background: var(--primary-bg); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-sub);
  padding: 8px 10px; border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--card-inner); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-sub); }
.nowrap { white-space: nowrap; }

.mini-bar { height: 6px; background: var(--card-inner); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; margin-top: 4px; min-width: 90px; }
.mini-bar > i { display: block; height: 100%; background: var(--primary); }
.mini-bar > i.warn { background: var(--yellow); }
.mini-bar > i.danger { background: var(--red); }

/* ---------- 分段选择器 ---------- */
.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  padding: 6px 14px; font-size: 12.5px; font-weight: 700;
  background: var(--card); border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text-sub); box-shadow: var(--shadow-sm);
}
.seg button.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-deep); }
[data-theme="dark"] .seg button.active { color: #F4A87E; }

/* ---------- 图表 ---------- */
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-sub); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- 排行（节点/用户视图） ---------- */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-row .name { width: 150px; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.rank-row .track { flex: 1; height: 12px; background: var(--card-inner); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.rank-row .track > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #E8965B); }
.rank-row .val { font-size: 12px; color: var(--text-sub); white-space: nowrap; font-family: var(--mono); }

/* ---------- 服务器卡片（服务管理） ---------- */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.server-grid > .card { min-width: 0; }
.srv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.srv-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); flex-shrink: 0; }
.srv-head .dot.off { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.srv-head .name { font-size: 15px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-ip { font-family: var(--mono); font-size: 12.5px; color: var(--text-sub); margin: 6px 0; }
.srv-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.srv-tags .tag-yellow { white-space: normal; line-height: 1.25; overflow-wrap: anywhere; max-width: 100%; min-width: 0; }
.srv-speed {
  background: var(--card-inner); border: 1px solid var(--border);
  border-radius: 7px; padding: 10px 12px; margin: 10px 0;
  display: flex; gap: 22px;
}
.srv-speed .k { font-size: 11px; color: var(--text-sub); }
.srv-speed .v { font-size: 15px; font-weight: 800; font-family: var(--mono); margin-top: 2px; }
.srv-speed .v.up { color: var(--primary); }
.srv-speed .v.down { color: var(--green); }
.rainbow { height: 7px; border-radius: 4px; margin: 10px 0; border: 1px solid var(--border);
  background: linear-gradient(90deg, #E5484D, #E8A13C, #D9C94A, #3FA46B, #3F8DE8, #8E5AE8); }
.srv-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.srv-foot .time { font-size: 11.5px; color: var(--text-sub); }
.srv-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.form-item { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.form-item label { font-size: 12px; font-weight: 700; color: var(--text-sub); }
.form-item input, .form-item select, .form-item textarea {
  padding: 8px 10px; font-size: 13px;
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border-strong);
  border-radius: 7px; outline: none;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 20, 12, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; overflow-y: auto;
}
.modal {
  background: var(--card); border: 1.5px solid var(--border-strong);
  border-radius: 12px; box-shadow: 6px 6px 0 rgba(30,20,12,.18);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 20px 22px;
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--text-sub); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- 订阅链接框 ---------- */
.subrow {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-top: 10px; background: var(--card-inner); flex-wrap: wrap;
}
.subrow .fmt { font-size: 12px; font-weight: 800; color: var(--primary-deep); width: 88px; flex-shrink: 0; }
[data-theme="dark"] .subrow .fmt { color: #F4A87E; }
.subrow .url { flex: 1; font-family: var(--mono); font-size: 12px; word-break: break-all; min-width: 200px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 380px; padding: 30px 30px 26px; }
.login-card .brand { justify-content: center; margin-bottom: 18px; }
.login-card .brand .name { font-size: 24px; }
.login-hint { margin-top: 14px; font-size: 12px; color: var(--text-sub); text-align: center; line-height: 1.7; }
.login-hint code { font-family: var(--mono); background: var(--card-inner); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.btn-block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1.5px solid var(--border-strong);
  border-left-width: 5px; border-radius: 8px; box-shadow: var(--shadow);
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  animation: slidein .18s ease-out; max-width: 340px;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 杂项 ---------- */
.empty { text-align: center; color: var(--text-sub); font-size: 13px; padding: 30px 0; }
.copy-chip { font-family: var(--mono); font-size: 12px; background: var(--card-inner); border: 1px solid var(--border); padding: 2px 7px; border-radius: 5px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--text-sub); }
.kv .v { font-weight: 600; word-break: break-all; }
.json-box {
  background: var(--card-inner); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 12px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow-y: auto;
}
.sub-preview { max-height: 460px; padding: 8px; }
.sub-preview-line { display: flex; align-items: flex-start; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--border); }
.sub-preview-line:last-child { border-bottom: none; }
.sub-preview-line span { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.55; }
.sub-preview-line .btn { flex-shrink: 0; }
