/* ==================== Reset & Variables ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1890FF;
  --primary-light: #E6F7FF;
  --success: #52C41A;
  --warning: #FA8C16;
  --danger: #FF4D4F;
  --text: #333333;
  --text-secondary: #666666;
  --text-hint: #999999;
  --border: #EBEBEB;
  --bg: #F5F5F5;
  --white: #FFFFFF;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 20px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
}
.desktop #app {
  max-width: none;
  padding: 0 16px;
}
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ==================== Nav Bar ==================== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
}
.nav-title { flex: 1; text-align: center; font-size: 34px; font-weight: 600; }
.nav-left, .nav-right { width: 48px; font-size: 34px; cursor: pointer; }
.nav-left { text-align: left; }
.nav-right { text-align: right; }
.nav-back { cursor: pointer; font-size: 34px; }

/* ==================== 全局顶部导航（me.js 按角色渲染） ==================== */
.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}
.top-nav-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-right: 10px;
}
.top-nav-item {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.top-nav-item:hover { background: var(--bg); color: var(--text); }
.top-nav-item.active { background: var(--primary); color: #fff; }
.top-nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-nav-user { font-size: 12px; color: var(--text-hint); white-space: nowrap; }
.top-nav-logout { font-size: 12px; padding: 4px 12px; }

/* ==================== Tab Bar ==================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 4px;
  cursor: pointer;
  color: var(--text-hint);
  transition: color 0.2s;
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 26px; }
.tab-text { font-size: 12px; margin-top: 2px; }

/* ==================== Main Content ==================== */
.main-content {
  padding-bottom: 20px;
  min-height: 100vh;
}

/* ==================== Cards ==================== */
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  margin: 16px 16px;
  box-shadow: var(--shadow);
}

/* ==================== Vehicle Card ==================== */
.vehicle-card { cursor: pointer; transition: transform 0.15s; }
.vehicle-card:active { transform: scale(0.98); }

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.plate-number {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.plate-number::before {
  content: '';
  display: inline-block;
  width: 4px; height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

.vehicle-info { font-size: 24px; color: var(--text-secondary); line-height: 1.8; }
.vehicle-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 34px;
  color: var(--text-hint);
}
.btn-sm {
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-sm:active { opacity: 0.8; }
.btn-sm-primary { background: var(--primary); color: #fff; }
.btn-sm-primary:disabled { background: #A0CFFF; color: rgba(255,255,255,.7); }
.btn-sm-disabled { background: #ccc; color: #fff; }

/* ==================== Tags ==================== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
}
.tag-idle { background: #F0FFF4; color: #38A169; }
.tag-in_use { background: #FFF8F0; color: #DD6B20; }
.tag-maintenance { background: #FFF0F0; color: #E53E3E; }
.tag-active { background: #FFF8F0; color: #DD6B20; }
.tag-finished { background: #F0FFF4; color: #38A169; }
.tag-overdue { background: #FFF0F0; color: #E53E3E; }

/* ==================== Form ==================== */
.form-group { margin-bottom: 24px; }
.form-label { font-size: 20px; font-weight: 700; margin-bottom: 6px; display: flex; }
.form-label .required { color: var(--danger); margin-right: 2px; }
.form-input, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #F7F8FA;
  transition: border 0.2s;
  font-family: inherit;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-input.error, .form-textarea.error { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: 34px; margin-top: 4px; }
.form-input:disabled { background: #eee; color: var(--text-hint); }

/* ==================== Buttons ==================== */
.btn {
  display: block;
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  letter-spacing: 1px;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { background: #A0CFFF; color: rgba(255,255,255,.7); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:disabled { background: #FFB8B8; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-cancel { background: #F5F5F5; color: var(--text); }

/* ==================== Filter Tabs ==================== */
.filter-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 15px;
  background: #F5F5F5;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.filter-tab.active { background: var(--primary); color: #fff; }

/* ==================== Records ==================== */
.record-card { padding: 14px 16px; }
.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.record-plate { font-size: 34px; font-weight: 600; }
.record-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 20px; color: var(--text-secondary); line-height: 2; }
.record-body span { margin-right: 4px; opacity: 0.5; }
.record-footer { text-align: right; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ==================== Detail Page ==================== */
.detail-section { margin-bottom: 16px; }
.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 0; }
.info-item { font-size: 24px; }
.info-item .label { color: var(--text-hint); display: block; font-size: 34px; margin-bottom: 2px; }
.info-item .value { color: var(--text); }

.qr-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: 8px;
  margin-top: 16px;
}
.qr-icon { font-size: 24px; }
.qr-text { font-size: 26px; color: var(--primary); font-weight: 500; }

.record-mini { padding: 10px 0; border-bottom: 1px solid #f5f5f5; font-size: 24px; }
.record-mini:last-child { border-bottom: none; }

/* ==================== Mine Page ==================== */
.user-card {
  background: linear-gradient(135deg, #1890FF 0%, #096DD9 100%);
  color: #fff;
  padding: 24px 20px;
}
.user-info-row { display: flex; align-items: center; gap: 14px; }
.user-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.user-name { font-size: 24px; font-weight: 600; }
.user-dept { font-size: 24px; opacity: 0.85; }
.user-stats {
  display: flex;
  margin-top: 20px;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 12px 0;
}
.stat-item { flex: 1; text-align: center; }
.stat-num { font-size: 30px; font-weight: 700; }
.stat-label { font-size: 20px; opacity: 0.8; }
.stat-divider { width: 1px; background: rgba(255,255,255,0.2); }

.menu-section { margin: 12px 16px; }
.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  font-size: 30px;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #f9f9f9; }
.menu-icon { margin-right: 12px; font-size: 24px; }
.menu-arrow { margin-left: auto; color: #ccc; }

.section-label { font-size: 34px; color: var(--text-hint); padding: 8px 0 4px; }

/* ==================== Search ==================== */
.search-bar {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-input {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: var(--white);
  font-size: 26px;
}
.search-input:focus { outline: 2px solid var(--primary); }
.search-icon-btn { font-size: 24px; cursor: pointer; padding: 4px; }

/* ==================== Location ==================== */
.location-picker {
  background: #F7F8FA;
  border-radius: 8px;
  padding: 12px;
}
.location-text {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 26px;
}
.location-actions { display: flex; gap: 8px; }
.location-btn {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  font-size: 24px;
  cursor: pointer;
}
.location-btn.primary { background: var(--primary); color: #fff; }
.location-btn.outline { border: 1px solid var(--primary); color: var(--primary); }

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 26px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* ==================== Bottom Bar ==================== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 99;
}

/* ==================== Empty ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-hint);
}
.empty-icon { font-size: 60px; opacity: 0.4; }
.empty-text { font-size: 26px; margin-top: 12px; }

/* ==================== Loading ==================== */
.loading { text-align: center; padding: 20px; color: var(--text-hint); font-size: 24px; }
.loading-more { text-align: center; padding: 16px; color: var(--text-hint); font-size: 34px; }

/* ==================== Notice ==================== */
.notice {
  background: #FFFBE6;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 34px;
  color: #D48806;
  line-height: 1.8;
}
.notice-title { font-weight: 600; font-size: 26px; margin-bottom: 4px; }

/* ==================== Responsive ==================== */
@media (min-width: 481px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* Print */
@media print {
  #qrSearch, #qrPrint, #qrBack, .btn-cancel, button, .form-group, .nav-bar, .tab-bar { display: none !important; }
  .card { box-shadow: none; margin: 0; padding: 8px; }
  body { background: #fff; }
}

/* Utility */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
