/* ============================================================
   薯芯云 · 设计系统
   移动优先，断点：640 / 900 / 1200
   ============================================================ */

:root {
  --brand: #1B6EF3;
  --brand-d: #1259D4;
  --brand-l: #EAF2FF;
  --brand-l2: #F4F8FF;
  --orange: #F5941E;
  --orange-l: #FFF4E5;
  --green: #0F9D76;
  --green-l: #E7F8F1;
  --red: #E5484D;
  --red-l: #FEECEC;
  --purple: #7C3AED;

  --ink: #0F172A;
  --ink-2: #475569;
  --ink-3: #64748B;
  --muted: #8A98AC;
  --line: #E6EBF3;
  --line-2: #F0F3F8;
  --bg: #F4F7FB;
  --card: #FFFFFF;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D4DCE8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #BFCADB; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   布局骨架
   ============================================================ */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 216px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  flex: none;
  border-bottom: 1px solid var(--line-2);
}
.brand img { width: 26px; height: 26px; object-fit: contain; }
.brand b { font-size: 15px; letter-spacing: -.2px; }
.brand span { font-size: 10.5px; color: var(--muted); display: block; margin-top: -3px; letter-spacing: .3px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-t {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  padding: 12px 10px 6px; letter-spacing: .4px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .72; }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.on { background: var(--brand-l); color: var(--brand); font-weight: 600; }
.nav a.on svg { opacity: 1; }
.nav a .cnt {
  margin-left: auto; font-size: 10.5px; font-weight: 600;
  background: var(--red); color: #fff; border-radius: 20px;
  padding: 1px 6px; min-width: 18px; text-align: center;
}

.side-foot {
  flex: none; padding: 10px; border-top: 1px solid var(--line-2);
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: 216px;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  flex: none;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar h1 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-left: 2px; }
.topbar .grow { flex: 1; }

.content { padding: 20px 22px 40px; flex: 1; min-width: 0; }

.hamburger {
  display: none; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff;
  align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.hamburger svg { width: 18px; height: 18px; }

.mask {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  z-index: 55; backdrop-filter: blur(1px);
}
.mask.on { display: block; }

/* ============================================================
   通用组件
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
}
.card-h h3 { font-size: 14px; font-weight: 600; }
.card-h .grow { flex: 1; }
.card-b { padding: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: .16s; white-space: nowrap;
}
.btn:hover { border-color: #CBD7E6; color: var(--ink); background: #FBFCFE; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand-d); border-color: var(--brand-d); color: #fff; }
.btn.danger { color: var(--red); border-color: #F6C7C8; background: #fff; }
.btn.danger:hover { background: var(--red-l); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--ink-2); margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.6; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; outline: none; transition: .16s;
  font-size: 13.5px;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.65; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 110, 243, .1);
}
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238A98AC' stroke-width='1.5' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge.b { background: var(--brand-l); color: var(--brand); }
.badge.g { background: var(--green-l); color: var(--green); }
.badge.o { background: var(--orange-l); color: #B4690E; }
.badge.r { background: var(--red-l); color: var(--red); }
.badge.n { background: var(--line-2); color: var(--ink-3); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }
.dot.g { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 118, .14); }
.dot.o { background: var(--orange); box-shadow: 0 0 0 3px rgba(245, 148, 30, .14); }
.dot.n { background: #C3CCDA; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 54px 20px; color: var(--muted); text-align: center; gap: 10px;
}
.empty svg { width: 42px; height: 42px; opacity: .35; }
.empty p { font-size: 13px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted);
  font-size: 11.5px; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #FAFBFD;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFCFF; }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.switch {
  position: relative; width: 38px; height: 22px; flex: none;
  border-radius: 22px; background: #D8E0EB; cursor: pointer; transition: .2s;
  border: none; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(16px); }

/* 模态 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fadeIn .16s ease both;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2, .9, .3, 1.2) both;
}
.modal.wide { max-width: 680px; }
.modal-h {
  padding: 18px 20px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px; flex: none;
}
.modal-h h3 { font-size: 15px; font-weight: 600; flex: 1; }
.modal-b { padding: 20px; overflow-y: auto; flex: 1; }
.modal-f {
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  display: flex; gap: 9px; justify-content: flex-end; flex: none;
}
.x-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; flex: none;
}
.x-btn:hover { background: var(--line-2); color: var(--ink); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }

/* 提示 */
.toast-wrap {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: #1E293B; color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
  animation: toastIn .22s ease both;
}
.toast.ok { background: #0F9D76; }
.toast.err { background: #E5484D; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

/* 头部用户 */
.user-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: 30px; transition: .15s;
  position: relative;
}
.user-chip:hover { background: var(--line-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #4A93FF);
  color: #fff; font-size: 12.5px; font-weight: 600;
  display: grid; place-items: center; flex: none;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.user-chip .nm { font-size: 13px; font-weight: 500; line-height: 1.25; }
.user-chip .rl { font-size: 11px; color: var(--muted); line-height: 1.2; }

.menu {
  position: absolute; right: 0; top: 46px; min-width: 168px;
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow-lg); padding: 5px; z-index: 80;
  display: none;
}
.menu.on { display: block; animation: pop .16s ease both; }
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 11px; border: none; background: none; border-radius: 7px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--line-2); color: var(--ink); }
.menu button.danger { color: var(--red); }
.menu button.danger:hover { background: var(--red-l); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1199px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 0 14px; height: 58px; }
  .topbar h1 { font-size: 15px; }
  .content { padding: 14px 14px 34px; }
  .hide-sm { display: none !important; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .content { padding: 12px 12px calc(28px + var(--safe-b)); }
  .card-h { padding: 13px 14px; }
  .card-b { padding: 14px; }
  .modal { max-width: none; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .btn { height: 38px; }
  .input, .select { height: 40px; }
  .table th { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: #fff; border: 1px solid var(--line); border-radius: 11px;
    padding: 11px 12px; margin-bottom: 9px;
  }
  .table td {
    border: none; padding: 3px 0; display: flex; gap: 10px;
    align-items: center; justify-content: space-between; text-align: right;
  }
  .table td::before {
    content: attr(data-l); color: var(--muted); font-size: 12px;
    font-weight: 500; text-align: left; flex: none;
  }
  .table td.r { text-align: right; }
}

/* 工具类 */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.copy-ok { color: var(--green) !important; }
