/* ============================================================
   在云端财务运营平台 - 样式
   福州在云端科技有限公司
   ============================================================ */
:root {
  --brand: #1B4B8A;
  --brand-2: #2E6CB8;
  --brand-soft: #E8F0FA;
  --bg: #F2F6FA;
  --card: #FFFFFF;
  --ink: #1F2D3D;
  --ink-2: #5A6B85;
  --ink-3: #94A5BC;
  --line: #E4EBF4;
  --green: #179B57;
  --green-bg: #E7F6EE;
  --red: #D43A3A;
  --red-bg: #FBECEC;
  --amber: #D97E0F;
  --amber-bg: #FBF1E0;
  --blue: #2E6CB8;
  --blue-bg: #E8F0FA;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 50, 90, 0.06);
  --shadow-lg: 0 8px 28px rgba(20, 50, 90, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }
a { color: var(--brand-2); text-decoration: none; }

/* ===== 加载层 ===== */
.loader {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.loader-logo { font-size: 18px; font-weight: 700; color: var(--brand); letter-spacing: 1px; }
.loader-bar { width: 160px; height: 4px; background: #DCE7F4; border-radius: 99px; overflow: hidden; }
.loader-bar i { display: block; width: 40%; height: 100%; background: var(--brand-2); border-radius: 99px; animation: loadbar 1s infinite ease-in-out; }
@keyframes loadbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 20px 40px;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(46,108,184,.14), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(27,75,138,.10), transparent 60%),
    var(--bg);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.brand-badge {
  width: 60px; height: 60px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(27,75,138,.30);
}
.login-brand h1 { font-size: 22px; color: var(--ink); font-weight: 700; letter-spacing: 1px; }
.login-brand p { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
}
.login-tab { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.login-tab button { padding: 8px 2px 12px; font-size: 15px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.login-tab button.active { color: var(--brand); border-color: var(--brand); }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #FBFCFE; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(46,108,184,.12); background: #fff;
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff;
  padding: 11px 22px; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; }
.login-hint { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 14px; }
.login-foot { margin-top: 28px; color: var(--ink-3); font-size: 12px; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 16px; height: 56px;
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.tt-name { font-weight: 700; font-size: 16px; color: var(--ink); }
.tt-sub { font-size: 11px; color: var(--ink-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px; color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 12px; border-radius: 99px; font-weight: 600;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { display: block; }

/* ===== 布局 ===== */
.app-body { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 216px; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  transition: transform .25s ease;
}
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 10px;
  color: var(--ink-2); font-size: 14.5px; font-weight: 500;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-foot { margin-top: auto; padding: 16px; font-size: 11px; color: var(--ink-3); }

.main { flex: 1; padding: 22px 24px 60px; min-width: 0; }
.page-view { max-width: 1160px; margin: 0 auto; }

/* ===== 卡片与 KPI ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title h3 { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.card-title .sub { font-size: 12px; color: var(--ink-3); }

.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ""; position: absolute; right: -24px; top: -24px;
  width: 90px; height: 90px; border-radius: 50%; opacity: .10;
}
.kpi-card.k-income::after { background: var(--green); }
.kpi-card.k-expense::after { background: var(--red); }
.kpi-card.k-net::after { background: var(--brand); }
.kpi-card.k-month::after { background: var(--amber); }
.kpi-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi-label .dot { width: 7px; height: 7px; border-radius: 50%; }
.k-income .dot { background: var(--green); }
.k-expense .dot { background: var(--red); }
.k-net .dot { background: var(--brand); }
.k-month .dot { background: var(--amber); }
.kpi-value { font-size: 25px; font-weight: 800; margin-top: 8px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.kpi-sub.up { color: var(--green); }
.kpi-sub.down { color: var(--red); }

/* ===== 图表容器 ===== */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 16px; }
.chart-box { height: 300px; }
.chart-box.tall { height: 340px; }

/* ===== 最近流水 ===== */
.flow-list { display: flex; flex-direction: column; }
.flow-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid #F0F4FA;
}
.flow-row:last-child { border-bottom: none; }
.flow-ico {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.flow-ico.income { background: var(--green-bg); color: var(--green); }
.flow-ico.expense { background: var(--red-bg); color: var(--red); }
.flow-ico.transfer { background: var(--blue-bg); color: var(--blue); }
.flow-main { flex: 1; min-width: 0; }
.flow-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-meta { font-size: 12px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14.5px; flex-shrink: 0; }
.flow-amt.income { color: var(--green); }
.flow-amt.expense { color: var(--red); }
.flow-amt.transfer { color: var(--blue); }

/* ===== 工具条 ===== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.select, .input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; outline: none; font-size: 14px;
}
.select:focus, .input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(46,108,184,.12); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  transition: border .15s, color .15s, background .15s;
}
.btn-ghost:hover { border-color: var(--brand-2); color: var(--brand); background: var(--brand-soft); }
.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; padding: 10px 12px;
  color: var(--ink-2); font-weight: 600; font-size: 12.5px;
  background: #F7FAFD; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data-table td {
  padding: 11px 12px; border-bottom: 1px solid #F0F4FA;
  vertical-align: middle; white-space: nowrap;
}
table.data-table tr:hover td { background: #FAFCFE; }
.td-type { font-size: 12px; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.td-type.income { background: var(--green-bg); color: var(--green); }
.td-type.expense { background: var(--red-bg); color: var(--red); }
.td-type.transfer { background: var(--blue-bg); color: var(--blue); }
.td-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.td-num.income { color: var(--green); }
.td-num.expense { color: var(--red); }
.td-num.transfer { color: var(--blue); }
.td-remark { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.pager button {
  padding: 6px 13px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; color: var(--ink-2);
}
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 录入表单 ===== */
.record-wrap { max-width: 720px; }
.record-type { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.type-btn {
  padding: 14px 10px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-weight: 600; color: var(--ink-2); transition: all .15s;
}
.type-btn small { font-weight: 400; font-size: 11px; color: var(--ink-3); }
.type-btn.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.amount-input { font-size: 20px !important; font-weight: 700; }

/* ===== 报表 ===== */
.report-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.report-tab {
  padding: 8px 18px; border-radius: 99px;
  border: 1px solid var(--line); background: #fff;
  font-size: 14px; color: var(--ink-2); font-weight: 500;
  transition: all .15s;
}
.report-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.summary-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px;
}
.summary-cell { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.summary-cell .s-label { font-size: 12.5px; color: var(--ink-2); }
.summary-cell .s-value { font-size: 21px; font-weight: 800; margin-top: 5px; font-variant-numeric: tabular-nums; }
.summary-cell .s-value.green { color: var(--green); }
.summary-cell .s-value.red { color: var(--red); }
.summary-cell .s-value.brand { color: var(--brand); }

/* ===== 设置页 ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-grid .card h3 { margin-bottom: 14px; }
.mini-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.mini-form .input { flex: 1; min-width: 120px; }
.mini-form .select { flex-shrink: 0; }
.role-badge { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.role-badge.admin { background: var(--amber-bg); color: var(--amber); }
.role-badge.executive { background: #EDE9FB; color: #6D4BC4; }

/* ===== 加载提示 ===== */
.loading-tip { padding: 26px 0; text-align: center; color: var(--ink-3); font-size: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: rgba(31,45,61,.92); color: #fff;
  padding: 10px 20px; border-radius: 99px; font-size: 14px;
  z-index: 300; box-shadow: var(--shadow-lg);
  max-width: 86vw; text-align: center;
  animation: toastIn .2s ease;
}
.toast.error { background: rgba(212,58,58,.94); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== 手机底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line);
  display: none; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--ink-3); font-size: 11px;
}
.tab-item.active { color: var(--brand); }
.tab-item svg { display: block; }

/* ===== 移动端适配 ===== */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .main { padding: 14px 14px 90px; }
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; z-index: 55; transform: translateX(-100%); width: 220px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .tabbar { display: grid; }
  .topbar { padding: 0 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: 1fr; gap: 10px; }
  .kpi-value { font-size: 22px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
}
@media (max-width: 420px) {
  .kpi-grid { gap: 10px; }
  .kpi-card { padding: 13px 14px; }
  .kpi-value { font-size: 20px; }
  .record-type { gap: 8px; }
  .type-btn { padding: 11px 6px; font-size: 13px; }
  .toolbar .select, .toolbar .input { flex: 1; min-width: 90px; }
}
