/* ============================================================
   炫酷个人面板 · 全局样式（外壳 + 通用组件）
   设计语言：miuix / HyperOS（token 取自 miuix 源码）
   ============================================================ */

* { box-sizing: border-box; }

/* ---------------- 设计令牌 · 浅色（默认） ---------------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F7F7F7;
  --bg-grad-1: rgba(52, 130, 255, .05);
  --bg-grad-2: rgba(52, 130, 255, .03);
  --panel: #FFFFFF;
  --panel-solid: #FFFFFF;
  --panel-2: #F0F0F0;
  --btn-bg: #F0F0F0;
  --btn-bg-hover: #E8E8E8;
  --btn-bg-press: #DEDEDE;
  --input-bg: #F0F0F0;
  --tertiary: #EAF2FF;
  --on-tertiary: #3482FF;
  --line: #E4E4E4;
  --divider: #E0E0E0;
  --outline: #D9D9D9;
  --text: #1A1A1A;
  --muted: #6E7488;
  --hint: #8C93B0;
  --overlay: rgba(0, 0, 0, .38);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .04);
  --hover: rgba(0, 0, 0, .05);
  --press: rgba(0, 0, 0, .10);
  --ok: #0E9F57;
  --warn: #D17E00;
  --danger: #E94634;
  --side-bg: #FFFFFF;
  --radius: 16px;
  --brand1: #3482FF;
  --brand2: #5D9BFF;
  --ease-out: cubic-bezier(.05, .7, .1, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .15s;
  --t-base: .2s;
  --t-slow: .3s;
}

/* ---------------- 设计令牌 · 深色 ---------------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171717;
  --bg-grad-1: rgba(52, 130, 255, .07);
  --bg-grad-2: rgba(255, 255, 255, .02);
  --panel: #242424;
  --panel-solid: #242424;
  --panel-2: #2F2F2F;
  --btn-bg: #3A3A3A;
  --btn-bg-hover: #434343;
  --btn-bg-press: #4D4D4D;
  --input-bg: #363636;
  --tertiary: #2B3B54;
  --on-tertiary: #4788FF;
  --line: #3F3F3F;
  --divider: #383838;
  --outline: #3F3F3F;
  --text: #F2F2F2;
  --muted: #8A90A6;
  --hint: #787E96;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: none;
  --hover: rgba(255, 255, 255, .06);
  --press: rgba(255, 255, 255, .10);
  --ok: #35D07F;
  --warn: #FFB020;
  --danger: #F12522;
  --side-bg: #171717;
  --brand1: #277AF7;
  --brand2: #5D9BFF;
}

/* ---------------- 强调色（HyperOS 色系，浅/深各一对） ---------------- */
[data-accent="aurora"]  { --brand1: #3482FF; --brand2: #5D9BFF; }
[data-accent="sunset"]  { --brand1: #F26E00; --brand2: #FFA047; }
[data-accent="emerald"] { --brand1: #0BA360; --brand2: #3ECD8B; }
[data-accent="violet"]  { --brand1: #7B61FF; --brand2: #A78BFA; }

[data-accent="aurora"][data-theme="dark"]  { --brand1: #277AF7; --brand2: #5D9BFF; }
[data-accent="sunset"][data-theme="dark"]  { --brand1: #FF7A1A; --brand2: #FFAB5E; }
[data-accent="emerald"][data-theme="dark"] { --brand1: #00B86B; --brand2: #40D391; }
[data-accent="violet"][data-theme="dark"]  { --brand1: #9075FF; --brand2: #B49BFF; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "MiSans", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 8% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(120, 120, 130, .35); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 布局外壳 ---------------- */
.app {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: var(--side-bg);
  border-right: 1px solid var(--divider);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
}
.brand-logo svg { display: block; }
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.brand-text p { margin: 3px 0 0; font-size: 11px; color: var(--hint); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 14px;
  color: var(--muted); cursor: pointer; border: none;
  font-size: 13px; transition: background var(--t-fast), color var(--t-fast);
  user-select: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active {
  color: var(--on-tertiary);
  background: var(--tertiary);
  font-weight: 600;
}
.nav-item .nav-icon { width: 20px; height: 20px; display: grid; place-items: center; flex: none; }
.nav-item .nav-icon svg { width: 20px; height: 20px; display: block; }
.nav-item .nav-desc { margin-left: auto; font-size: 10px; color: var(--hint); font-weight: 400; }

.side-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 4px; border-top: 1px solid var(--divider);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 600; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
}
.side-user { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.side-user strong { font-size: 13px; font-weight: 600; }
.side-user span { font-size: 11px; color: var(--hint); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--divider);
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  backdrop-filter: blur(14px); z-index: 20;
}
.topbar-title h2 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar-title p { margin: 2px 0 0; font-size: 11px; color: var(--hint); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.clock {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.clock-time { font-size: 14px; font-weight: 600; letter-spacing: .4px; }
.clock-date { font-size: 10.5px; color: var(--hint); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: none;
  background: var(--panel-2); color: var(--text); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--btn-bg-hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; display: block; }

.viewport {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px;
  scroll-behavior: smooth;
}

.tabbar { display: none; }

/* ---------------- 视图容器 ---------------- */
.view { display: none; animation: viewIn .28s var(--ease-out) both; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.page { display: flex; flex-direction: column; gap: 18px; max-width: 1180px; margin: 0 auto; }
.page-wide { max-width: none; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}
.card:active { transform: scale(.995); }
.card-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 12px; font-size: 15px; font-weight: 600;
}
.card-title .sub { font-size: 11px; font-weight: 400; color: var(--hint); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.btn {
  appearance: none; border: none; background: var(--btn-bg);
  color: var(--text); min-height: 40px; padding: 11px 16px; border-radius: 16px;
  font-size: 14px; font-family: inherit; white-space: nowrap;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { background: var(--btn-bg-press); transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; display: block; flex: none; }
.btn-primary {
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  border: 1px solid color-mix(in srgb, var(--brand1) 35%, transparent);
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 20px color-mix(in srgb, var(--brand1) 20%, transparent);
}
.btn-primary:hover { background: linear-gradient(135deg, color-mix(in srgb, var(--brand1), #000 8%), color-mix(in srgb, var(--brand2), #000 8%)); }
[data-theme="dark"] .btn-primary {
  box-shadow: 0 8px 40px color-mix(in srgb, var(--brand1) 18%, transparent);
}
.btn-danger { color: #fff; background: var(--danger); font-weight: 600; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger), #000 8%); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { padding: 7px 14px; min-height: 32px; font-size: 13px; border-radius: 12px; }
.btn-block { width: 100%; justify-content: center; }

.chip {
  border: none; background: var(--panel-2); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none; display: inline-flex; align-items: center; gap: 5px;
}
.chip:hover { background: var(--btn-bg-hover); color: var(--text); }
.chip.active { color: var(--on-tertiary); background: var(--tertiary); font-weight: 600; }
.chip svg { width: 14px; height: 14px; display: block; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px; border-radius: 16px; font-size: 14px;
  border: none; background: var(--input-bg); color: var(--text);
  font-family: inherit; outline: none;
  transition: box-shadow var(--t-fast), background var(--t-fast);
}
.input:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand1) 45%, transparent);
}
textarea.input { resize: vertical; min-height: 76px; }
select.input option { background: var(--panel-solid); color: var(--text); }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }
[data-theme="light"] input[type="date"].input, [data-theme="light"] input[type="time"].input { color-scheme: light; }

/* 全站禁止省略号截断：宁可换行 */
input, textarea, button, select { text-overflow: clip; }
input[type="file"] { text-overflow: clip !important; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; background: var(--panel-2); color: var(--muted); border: none;
}
.badge svg { width: 12px; height: 12px; display: block; }
.badge-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.badge-brand { color: #fff; background: var(--brand1); border: none; font-weight: 600; }

.progress {
  height: 8px; border-radius: 999px; overflow: hidden; background: var(--panel-2);
  border: none;
}
.progress > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand1), var(--brand2));
  transition: width .5s var(--ease-out);
}

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat .stat-label { font-size: 12px; color: var(--hint); }
.stat .stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .4px; }
.stat .stat-hint { font-size: 11px; color: var(--hint); }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 16px; text-align: center; color: var(--muted);
}
.empty .empty-icon { color: var(--muted); opacity: .75; }
.empty .empty-icon svg { width: 40px; height: 40px; display: block; }
.empty .empty-text { font-size: 14px; color: var(--text); font-weight: 600; }
.empty .empty-hint { font-size: 12px; color: var(--hint); }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--brand1) 25%, transparent);
  border-top-color: var(--brand1); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 0; color: var(--hint); }

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: var(--overlay); backdrop-filter: blur(8px);
  animation: fadeIn var(--t-base) ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(520px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: modalIn .3s var(--ease-out);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--divider);
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 13px 18px;
  border-top: 1px solid var(--divider); background: transparent;
}
.modal-close {
  width: 30px; height: 30px; border-radius: 999px; border: none; background: var(--panel-2);
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.modal-close:hover { background: var(--btn-bg-hover); color: var(--text); }
.modal-close:active { transform: scale(.94); }
.modal-close svg { width: 15px; height: 15px; display: block; }

/* ---------------- Toast ---------------- */
#toast-root {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  padding: 10px 16px; border-radius: 999px; font-size: 13px; color: var(--text);
  background: var(--panel-solid); border: 1px solid var(--line);
  box-shadow: var(--shadow); animation: toastIn .28s var(--ease-out);
  display: flex; align-items: center; gap: 7px; max-width: 100%;
}
.toast svg { width: 15px; height: 15px; display: block; flex: none; }
.toast.success { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.toast.success svg { color: var(--ok); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.toast.error svg { color: var(--danger); }
.toast.info { border-color: color-mix(in srgb, var(--brand1) 40%, transparent); }
.toast.info svg { color: var(--brand1); }
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* ---------------- 描述列表 ---------------- */
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; word-break: break-all; }

/* ---------------- 表单 / 确认 / 小按钮（跨模块通用） ---------------- */
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-error { font-size: 12px; color: var(--danger); }
.confirm-text { font-size: 14px; line-height: 1.6; word-break: break-word; }

.mini-btn {
  width: 32px; height: 32px; border-radius: 10px; border: none;
  background: var(--panel-2); cursor: pointer; color: var(--text);
  display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.mini-btn:hover { background: var(--btn-bg-hover); }
.mini-btn:active { transform: scale(.95); }
.mini-btn svg { width: 15px; height: 15px; display: block; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .viewport { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 14px; }
  .topbar-title h2 { font-size: 16px; }
  .clock { display: none; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
    border-top: 1px solid var(--divider); backdrop-filter: blur(16px);
  }
  .tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border: none; background: none; color: var(--muted);
    font-size: 12px; cursor: pointer; border-radius: 12px;
    transition: color var(--t-fast);
    min-width: 0; white-space: nowrap;
  }
  .tab-item .tab-icon { width: 22px; height: 22px; line-height: 1; display: grid; place-items: center; }
  .tab-item .tab-icon svg { width: 22px; height: 22px; display: block; }
  .tab-item.active { color: var(--brand1); }
  .modal { max-height: 90dvh; border-radius: 20px 20px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .kv { grid-template-columns: 76px 1fr; }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .app { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}
