/* =====================================================================
   奕升GEO 租户端样式（独立文件，禁止与运营后台 css/admin 互相引用）
   类名前缀 ys- ；红蓝企业风；全分辨率自适应（320 ~ 1920+）
   ===================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --ys-blue: #1D4ED8;
  --ys-blue-hover: #1E40AF;
  --ys-blue-light: #3B82F6;
  --ys-blue-active-text: #7FB2FC;
  --ys-red: #DC2626;
  --ys-red-deep: #991B1B;
  --ys-navy: #101E3C;
  --ys-navy-2: #182C52;
  --ys-bg: #EEF2F7;
  --ys-panel: #F4F6FB;
  --ys-card: #FFFFFF;
  --ys-text: #111827;
  --ys-text-2: #3B4358;
  --ys-text-3: #6B7490;
  --ys-line: #E3E8F0;
  --ys-green: #16A34A;
  --ys-amber: #D97706;
  --ys-radius: 12px;
  --ys-shadow: 0 2px 10px rgba(16, 30, 60, .06);
  --ys-sidebar-w: 232px;
  --ys-topbar-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--ys-bg);
  color: var(--ys-text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ys-blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }
img { max-width: 100%; display: block; }

/* ---------- 应用骨架 ---------- */
.ys-shell { display: flex; min-height: 100vh; }

