:root {
  --primary: #2f6bff;
  --primary-dark: #1f52d6;
  --primary-light: #e8efff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-sub: #6b7280;
  --text-light: #9ca3af;
  --sidebar-bg: #1e2530;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2f6bff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ===== 认证页 ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2f6bff 50%, #5b8cff 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon {
  width: 64px; height: 64px; line-height: 64px;
  font-size: 34px; border-radius: 16px;
  background: var(--primary-light);
  margin: 0 auto 14px;
}
.auth-logo h1 { font-size: 22px; color: var(--text); }
.auth-logo p { font-size: 13px; color: var(--text-sub); margin-top: 6px; }
.auth-tabs {
  display: flex; gap: 8px; margin-bottom: 24px;
  background: var(--bg); border-radius: 10px; padding: 4px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-sub);
  transition: all .2s;
}
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.auth-form input, .auth-form select {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; transition: border .2s;
}
.auth-form input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.auth-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-light); }
.auth-portal-tip { text-align: center; margin-top: 10px; padding: 8px 12px; font-size: 12px; color: var(--text-sub); background: var(--bg-sub); border-radius: 8px; }
.auth-portal-tip a { color: var(--primary); font-weight: 500; text-decoration: none; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .logo-icon.small {
  width: 36px; height: 36px; line-height: 36px; font-size: 20px;
  border-radius: 9px; background: var(--primary); text-align: center;
}
.brand-name { color: #fff; font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-light); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group-title {
  padding: 12px 18px 6px; font-size: 11px; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; cursor: pointer; font-size: 13.5px;
  color: var(--sidebar-text); transition: all .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active {
  background: rgba(47,107,255,0.15); color: #fff;
  border-left-color: var(--primary);
}
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.06); }
.btn-logout {
  width: 100%; padding: 9px; border: 1px solid rgba(255,255,255,0.15);
  background: transparent; color: var(--sidebar-text); border-radius: 8px;
  cursor: pointer; font-size: 13px;
}
.btn-logout:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; height: 60px; background: #fff;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.menu-toggle { display: none; border: none; background: none; font-size: 20px; cursor: pointer; }
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-date { font-size: 13px; color: var(--text-sub); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; background: var(--bg); border-radius: 20px; font-size: 13px;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.content { padding: 24px; flex: 1; }

/* ===== 卡片与通用 ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-sub); margin-top: 4px; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-info .stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-info .stat-label { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

/* ===== 表格 ===== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-input {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; min-width: 200px;
}
.search-input:focus { border-color: var(--primary); }
.select-input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; background: #fff;
}
.btn {
  padding: 9px 16px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

/* 批量操作栏 */
.batch-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding: 10px 14px; background: #f0f6ff; border: 1px solid #cfe0ff; border-radius: 8px;
}
.batch-bar .spacer { flex: 1; }
.data-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 12px 14px; background: var(--bg);
  color: var(--text-sub); font-weight: 600; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fafbfc; }
.data-table .actions { display: flex; gap: 6px; }
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: 13px; padding: 2px 4px;
}
.link-btn.danger { color: var(--danger); }
.link-btn:hover { text-decoration: underline; }

