/* =========================================================
   NIKO 管理后台样式表（独立，不依赖前台 style.css）
   前台是 480px 移动端容器，后台必须完全隔离，否则会被限宽压扁
   ========================================================= */

:root {
  --a-primary: #16a34a;
  --a-primary-lt: #4ade80;
  --a-bg: #f1f5f9;
  --a-card: #ffffff;
  --a-text: #0f172a;
  --a-muted: #64748b;
  --a-border: #e2e8f0;
  --a-side: #0f172a;
  --a-side-hover: #1e293b;
  --a-danger: #dc2626;
  --a-warn: #d97706;
  --a-info: #2563eb;
  --a-radius: 12px;
  --a-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; font-size: 14px; outline: none; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ============ 整体框架 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex-shrink: 0;
  background: var(--a-side); color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 18px 20px; color: #fff; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand small { font-size: 11px; font-weight: 400; color: #4ade80; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; font-size: 13.5px; color: #cbd5e1;
  border-left: 3px solid transparent; transition: .15s;
}
.sidebar nav a:hover { background: var(--a-side-hover); color: #fff; }
.sidebar nav a.active {
  background: rgba(74, 222, 128, .12); color: var(--a-primary-lt);
  border-left-color: var(--a-primary-lt); font-weight: 600;
}
.sidebar nav a .ico { width: 18px; text-align: center; font-size: 14px; }
.sidebar nav a .dot {
  margin-left: auto; background: #dc2626; color: #fff; font-size: 10px;
  min-width: 17px; height: 17px; line-height: 17px; text-align: center;
  border-radius: 9px; padding: 0 4px;
}
.sidebar .side-foot {
  padding: 13px 20px; font-size: 11.5px; color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, .08); line-height: 1.7;
}

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

.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar .sp { margin-left: auto; }
.topbar .who { font-size: 12.5px; color: var(--a-muted); }
.topbar .who b { color: var(--a-text); }

.content { flex: 1; padding: 20px 24px 48px; }