.ys-sidebar {
  width: var(--ys-sidebar-w);
  background: linear-gradient(180deg, var(--ys-navy) 0%, var(--ys-navy-2) 100%);
  color: #C7D2E8;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 60;
  transition: transform .25s ease;
}
.ys-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; height: var(--ys-topbar-h); }
.ys-brand-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--ys-blue-light), var(--ys-blue));
  color: #fff; font-weight: 800; font-size: 19px;
  display: grid; place-items: center;
}
.ys-brand-name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.2; white-space: nowrap; }
.ys-brand-sub { font-size: 11px; color: #8FA3C6; white-space: nowrap; }

.ys-nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.ys-nav-group { font-size: 11px; color: #6E80A6; padding: 14px 10px 6px; letter-spacing: 1px; }
.ys-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0; border-radius: 9px;
  color: #C7D2E8; font-size: 14px; white-space: nowrap;
}
.ys-nav a .ys-ico { width: 18px; text-align: center; flex: none; }
.ys-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.ys-nav a.active { background: var(--ys-blue); color: #fff; font-weight: 600; }
.ys-nav-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #8FA3C6; }

.ys-main { flex: 1; margin-left: var(--ys-sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.ys-topbar {
  height: var(--ys-topbar-h); background: #fff; border-bottom: 1px solid var(--ys-line);
  display: flex; align-items: center; gap: 12px; padding: 0 clamp(12px, 2vw, 24px);
  position: sticky; top: 0; z-index: 50;
}
.ys-hamburger { display: none; font-size: 22px; color: var(--ys-text-2); padding: 4px 8px; }
.ys-page-title { font-size: 16px; font-weight: 700; white-space: nowrap; }
.ys-topbar-spacer { flex: 1; }
.ys-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--ys-panel); border: 1px solid var(--ys-line); border-radius: 8px;
  padding: 7px 12px; width: min(320px, 38vw); color: var(--ys-text-3);
}
.ys-search input { border: none; background: none; outline: none; width: 100%; color: var(--ys-text); }
.ys-content { padding: clamp(12px, 2vw, 24px); flex: 1; }

.ys-mask { display: none; position: fixed; inset: 0; background: rgba(10,18,38,.45); z-index: 55; }
.ys-mask.show { display: block; }

/* ---------- 通用组件 ---------- */
.ys-card {
  background: var(--ys-card); border: 1px solid var(--ys-line);
  border-radius: var(--ys-radius); box-shadow: var(--ys-shadow);
  padding: clamp(14px, 1.6vw, 20px); min-width: 0;
}
.ys-card-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.ys-card-title { font-size: 15px; font-weight: 700; }
.ys-card-hd .ys-spacer { flex: 1; }

.ys-grid { display: grid; gap: clamp(10px, 1.2vw, 16px); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ys-grid-2 { display: grid; gap: clamp(10px, 1.2vw, 16px); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.ys-kpi .ys-kpi-label { color: var(--ys-text-3); font-size: 13px; }
.ys-kpi .ys-kpi-value { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; margin: 4px 0; }
.ys-kpi .ys-kpi-sub { font-size: 12px; color: var(--ys-text-3); }
.ys-delta { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.ys-delta.up { color: var(--ys-green); background: rgba(22,163,74,.1); }
.ys-delta.down { color: var(--ys-red); background: rgba(220,38,38,.1); }

.ys-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  background: var(--ys-panel); color: var(--ys-text-2); border: 1px solid var(--ys-line);
  transition: background .15s, color .15s; white-space: nowrap;
}
.ys-btn:hover { background: #e8edf6; }
.ys-btn-primary { background: var(--ys-blue); color: #fff; border-color: var(--ys-blue); }
.ys-btn-primary:hover { background: var(--ys-blue-hover); }
.ys-btn-danger { background: var(--ys-red); color: #fff; border-color: var(--ys-red); }
.ys-btn-danger:hover { background: var(--ys-red-deep); }
.ys-btn-ghost { background: transparent; }
.ys-btn-sm { padding: 6px 12px; font-size: 13px; }
.ys-btn[disabled] { opacity: .55; cursor: not-allowed; }

.ys-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.ys-badge-blue { background: rgba(29,78,216,.1); color: var(--ys-blue); }
.ys-badge-green { background: rgba(22,163,74,.12); color: var(--ys-green); }
.ys-badge-red { background: rgba(220,38,38,.1); color: var(--ys-red); }
.ys-badge-gray { background: #eef1f6; color: var(--ys-text-3); }
.ys-badge-amber { background: rgba(217,119,6,.12); color: var(--ys-amber); }

/* 表格：外层包裹，窄屏仅表格内部横滑，页面本身不超宽 */
.ys-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table.ys-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.ys-table th, .ys-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--ys-line); white-space: nowrap; }
.ys-table th { color: var(--ys-text-3); font-weight: 600; font-size: 13px; background: var(--ys-panel); }
.ys-table td.wrap, .ys-table th.wrap { white-space: normal; min-width: 160px; }
.ys-table tbody tr:hover { background: #f8fafd; }

.ys-form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 14px; }
.ys-field label { display: block; font-size: 13px; color: var(--ys-text-2); margin-bottom: 6px; font-weight: 600; }
.ys-field input, .ys-field select, .ys-field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--ys-line); border-radius: 8px;
  outline: none; background: #fff; color: var(--ys-text);
}
.ys-field input:focus, .ys-field select:focus, .ys-field textarea:focus { border-color: var(--ys-blue-light); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

/* ---------- 自定义弹窗（禁用原生 alert/confirm/prompt） ---------- */
.ys-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(10,18,38,.5); align-items: center; justify-content: center; padding: 16px;
}
.ys-modal-overlay.show { display: flex; }
.ys-modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(10,18,38,.3);
  animation: ys-pop .18s ease; max-height: 90vh; display: flex; flex-direction: column;
}
@keyframes ys-pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.ys-modal-hd { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.ys-modal-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; flex: none; }
.ys-modal-icon.info { background: rgba(29,78,216,.12); color: var(--ys-blue); }
.ys-modal-icon.danger { background: rgba(220,38,38,.12); color: var(--ys-red); }
.ys-modal-icon.warn { background: rgba(217,119,6,.12); color: var(--ys-amber); }
.ys-modal-title { font-size: 16px; font-weight: 700; }
.ys-modal-bd { padding: 12px 20px 18px; color: var(--ys-text-2); overflow-y: auto; word-break: break-word; }
.ys-modal-ft { display: flex; gap: 10px; padding: 0 20px 20px; justify-content: flex-end; }
.ys-modal-ft .ys-btn { min-width: 84px; }
.ys-modal-input { width: 100%; padding: 10px 12px; border: 1px solid var(--ys-line); border-radius: 8px; outline: none; margin-top: 4px; }
.ys-modal-input:focus { border-color: var(--ys-blue-light); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

/* Toast */
.ys-toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.ys-toast {
  background: var(--ys-navy); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(10,18,38,.25);
  animation: ys-toast-in .2s ease; display: flex; align-items: center; gap: 8px;
}
.ys-toast.success { background: var(--ys-green); }
.ys-toast.error { background: var(--ys-red); }
@keyframes ys-toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Loading 遮罩 */
.ys-loading-overlay { display: none; position: fixed; inset: 0; z-index: 150; background: rgba(255,255,255,.55); align-items: center; justify-content: center; }
.ys-loading-overlay.show { display: flex; }
.ys-spinner { width: 38px; height: 38px; border: 3px solid rgba(29,78,216,.2); border-top-color: var(--ys-blue); border-radius: 50%; animation: ys-spin .8s linear infinite; }
@keyframes ys-spin { to { transform: rotate(360deg); } }

/* 简单条形图（纯 CSS，正式版接 ECharts） */
.ys-bar-row { display: grid; grid-template-columns: 92px 1fr 48px; align-items: center; gap: 10px; margin: 10px 0; font-size: 13px; }
.ys-bar-track { height: 9px; background: #edf1f7; border-radius: 6px; overflow: hidden; }
.ys-bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--ys-blue-light), var(--ys-blue)); }
.ys-bar-val { text-align: right; font-weight: 600; color: var(--ys-text-2); }

.section-title { font-size: clamp(16px, 2vw, 20px); font-weight: 800; margin: 4px 2px 14px; }
.mt-16 { margin-top: 16px; }

/* ---------- 响应式 ---------- */
@media (max-width: 992px) {
  .ys-sidebar { transform: translateX(-100%); }
  .ys-sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(10,18,38,.3); }
  .ys-main { margin-left: 0; }
  .ys-hamburger { display: inline-flex; }
  .ys-search { width: auto; flex: 1; }
}
@media (max-width: 576px) {
  body { font-size: 13px; }
  .ys-topbar { padding: 0 12px; gap: 8px; }
  .ys-page-title { font-size: 15px; }
  .ys-search { display: none; }
  .ys-modal { max-width: 100%; border-radius: 12px; }
  .ys-modal-ft { flex-direction: column-reverse; }
  .ys-modal-ft .ys-btn { width: 100%; }
  .ys-bar-row { grid-template-columns: 76px 1fr 42px; }
  .ys-card-hd .ys-btn { width: 100%; }
}
@media (max-width: 380px) {
  .ys-grid, .ys-grid-2, .ys-form-row { grid-template-columns: 1fr; }
}
