:root {
  --primary: #2b6cb0;
  --primary-dark: #2c5282;
  --primary-light: #ebf4ff;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --muted: #718096;
  --danger: #e53e3e;
  --warn: #dd6b20;
  --ok: #38a169;
  --sidebar: #1a365d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button { cursor: pointer; font-family: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录/注册 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b6cb0, #1a365d); }
.auth-card { width: 360px; background: #fff; border-radius: 10px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.auth-card h1 { font-size: 22px; color: var(--primary-dark); margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.auth-tabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-tabs span { padding: 8px 14px; cursor: pointer; color: var(--muted); }
.auth-tabs span.active { color: var(--primary); border-bottom: 2px solid var(--primary); font-weight: 600; }
.auth-tip { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ---------- 表单控件 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.btn { background: var(--primary); color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-size: 14px; }
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.ghost:hover { background: var(--primary-light); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); }
.btn.ok { background: var(--ok); }

/* ---------- 主框架 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 190px; background: var(--sidebar); color: #cbd5e0; flex-shrink: 0; }
.sidebar .brand { padding: 18px 16px; color: #fff; font-size: 17px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar .menu { padding: 8px 0; }
.sidebar .menu a { display: block; padding: 11px 18px; color: #cbd5e0; font-size: 14px; cursor: pointer; }
.sidebar .menu a:hover, .sidebar .menu a.active { background: rgba(255,255,255,.08); color: #fff; border-left: 3px solid var(--primary); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 52px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.topbar .tenant { font-weight: 600; }
.topbar .user { color: var(--muted); font-size: 13px; }
.topbar .user b { color: var(--text); }
.content { padding: 18px 20px; overflow: auto; }

/* ---------- 卡片/表格/标题 ---------- */
.page-title { font-size: 18px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #f8fafc; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag.warn { background: #fffaf0; color: var(--warn); }
.tag.ok { background: #f0fff4; color: var(--ok); }
.tag.gray { background: #edf2f7; color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }

/* 看板 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--primary-dark); margin-top: 6px; }
.stat .value.warn { color: var(--warn); }

/* 弹层 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 8px; width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.line-items { width: 100%; }
.line-items th, .line-items td { padding: 6px; }
.line-items input { padding: 6px 8px; }
.close-x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #1a202c; color: #fff; padding: 9px 18px; border-radius: 6px; z-index: 99; font-size: 13px; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: .95; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