/* ============ 卡片 ============ */
.card {
  background: var(--a-card); border-radius: var(--a-radius);
  box-shadow: var(--a-shadow); margin-bottom: 16px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.card-body > .hint { font-size: 12.5px; color: var(--a-muted); line-height: 1.8; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }

/* ============ 统计卡 ============ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: var(--a-radius); padding: 16px 18px;
  box-shadow: var(--a-shadow); display: flex; flex-direction: column; gap: 5px;
}
.stat .lbl { font-size: 12px; color: var(--a-muted); }
.stat .val { font-size: 23px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
.stat .sub { font-size: 11.5px; color: var(--a-muted); }
.stat.green .val { color: var(--a-primary); }
.stat.blue .val { color: var(--a-info); }
.stat.orange .val { color: var(--a-warn); }
.stat.red .val { color: var(--a-danger); }
.stat.dark .val { color: var(--a-text); }

/* ============ 柱状图 ============ */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding: 22px 4px 0; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; }
.chart .barwrap { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.chart .bar {
  width: 100%; max-width: 44px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #4ade80, #16a34a);
  position: relative; min-height: 3px; transition: .3s;
}
.chart .bar .v {
  position: absolute; top: -19px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #475569; white-space: nowrap;
}
.chart .x { font-size: 11px; color: var(--a-muted); white-space: nowrap; }
.chart-empty { color: var(--a-muted); font-size: 13px; text-align: center; padding: 60px 0; }

/* 状态分布条 */
.dist { display: flex; flex-direction: column; gap: 14px; }
.dist-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dist-row .k { width: 62px; color: var(--a-muted); flex-shrink: 0; }
.dist-row .track { flex: 1; height: 9px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.dist-row .track i { display: block; height: 100%; border-radius: 5px; }
.dist-row .n { width: 54px; text-align: right; font-variant-numeric: tabular-nums; color: #334155; flex-shrink: 0; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 14px; text-align: left; font-size: 13px;
  white-space: nowrap; border-bottom: 1px solid var(--a-border);
  vertical-align: middle;
}
th { background: #f8fafc; color: var(--a-muted); font-weight: 600; font-size: 12.5px; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 220px; max-width: 340px; }
td.num { font-variant-numeric: tabular-nums; }
.cell-thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; background: #f1f5f9; }
.cell-user { display: flex; align-items: center; gap: 9px; }
.cell-user .nm { font-weight: 500; }
.cell-user .sm { font-size: 11.5px; color: var(--a-muted); }
.empty-row td { text-align: center; color: var(--a-muted); padding: 34px 0; font-size: 13px; }

/* ============ 徽章 / 标签 ============ */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap;
}
.b-pending   { background: #fef3c7; color: #92400e; }
.b-paid      { background: #dcfce7; color: #166534; }
.b-completed { background: #dbeafe; color: #1e40af; }
.b-cancelled { background: #e2e8f0; color: #475569; }
.b-approved  { background: #dcfce7; color: #166534; }
.b-rejected  { background: #fee2e2; color: #991b1b; }
.b-online    { background: #dcfce7; color: #166534; }
.b-offline   { background: #e2e8f0; color: #475569; }
.b-gray      { background: #e2e8f0; color: #475569; }
.b-blue      { background: #dbeafe; color: #1e40af; }

.tag {
  display: inline-block; padding: 3px 9px; margin: 0 5px 5px 0;
  background: #f1f5f9; color: #334155; border-radius: 6px; font-size: 11.5px;
}
.tag b { color: var(--a-muted); font-weight: 500; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 8px; border: 1px solid transparent;
  background: #f1f5f9; color: #334155; font-size: 13px; white-space: nowrap;
  transition: .15s; line-height: 1.2;
}
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--a-primary); color: #fff; }
.btn-blue    { background: var(--a-info); color: #fff; }
.btn-red     { background: var(--a-danger); color: #fff; }
.btn-warn    { background: var(--a-warn); color: #fff; }
.btn-ghost   { background: #fff; border-color: var(--a-border); color: #334155; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-link { background: none; color: var(--a-info); padding: 4px 2px; font-size: 12.5px; }
.btn-link.danger { color: var(--a-danger); }
.btn-row { display: inline-flex; gap: 6px; align-items: center; }

/* ============ 筛选工具条 ============ */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; width: 100%; }
.filters input, .filters select {
  padding: 7px 11px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--a-text);
}
.filters input[type="text"], .filters input[type="search"] { min-width: 180px; }
.filters input:focus, .filters select:focus { border-color: var(--a-primary-lt); outline: 2px solid rgba(74, 222, 128, .25); }
.filters .sum { margin-left: auto; font-size: 12.5px; color: var(--a-muted); }
.filters .sum b { color: var(--a-primary); font-size: 14px; }

/* ============ 分页 ============ */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 13px 18px; border-top: 1px solid var(--a-border);
  font-size: 13px; color: var(--a-muted);
}
.pager .info { margin-right: auto; }
.pager button {
  min-width: 32px; height: 30px; padding: 0 9px; border-radius: 7px;
  border: 1px solid var(--a-border); background: #fff; color: #334155; font-size: 13px;
}
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager button.cur { background: var(--a-primary); border-color: var(--a-primary); color: #fff; font-weight: 600; }

/* ============ 表单 ============ */
.form-item { margin-bottom: 14px; }
.form-item > label { display: block; font-size: 12.5px; color: var(--a-muted); margin-bottom: 6px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1;
  border-radius: 8px; background: #fff; color: var(--a-text);
}
.form-item textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--a-primary-lt); outline: 2px solid rgba(74, 222, 128, .25);
}
.form-item .tip { font-size: 11.5px; color: var(--a-muted); margin-top: 5px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

.kv { font-size: 12.5px; line-height: 1.9; }
.kv b { display: inline-block; min-width: 76px; color: var(--a-muted); font-weight: 500; }

/* ============ 弹窗 ============ */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; backdrop-filter: blur(2px);
}
.mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3); animation: pop .16s ease-out;
}
.modal.wide { max-width: 680px; }
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .x { margin-left: auto; font-size: 22px; line-height: 1; color: #94a3b8; }
.modal-head .x:hover { color: #475569; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--a-border);
  display: flex; justify-content: flex-end; gap: 9px;
}

/* ============ Toast ============ */
#toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-24px);
  background: #0f172a; color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 13.5px; z-index: 500; opacity: 0; pointer-events: none;
  transition: .25s; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok  { background: var(--a-primary); }
#toast.err { background: var(--a-danger); }

/* ============ 登录页 ============ */
.login-body {
  min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #14532d 55%, #16a34a 100%); padding: 20px;
}
.login-box {
  background: #fff; padding: 38px 34px; border-radius: 16px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-box .lg-brand {
  text-align: center; margin-bottom: 26px;
}
.login-box .lg-brand .ico-lg {
  width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 15px;
  background: linear-gradient(135deg, #4ade80, #16a34a);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; box-shadow: 0 8px 20px rgba(22, 163, 74, .35);
}
.login-box .lg-brand h2 { font-size: 19px; font-weight: 700; }
.login-box .lg-brand p { font-size: 12.5px; color: var(--a-muted); margin-top: 5px; }
.login-box input {
  width: 100%; padding: 12px 14px; border: 1px solid #cbd5e1;
  border-radius: 9px; margin-bottom: 12px; font-size: 14px;
}
.login-box input:focus { border-color: var(--a-primary-lt); outline: 2px solid rgba(74, 222, 128, .25); }
.login-box .btn-login {
  width: 100%; padding: 12px; background: var(--a-primary); color: #fff;
  border-radius: 9px; font-size: 15px; font-weight: 600; margin-top: 4px;
}
.login-box .btn-login:hover { background: #15803d; }
.login-tip { font-size: 12px; color: #94a3b8; text-align: center; margin-top: 16px; line-height: 1.7; }
.login-err {
  color: var(--a-danger); font-size: 13px; text-align: center;
  margin-bottom: 12px; display: none; background: #fef2f2;
  padding: 9px; border-radius: 8px;
}

/* ============ 响应式 ============ */
@media (max-width: 1240px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .sidebar .brand { padding: 14px 16px; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0; }
  .sidebar nav a {
    border-left: 0; border-bottom: 3px solid transparent;
    padding: 11px 15px; white-space: nowrap;
  }
  .sidebar nav a.active { border-left: 0; border-bottom-color: var(--a-primary-lt); }
  .sidebar nav a .dot { display: none; }
  .sidebar .side-foot { display: none; }
  .topbar { padding: 0 16px; height: 52px; }
  .topbar h1 { font-size: 15px; }
  .topbar .who { display: none; }
  .content { padding: 14px 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .filters .sum { margin-left: 0; width: 100%; }
}
