:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --primary-soft: #d2e3fc;
  --bg: #f0f5fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #5f6b7a;
  --border: #dbe3ee;
  --success: #0d9488;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --shadow: 0 8px 24px rgba(26, 115, 232, 0.08);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ========== Auth ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(26,115,232,.18), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(26,115,232,.12), transparent 40%),
    linear-gradient(160deg, #f7fbff 0%, #e8f1fc 50%, #f0f5fb 100%);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(26,115,232,.12);
  overflow: hidden;
  border: 1px solid rgba(26,115,232,.08);
}
.auth-header {
  background: linear-gradient(135deg, #1a73e8, #3b8cf0);
  color: #fff;
  padding: 28px 32px;
  text-align: center;
}
.auth-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-header p { opacity: .9; font-size: 14px; }
.auth-body { padding: 28px 32px 32px; }
.auth-tabs {
  display: flex;
  background: var(--primary-light);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-secondary);
  transition: .2s;
}
.auth-tabs button.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(26,115,232,.12);
}
.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ========== Layout ========== */
.topbar {
  background: linear-gradient(90deg, #1a73e8, #2b82ef);
  color: #fff;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(26,115,232,.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand .logo {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.topbar nav { display: flex; gap: 6px; align-items: center; }
.topbar nav a {
  color: rgba(255,255,255,.9);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  transition: .2s;
}
.topbar nav a:hover, .topbar nav a.active {
  background: rgba(255,255,255,.18);
  color: #fff;
}
.user-chip {
  background: rgba(255,255,255,.15);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  margin-left: 8px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title h2 {
  font-size: 22px;
  color: #153e75;
}
.page-title .sub { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; color: #153e75; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}
.stat-card.pending::before { background: var(--warning); }
.stat-card.processing::before { background: var(--info); }
.stat-card.done::before { background: var(--success); }
.stat-card.rejected::before { background: var(--danger); }
.stat-card .label { color: var(--text-secondary); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #153e75; margin-top: 6px; }
.stat-card .value.money { font-size: 22px; letter-spacing: -0.3px; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #334155;
  font-weight: 500;
}
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: .2s;
  background: #fff;
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}
textarea.form-control { min-height: 110px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 8px 0 18px;
}
.form-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: .2s;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.2;
}
.btn-primary {
  background: linear-gradient(135deg, #1a73e8, #2b82ef);
  color: #fff;
  box-shadow: 0 4px 12px rgba(26,115,232,.3);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: var(--primary-soft); color: var(--primary-dark); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #ccfbf1; color: var(--success); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled], .btn.is-loading {
  opacity: .72;
  pointer-events: none;
  cursor: wait;
}

/* 提交报销上传进度 */
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, .48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.upload-overlay-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
  text-align: center;
}
.upload-overlay-title {
  font-size: 16px;
  font-weight: 700;
  color: #153e75;
  margin-bottom: 6px;
}
.upload-overlay-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  min-height: 1.4em;
  word-break: break-all;
}
.upload-progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eef7;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #1a73e8, #4f9cf7);
  transition: width .15s ease-out;
}
.upload-progress-bar.is-indeterminate {
  width: 40% !important;
  animation: upload-indeterminate 1.1s ease-in-out infinite;
}
@keyframes upload-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}
.upload-progress-pct {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #153e75;
}

/* ========== Table ========== */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th,
table.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  background: #f5f9ff;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}
table.data-table tr:hover td { background: #fafcff; }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 42px; margin-bottom: 10px; opacity: .5; }

/* ========== Badge ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.pending { background: #fef3c7; color: #b45309; }
.badge.processing { background: #dbeafe; color: #1d4ed8; }
.badge.done { background: #ccfbf1; color: #0f766e; }
.badge.rejected { background: #fee2e2; color: #b91c1c; }
.badge.priority-high { background: #fee2e2; color: #b91c1c; }
.badge.priority-mid { background: #e0e7ff; color: #3730a3; }
.badge.priority-low { background: #f1f5f9; color: #64748b; }

/* ========== Alert ========== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ========== Ticket detail ========== */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.meta-item {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.meta-item .k { font-size: 12px; color: #94a3b8; }
.meta-item .v { font-size: 14px; margin-top: 4px; font-weight: 500; }

.form-data-list { margin-top: 8px; }
.form-data-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.form-data-item .label {
  width: 120px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.form-data-item .value { flex: 1; font-size: 14px; word-break: break-word; }
.form-data-item img {
  max-width: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 4px;
}
.image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.image-gallery a {
  display: block;
}
.image-gallery img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  max-width: none;
  margin-top: 0;
  transition: transform .15s, box-shadow .15s;
}
.image-gallery img:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(26,115,232,.18);
}
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-images {
  margin-top: 8px;
}
.chat-images img {
  width: 110px;
  height: 110px;
}

/* Chat */
.chat-box {
  background: #f7faff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.chat-item {
  display: flex;
  margin-bottom: 14px;
  gap: 10px;
}
.chat-item.admin { flex-direction: row-reverse; }
.chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.chat-item.admin .chat-avatar { background: #dbeafe; color: #1d4ed8; }
.chat-bubble {
  max-width: 70%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
}
.chat-item.admin .chat-bubble {
  background: #e8f0fe;
  border-color: #c5d9f7;
}
.chat-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.chat-content { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}
.page-link {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
}
.page-link.active, .page-link:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Admin sidebar layout */
.admin-layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  color: #475569;
  font-size: 14px;
  margin-bottom: 4px;
  transition: .2s;
}
.sidebar a:hover, .sidebar a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.admin-main { flex: 1; padding: 24px; min-width: 0; }

.field-builder-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 80px 60px 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filters .form-control { width: auto; min-width: 140px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 10px; gap: 4px; }
  .sidebar a { white-space: nowrap; margin-bottom: 0; }
  .field-builder-row { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 12px; height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .topbar nav { flex-wrap: wrap; }
  .chat-bubble { max-width: 85%; }
}
