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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== 登录页 ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.auth-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
  color: var(--text);
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.form-group .required::after {
  content: " *";
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea.form-control {
  resize: vertical;
  min-height: 60px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #c2410c; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 主应用布局 ===== */
.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 18px;
  color: var(--text);
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.app-main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
}

.tabs {
  display: flex;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}

.tab:hover { background: #f9fafb; }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #eff6ff;
}

.panel {
  background: var(--card);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== 表格 ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

tbody tr:hover { background: #f9fafb; }

td .actions {
  display: flex;
  gap: 6px;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== 徽章 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-mask.show { display: flex; }

.modal {
  background: var(--card);
  border-radius: 8px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.modal-large { max-width: 700px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 20px; }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== 表单内嵌行 ===== */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-row .form-group { margin-bottom: 0; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .form-group { margin-bottom: 0; flex: 1; min-width: 200px; }

/* ===== 通知 ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  animation: slideIn 0.2s;
  font-size: 14px;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 统计卡片 ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.stat-card .value.money { color: var(--success); }

/* ===== 结算区 ===== */
.settle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settle-row:last-child { border-bottom: none; }

.settle-row .info { flex: 1; }
.settle-row .info .name { font-weight: 500; }
.settle-row .info .amount { color: var(--text-muted); font-size: 13px; }
.settle-row .actions { display: flex; gap: 8px; }
/* ==================== iPad / 窄屏自适应 ==================== */
@media (max-width: 1024px) {
  .settle-row { gap: 12px; flex-wrap: wrap; }
  .settle-row .actions { flex-wrap: wrap; }
  .settle-row .actions .btn { padding: 8px 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .modal .modal-content { width: 92vw; max-height: 88vh; overflow-y: auto; }
  .confirm-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    padding: 16px;
  }
  .confirm-mask .box {
    background: #fff; border-radius: 10px; padding: 20px 24px;
    width: 100%; max-width: 360px; box-shadow: 0 12px 32px rgba(0,0,0,0.2);
  }
  .confirm-mask .msg { white-space: pre-wrap; font-size: 14px; line-height: 1.6; margin-bottom: 16px; color: #1f2937; }
  .confirm-mask .acts { display: flex; gap: 12px; justify-content: flex-end; }
  .confirm-mask .acts .btn { min-width: 80px; }
}

