:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel-2: #182238;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #8ea0bf;
  --green: #34d399;
  --red: #f87171;
  --purple: #a78bfa;
  --accent: #7c5cff;
  --radius: 16px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(124, 92, 255, 0.25), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(52, 211, 153, 0.12), transparent 35%),
    var(--bg);
}
.auth-card {
  width: min(420px, 92vw);
  background: rgba(18, 26, 47, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.auth-brand { font-size: 28px; font-weight: 700; }
.auth-sub { color: var(--muted); margin: 6px 0 18px; font-size: 13px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 8px; cursor: pointer;
}
.auth-tab.active { background: rgba(124,92,255,.2); color: #fff; border-color: rgba(124,92,255,.5); }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.auth-card input, .search, .modal-card input, .modal-card select {
  width: 100%; margin-top: 6px; border-radius: 10px; border: 1px solid var(--line);
  background: #0d1528; color: var(--text); padding: 10px 12px; outline: none;
}
.auth-hint { color: var(--muted); font-size: 12px; margin-top: 14px; }
.auth-error { color: var(--red); min-height: 1.2em; font-size: 13px; }

.auth-lang-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.lang-btn {
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.lang-btn:hover { color: #fff; }
.lang-btn.active {
  background: #fff;
  color: #0f172a;
  font-weight: 600;
}
.lang-btn[data-lang="ug"],
[data-i18n="langUg"] {
  font-family: var(--ug-font, 'alkatip tor', 'alkatip basma tom', 'ukij tuz tom', 'alkatip basma', serif) !important;
  font-size: 13px;
  direction: ltr !important;
  unicode-bidi: isolate;
}
.lang-btn[data-lang="zh"] {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}
.top-meta .lang-switch { margin-inline-end: 8px; }

/*
 * 维语布局：html dir 仍 ltr（语言钮稳定）；
 * 双栏镜像：主内容左、导航栏右（与主区 RTL 文案一致）
 */
html.lang-ug,
body.lang-ug {
  direction: ltr !important;
  font-family: var(--ug-font, 'alkatip tor', 'alkatip basma tom', 'ukij tuz tom', serif) !important;
}

/* 侧栏换到右边 */
body.lang-ug .app-shell {
  grid-template-columns: 1fr 260px;
  direction: ltr !important;
}
body.lang-ug .app-shell > .main {
  grid-column: 1;
  order: 1;
}
body.lang-ug .app-shell > .sidebar {
  grid-column: 2;
  order: 2;
  border-right: none;
  border-left: 1px solid var(--line);
  text-align: right;
}
body.lang-ug .side-brand,
body.lang-ug .side-brand strong,
body.lang-ug .side-brand span,
body.lang-ug .nav-item,
body.lang-ug .goal-box,
body.lang-ug .goal-box span,
body.lang-ug .goal-box strong,
body.lang-ug .user-box,
body.lang-ug .user-box #userLabel,
body.lang-ug .user-box .linkish {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}
body.lang-ug .nav-item {
  width: 100%;
  display: block;
}
body.lang-ug .user-box {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* 顶栏 / 页头镜像：标题靠右，操作靠左 */
body.lang-ug .topbar,
body.lang-ug .page-head {
  flex-direction: row-reverse;
}
body.lang-ug .head-actions {
  flex-direction: row-reverse;
}
body.lang-ug .search {
  text-align: right;
  direction: rtl;
}
body.lang-ug .lang-switch,
body.lang-ug .lang-btn,
body.lang-ug .range-tabs,
body.lang-ug .modal-actions {
  direction: ltr !important;
}
body.lang-ug .auth-lang-bar {
  right: auto;
  left: 16px;
}
body.lang-ug .auth-card {
  direction: rtl;
  text-align: right;
}
body.lang-ug .auth-tabs {
  direction: rtl;
}
body.lang-ug .auth-card input {
  direction: rtl;
  text-align: right;
}
body.lang-ug .modal-card {
  direction: rtl;
  text-align: right;
}
body.lang-ug .modal-actions {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

body.lang-ug .ug-text,
body.lang-ug [data-i18n]:not(.lang-btn),
body.lang-ug [data-i18n-placeholder],
body.lang-ug .auth-brand,
body.lang-ug .auth-sub,
body.lang-ug .auth-hint,
body.lang-ug .auth-tab,
body.lang-ug .auth-card label,
body.lang-ug .side-brand,
body.lang-ug .nav-item,
body.lang-ug .page-head h1,
body.lang-ug .kpi span,
body.lang-ug .biz-card h3,
body.lang-ug .panel h3,
body.lang-ug .sub-title,
body.lang-ug .search,
body.lang-ug .goal-box,
body.lang-ug .user-box,
body.lang-ug .settings-panel,
body.lang-ug .table-head,
body.lang-ug .table-row,
body.lang-ug .empty,
body.lang-ug .ai-tip,
body.lang-ug .modal-card,
body.lang-ug .btn-primary,
body.lang-ug .btn-ghost,
body.lang-ug .linkish {
  font-family: var(--ug-font, 'alkatip tor', 'alkatip basma tom', 'ukij tuz tom', serif) !important;
}
body.lang-ug .ug-text,
body.lang-ug .auth-brand,
body.lang-ug .auth-sub,
body.lang-ug .auth-hint,
body.lang-ug .page-head h1,
body.lang-ug .kpi span,
body.lang-ug .biz-card h3,
body.lang-ug .panel h3,
body.lang-ug .sub-title,
body.lang-ug .settings-panel,
body.lang-ug .table-head,
body.lang-ug .table-row,
body.lang-ug .empty,
body.lang-ug .ai-tip,
body.lang-ug .modal-card input,
body.lang-ug .modal-card select {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}
body.lang-ug .kpi,
body.lang-ug .biz-card,
body.lang-ug .panel {
  text-align: right;
}
body.lang-ug .kpi strong,
body.lang-ug .biz-card strong,
body.lang-ug .goal-box strong,
body.lang-ug #todayLabel {
  font-family: var(--ug-font, 'alkatip tor', 'alkatip basma tom', serif) !important;
  direction: rtl !important;
  text-align: right !important;
}
body.lang-ug .cat-row {
  grid-template-columns: 70px 1fr 88px;
  direction: rtl;
}
body.lang-ug .lang-btn[data-lang='zh'],
body.lang-ug .lang-btn[data-lang='ug'] {
  direction: ltr !important;
  text-align: center !important;
  unicode-bidi: isolate;
}
body.lang-ug .lang-btn[data-lang='zh'] {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}
body.lang-ug .lang-btn[data-lang='ug'] {
  font-family: var(--ug-font, 'alkatip tor', 'alkatip basma tom', serif) !important;
}

@media (max-width: 960px) {
  body.lang-ug .app-shell {
    grid-template-columns: 1fr;
  }
  body.lang-ug .app-shell > .main,
  body.lang-ug .app-shell > .sidebar {
    grid-column: auto;
    order: unset;
  }
}

.btn-primary {
  border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer;
  background: linear-gradient(135deg, #7c5cff, #5b8cff); color: #fff; font-weight: 600;
}
.linkish { border: 0; background: none; color: var(--purple); cursor: pointer; padding: 0; font-size: 12px; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #10182c, #0c1324);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.side-brand strong { display: block; font-size: 20px; }
.side-brand span { color: var(--muted); font-size: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left; border: 0; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.nav-item.active, .nav-item:hover { background: rgba(124,92,255,.16); color: #fff; }
.nav-muted { margin-top: auto; }
.side-foot { display: grid; gap: 12px; }
.goal-box, .user-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.goal-box span, .user-box { color: var(--muted); font-size: 12px; }
.goal-box strong { display: block; margin-top: 4px; color: #fff; font-size: 18px; }
.user-box { display: flex; gap: 10px; align-items: center; color: var(--text); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: linear-gradient(135deg, #7c5cff, #34d399);
  color: #fff; font-weight: 700;
}

.main { padding: 18px 22px 28px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.search { max-width: 420px; }
.top-meta { color: var(--muted); display: flex; gap: 14px; align-items: center; font-size: 13px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 28px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.range-tabs { display: flex; background: var(--panel); border-radius: 999px; padding: 4px; border: 1px solid var(--line); }
.range-tabs button {
  border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.range-tabs button.on { background: rgba(124,92,255,.25); color: #fff; }

.kpi-row, .biz-row, .charts-row { display: grid; gap: 14px; margin-bottom: 14px; }
.kpi-row { grid-template-columns: repeat(3, 1fr); }
.biz-row { grid-template-columns: repeat(3, 1fr); }
.charts-row { grid-template-columns: 1.4fr 1fr; }
.kpi, .biz-card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.kpi span, .biz-card h3, .panel h3 { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi strong { display: block; margin-top: 8px; font-size: 30px; }
.kpi-in strong { color: var(--green); }
.kpi-out strong { color: var(--red); }
.biz-card strong { display: block; margin-top: 10px; font-size: 24px; }
.biz-card.warn strong { color: #fbbf24; }
.cat-bars { display: grid; gap: 10px; margin-top: 12px; }
.cat-row { display: grid; grid-template-columns: 72px 1fr 70px; gap: 8px; align-items: center; font-size: 13px; }
.cat-track { height: 10px; background: #0d1528; border-radius: 999px; overflow: hidden; }
.cat-fill { height: 100%; background: linear-gradient(90deg, #7c5cff, #34d399); }

.table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-row, .table-head {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.4fr; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.table-head { color: var(--muted); background: var(--panel-2); }
.empty { color: var(--muted); padding: 8px 2px 18px; }

.modal {
  position: fixed; inset: 0; background: rgba(2,6,18,.65);
  display: grid; place-items: center; z-index: 40;
}
.modal-card {
  width: min(440px, 92vw); background: #121a2f; border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; display: grid; gap: 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.btn-ghost {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 10px; padding: 8px 12px; cursor: pointer;
}
.settings-panel { line-height: 1.7; color: var(--muted); font-size: 14px; }
.btn-danger-link {
  border: 0; background: none; color: var(--red); cursor: pointer; font-size: 12px; padding: 0;
}
.sub-title { margin: 18px 0 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
.ai-tip {
  padding: 10px 12px; margin: 8px 0; border-radius: 10px;
  background: rgba(124,92,255,.12); border: 1px solid rgba(124,92,255,.25); line-height: 1.5;
}
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-row, .biz-row, .charts-row { grid-template-columns: 1fr; }
}