/* 状态标签 */
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag.green { background: #dcfce7; color: #15803d; }
.tag.red { background: #fee2e2; color: #dc2626; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.yellow { background: #fef3c7; color: #b45309; }
.tag.gray { background: #f3f4f6; color: #6b7280; }
.tag.purple { background: #ede9fe; color: #6d28d9; }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-light);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== 模态框 ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.modal.lg { max-width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-light); line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.form-field label .req { color: var(--danger); margin-left: 2px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none; font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); }
.form-field textarea { resize: vertical; min-height: 80px; }

/* ===== 关联房屋多选（业主表单） ===== */
.house-picker { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.house-picker-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.house-picker-count { margin-left: auto; font-size: 12px; color: var(--text-sub); }
.house-picker-list {
  max-height: 200px; overflow-y: auto; padding: 8px 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
.house-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; padding: 3px 0; }
.house-check input { width: auto; margin: 0; }
.house-check span { color: var(--text); }
.house-check:hover span { color: var(--primary); }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 12px 18px; border-radius: 10px; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .25s ease; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-date { display: none; }
}

/* 支付弹窗 */
.pay-qr { text-align: center; padding: 20px 0; }
.pay-qr .qr-placeholder {
  width: 200px; height: 200px; margin: 0 auto 16px; border-radius: 12px;
  background: #f8fafc; border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 60px;
}
.pay-amount { font-size: 30px; font-weight: 700; color: var(--danger); }
.pay-channel-list { display: flex; gap: 10px; margin: 16px 0; justify-content: center; }
.pay-channel {
  padding: 12px 20px; border: 2px solid var(--border); border-radius: 10px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px; transition: all .15s;
}
.pay-channel .pc-icon { font-size: 26px; }
.pay-channel.active { border-color: var(--primary); background: var(--primary-light); }

/* 角色权限管理 */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.role-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.role-card-head { display: flex; flex-direction: column; gap: 6px; }
.role-card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-badge { font-size: 15px; font-weight: 600; }
.role-card-meta { font-size: 12px; color: var(--text-sub); line-height: 1.5; }
.role-card-actions { display: flex; gap: 8px; align-items: center; }

/* 权限矩阵 */
.perm-toolbar { display: flex; gap: 12px; margin-bottom: 12px; }
.perm-table-wrap { max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.perm-table th, .perm-table td { text-align: center; }
.perm-table .perm-mod { text-align: left; font-weight: 500; }
.perm-check { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.perm-check input { display: none; }
.perm-check span {
  width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--border);
  display: inline-block; position: relative; transition: all .15s;
}
.perm-check input:checked + span { background: var(--primary); border-color: var(--primary); }
.perm-check input:checked + span::after {
  content: ''; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.perm-check input:disabled + span { opacity: .4; cursor: not-allowed; }

/* 用户角色标签 */
.role-chip {
  display: inline-block; padding: 2px 8px; margin-left: 8px; border-radius: 10px;
  background: var(--primary-light); color: var(--primary); font-size: 11px; font-weight: 500;
}

/* 公司创建/加入引导 */
.company-gate { display: flex; gap: 20px; flex-wrap: wrap; padding: 40px 20px; justify-content: center; }
.gate-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 320px; text-align: center; display: flex; flex-direction: column; gap: 12px;
}
.gate-icon { font-size: 48px; }
.gate-card h3 { margin: 0; font-size: 18px; }
.gate-card p { margin: 0; font-size: 13px; color: var(--text-sub); line-height: 1.6; min-height: 40px; }
.gate-join { display: flex; gap: 8px; margin-top: 8px; }
.gate-join input { flex: 1; }

/* 平台管理后台 */
.platform-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.platform-tab {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.platform-tab:hover { border-color: var(--primary); }
.platform-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 登录 tab 双按钮 */
.auth-tabs { display: flex; gap: 0; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 9px 0; border: none; background: transparent; color: var(--text-sub);
  font-size: 14px; cursor: pointer; border-radius: 8px; transition: all .15s;
}
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* 详情弹窗列表 */
.detail-list { display: flex; flex-direction: column; padding: 4px 0; }
.detail-row {
  display: flex; align-items: flex-start; padding: 10px 0;
  border-bottom: 1px dashed var(--border); gap: 16px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  flex: 0 0 90px; font-size: 13px; color: var(--text-sub); line-height: 1.5;
}
.detail-value { flex: 1; font-size: 14px; color: var(--text); line-height: 1.5; word-break: break-all; }

/* ===== 发票管理：标签页 ===== */
.tab-nav {
  display: flex; gap: 4px; border-bottom: 2px solid var(--border);
  margin-bottom: 16px; overflow-x: auto;
}
.tab-item {
  padding: 10px 18px; cursor: pointer; color: var(--text-sub); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
  transition: all .15s;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* ===== 发票管理：筛选面板 ===== */
.filter-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.05));
}
.filter-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 6px 0;
}
.filter-row + .filter-row { border-top: 1px dashed var(--border); }
.filter-label { font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.filter-sep { color: var(--text-light); font-size: 13px; }
.filter-date {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); width: 150px;
}
.filter-select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); min-width: 110px;
}
.filter-input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; width: 170px; color: var(--text);
}
.filter-input::placeholder { color: var(--text-light); }
.link-blue { color: var(--primary); cursor: pointer; }
.link-blue:hover { text-decoration: underline; }
.new-badge {
  position: absolute; top: -7px; right: -7px; background: #ef4444; color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 8px; line-height: 1.4;
}
.tag.orange { background: #ffedd5; color: #c2410c; }

/* ===== 交易即开票：支付方式选择 + 通道信息 ===== */
.field-hint { font-size: 12px; color: var(--text-light); margin: 4px 0 10px; line-height: 1.5; }
.field-hint.blue { color: var(--primary); }
.pay-methods {
  display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 10px 0 6px;
}
.pay-check {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
  color: var(--text); cursor: pointer; user-select: none;
}
.pay-check input { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
.info-icon {
  color: var(--primary); font-style: normal; font-weight: 600; cursor: help; font-size: 13px;
}
.channel-box {
  background: #f7f8fa; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-top: 4px;
}
.channel-inner {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
}
.channel-inner .form-field { margin-bottom: 0; }
.channel-box .field-hint { margin: 10px 0 0; }

/* ===== 发票设置：只读文本、门店选择、税率设置 ===== */
.readonly-text {
  padding: 8px 10px; background: #f7f8fa; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text); font-family: monospace;
}
.store-picker {
  display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 10px 12px;
  background: #f7f8fa; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px;
}
.radio-group { display: flex; gap: 24px; padding: 6px 0; }
.radio-item {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
  color: var(--text); cursor: pointer;
}
.radio-item input { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
.tax-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px dashed var(--border); gap: 16px;
}
.tax-row:last-child { border-bottom: none; }
.tax-name { font-size: 14px; color: var(--text); font-weight: 500; }
.tax-row select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); min-width: 90px;
}
