/* 房屋租赁管理系统 - 样式 */
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: "PingFang SC","Microsoft YaHei",sans-serif; background:#f0f2f5; color:#333; font-size:14px; }

/* 左侧导航布局 (sidebar) */
.layout { display:flex; min-height:100vh; }
.sidebar { width:230px; background:#1f2d3d; color:#cfd8e3; display:flex; flex-direction:column; position:fixed; top:0; left:0; bottom:0; z-index:90; box-shadow:2px 0 10px rgba(0,0,0,.12); }
.sidebar-brand { height:56px; display:flex; align-items:center; padding:0 20px; font-size:17px; font-weight:700; color:#fff; border-bottom:1px solid rgba(255,255,255,.08); white-space:nowrap; }
.sidebar-nav { flex:1; overflow-y:auto; padding:8px 0 20px; }
.nav-group { margin-bottom:4px; }
.nav-group-title { padding:12px 20px 5px; font-size:12px; color:#8a97a8; letter-spacing:1px; }
.nav-item { display:flex; align-items:center; gap:8px; padding:10px 20px; color:#cfd8e3; text-decoration:none; font-size:14px; transition:all .2s; border-left:3px solid transparent; }
.nav-item:hover { background:rgba(255,255,255,.06); color:#fff; }
.nav-item.active { background:rgba(59,130,246,.18); color:#fff; border-left-color:#3b82f6; }
.sidebar-footer { padding:14px 20px; border-top:1px solid rgba(255,255,255,.08); display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:13px; }
.main { flex:1; margin-left:230px; display:flex; flex-direction:column; min-width:0; min-height:100vh; }
.topbar { height:56px; background:#fff; display:flex; align-items:center; padding:0 20px; gap:14px; box-shadow:0 1px 3px rgba(0,0,0,.06); position:sticky; top:0; z-index:80; }
.breadcrumb { font-size:15px; font-weight:600; color:#1f2d3d; flex:1; }
.topbar-user { color:#64748b; font-size:13px; }
.main .container { max-width:none; padding:16px 20px; }

/* 容器 */
.container { max-width:1440px; margin:0 auto; padding:16px 20px; }
.page { display:none; }
.page.active { display:block; }
.page-title { font-size:18px; font-weight:700; margin:8px 0 14px; }

/* 统计卡片 */
.stat-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin-bottom:18px; }
.stat-card { background:#fff; border-radius:10px; padding:14px 16px; box-shadow:0 1px 4px rgba(0,0,0,.08); border-left:4px solid #3b82f6; }
.stat-card .label { color:#888; font-size:12px; margin-bottom:6px; }
.stat-card .value { font-size:20px; font-weight:700; color:#1f2d3d; }
.stat-card .sub { color:#999; font-size:12px; margin-top:4px; }
.stat-card.green { border-left-color:#22c55e; }
.stat-card.orange { border-left-color:#f59e0b; }
.stat-card.red { border-left-color:#ef4444; }
.stat-card.purple { border-left-color:#8b5cf6; }

/* 工具条 */
.toolbar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; background:#fff; padding:10px 12px; border-radius:10px; margin-bottom:12px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.toolbar input, .toolbar select { height:32px; padding:0 8px; border:1px solid #dcdfe6; border-radius:6px; font-size:13px; outline:none; }
.toolbar input:focus, .toolbar select:focus { border-color:#3b82f6; }
.toolbar .spacer { flex:1; }
.btn { display:inline-flex; align-items:center; gap:4px; height:32px; padding:0 14px; border:none; border-radius:6px; cursor:pointer; font-size:13px; background:#3b82f6; color:#fff; transition:all .15s; }
.btn:hover { opacity:.88; }
.btn.green { background:#22c55e; }
.btn.orange { background:#f59e0b; }
.btn.red { background:#ef4444; }
.btn.gray { background:#6b7280; }
.btn.sm { height:26px; padding:0 10px; font-size:12px; border-radius:5px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* 表格 */
.table-wrap { background:#fff; border-radius:10px; box-shadow:0 1px 3px rgba(0,0,0,.06); overflow-x:auto; }
table { width:100%; border-collapse:collapse; table-layout:fixed; }
th, td { padding:9px 10px; border-bottom:1px solid #f0f0f0; text-align:left; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
th { background:#f8fafc; color:#64748b; font-weight:600; position:sticky; top:0; }
tr:hover td { background:#f8fafc; }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; }
td.center, th.center { text-align:center; }
tr.total-row td { font-weight:700; background:#f1f5f9; }
.td-notes { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:180px; }
/* 操作列: 允许按钮换行且不被裁剪 (覆盖 table-layout:fixed 的 overflow 限制) */
td.td-ops { overflow:visible; white-space:normal; }
td.td-ops .btn { margin:2px 1px; }

/* 标签 */
.tag { display:inline-block; padding:2px 9px; border-radius:10px; font-size:12px; line-height:18px; }
.tag-green { background:#dcfce7; color:#15803d; }
.tag-orange { background:#fef3c7; color:#b45309; }
.tag-red { background:#fee2e2; color:#b91c1c; }
.tag-gray { background:#f1f5f9; color:#64748b; }
.tag-blue { background:#dbeafe; color:#1d4ed8; }
.tag-purple { background:#ede9fe; color:#6d28d9; }

/* 分页 */
.pagination { display:flex; align-items:center; gap:8px; padding:10px 12px; justify-content:flex-end; font-size:13px; color:#666; }
.pagination .btn { height:26px; padding:0 10px; font-size:12px; }

/* 弹窗 */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:1000; display:flex; align-items:flex-start; justify-content:center; padding:40px 16px; overflow-y:auto; }
.modal { background:#fff; border-radius:12px; width:100%; max-width:560px; box-shadow:0 10px 40px rgba(0,0,0,.2); }
.modal.wide { max-width:760px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:14px 20px; border-bottom:1px solid #eee; }
.modal-header h3 { font-size:16px; }
.modal-close { background:none; border:none; font-size:18px; cursor:pointer; color:#999; }
.modal-close:hover { color:#333; }
.modal-body { padding:18px 20px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px 16px; }
.form-item { display:flex; flex-direction:column; }
.form-item.full { grid-column:1/-1; }
.form-item label { font-size:12px; color:#666; margin-bottom:4px; }
.form-item input, .form-item select, .form-item textarea { height:32px; padding:0 8px; border:1px solid #dcdfe6; border-radius:6px; font-size:13px; outline:none; }
.form-item textarea { height:64px; padding:6px 8px; resize:vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color:#3b82f6; }
.modal-footer { display:flex; justify-content:flex-end; gap:8px; padding:14px 20px; border-top:1px solid #eee; }
.checkbox-item { flex-direction:row; align-items:center; gap:8px; }
.checkbox-item label { margin-bottom:0; }

/* 统计报表 */
.stats-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; }
.panel { background:#fff; border-radius:10px; padding:16px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.panel h3 { font-size:15px; margin-bottom:12px; color:#1f2d3d; }
.panel table td, .panel table th { padding:8px 10px; }
.big-number { font-size:26px; font-weight:700; }
.month-bars { display:flex; align-items:flex-end; gap:6px; height:160px; padding:10px 4px 0; }
.month-bar-wrap { flex:1; display:flex; flex-direction:column; align-items:center; height:100%; justify-content:flex-end; }
.month-bar { width:70%; background:#3b82f6; border-radius:4px 4px 0 0; min-height:2px; transition:height .3s; }
.month-bar.paid { background:#22c55e; }
.month-label { font-size:11px; color:#888; margin-top:4px; }

/* 提示 */
.toast { position:fixed; top:70px; left:50%; transform:translateX(-50%); background:#1f2d3d; color:#fff; padding:10px 22px; border-radius:8px; z-index:2000; font-size:14px; box-shadow:0 4px 16px rgba(0,0,0,.2); animation:fadeIn .2s; }
.toast.error { background:#ef4444; }
.toast.success { background:#22c55e; }
@keyframes fadeIn { from{opacity:0; transform:translate(-50%,-8px);} to{opacity:1; transform:translate(-50%,0);} }

/* 登录页 */
#login-page { display:flex; align-items:center; justify-content:center; min-height:80vh; }
.login-box { background:#fff; border-radius:12px; padding:36px 40px; width:360px; box-shadow:0 10px 40px rgba(0,0,0,.12); text-align:center; }
.login-title { font-size:20px; font-weight:700; color:#1f2d3d; margin-bottom:6px; }
.login-sub { color:#999; font-size:13px; margin-bottom:24px; }
.login-input { width:100%; height:40px; border:1px solid #dcdfe6; border-radius:8px; padding:0 12px; font-size:14px; margin-bottom:14px; outline:none; }
.login-input:focus { border-color:#3b82f6; }
.login-btn { width:100%; height:40px; font-size:15px; border-radius:8px; }
.login-error { color:#ef4444; font-size:13px; margin-top:12px; min-height:18px; }
.nav-user { color:#cfd8e3; font-size:13px; margin-left:auto; padding:0 12px; display:flex; align-items:center; gap:10px; }
.nav-user .btn { height:26px; padding:0 10px; font-size:12px; }

/* 响应式 */
@media (max-width:768px) {
  .sidebar { transform:translateX(-100%); transition:transform .25s; }
  .sidebar.open { transform:translateX(0); box-shadow:2px 0 16px rgba(0,0,0,.2); }
  .main { margin-left:0; }
  .nav-toggle { display:block; background:none; border:none; font-size:20px; cursor:pointer; color:#1f2d3d; }
  .stats-grid { grid-template-columns:1fr; }
  .form-grid { grid-template-columns:1fr; }
}

/* ============ AI 助手 ============ */
#ai-fab {
  position: fixed; right: 22px; bottom: 26px; z-index: 1500;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-size: 26px; line-height: 56px; text-align: center;
  cursor: pointer; box-shadow: 0 6px 20px rgba(37, 99, 235, .4);
  transition: transform .2s, box-shadow .2s; user-select: none;
}
#ai-fab:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(37, 99, 235, .5); }
#ai-fab.open { transform: rotate(90deg); }
.ai-panel {
  position: fixed; right: 22px; bottom: 92px; z-index: 1500;
  width: 400px; max-width: calc(100vw - 40px); height: 600px; max-height: calc(100vh - 130px);
  background: #fff; border-radius: 14px; box-shadow: 0 12px 48px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden; animation: aiPop .2s;
}
@keyframes aiPop { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.ai-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-size: 15px; font-weight: 600;
}
.ai-header small { font-weight: 400; font-size: 11px; opacity: .85; margin-left: 6px; }
.ai-header-actions { display: flex; gap: 6px; }
.ai-header-actions button {
  background: rgba(255,255,255,.18); color: #fff; border: none; border-radius: 6px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px; line-height: 1;
}
.ai-header-actions button:hover { background: rgba(255,255,255,.3); }
.ai-body {
  flex: 1; overflow-y: auto; padding: 14px; background: #f6f8fb;
  display: flex; flex-direction: column; gap: 10px;
}
.ai-welcome { color: #94a3b8; font-size: 13px; line-height: 1.9; padding: 18px; text-align: center; }
.ai-warn { color: #f59e0b; font-weight: 600; }
.ai-msg {
  max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px;
  line-height: 1.65; word-break: break-word; white-space: normal;
}
.ai-user { align-self: flex-end; background: #3b82f6; color: #fff; border-bottom-right-radius: 4px; }
.ai-assistant { align-self: flex-start; background: #fff; color: #1f2d3d; border: 1px solid #e5e9f0; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.ai-thinking { color: #94a3b8; font-style: italic; }
.ai-plan-hint { margin-top: 10px; font-weight: 600; color: #1f2d3d; }
.ai-pending-bar {
  border-top: 2px solid #f59e0b; background: #fffbeb; padding: 10px 14px;
  max-height: 220px; overflow-y: auto; font-size: 12.5px;
}
.ai-plan-item { border: 1px solid #fde68a; background: #fff; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.ai-plan-title { font-weight: 600; color: #92400e; margin-bottom: 4px; }
.ai-plan-method { font-family: monospace; font-size: 11px; color: #78716c; background: #f5f5f4; padding: 2px 6px; border-radius: 4px; display: inline-block; margin-bottom: 4px; }
.ai-plan-args { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ai-arg { font-size: 11.5px; color: #57534e; }
.ai-arg span { color: #a8a29e; margin-right: 2px; }
.ai-arg b { font-weight: 500; color: #1c1917; }
.ai-plan-actions { display: flex; gap: 10px; margin-top: 6px; }
.ai-btn-ok { flex: 1; background: #22c55e; color: #fff; border: none; border-radius: 8px; padding: 8px 0; font-size: 13px; font-weight: 600; cursor: pointer; }
.ai-btn-ok:hover { background: #16a34a; }
.ai-btn-no { background: #e5e7eb; color: #4b5563; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.ai-btn-no:hover { background: #d1d5db; }
.ai-exec-row { padding: 6px 0; border-bottom: 1px dashed #e5e9f0; font-size: 13px; }
.ai-exec-row.ok { color: #166534; }
.ai-exec-row.fail { color: #b91c1c; }
.ai-exec-row small { color: #94a3b8; }
.ai-input-row {
  display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e5e9f0; background: #fff;
}
.ai-input-row textarea {
  flex: 1; resize: none; border: 1px solid #dcdfe6; border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; outline: none; max-height: 90px; line-height: 1.5;
  font-family: inherit;
}
.ai-input-row textarea:focus { border-color: #3b82f6; }
.ai-send-btn {
  background: #3b82f6; color: #fff; border: none; border-radius: 10px;
  padding: 0 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ai-send-btn:hover { background: #2563eb; }
.ai-send-btn:disabled { background: #94a3b8; cursor: not-allowed; }
@media (max-width:768px) {
  .ai-panel { right: 10px; left: 10px; width: auto; height: calc(100vh - 150px); }
  #ai-fab { right: 14px; bottom: 18px; }
}
