/* 油耗记录 - 全局样式（移动端优先，配色丰富） */
:root {
  --primary: #3b6ef0;
  --primary-dark: #2a52c0;
  --accent: #ff8c42;
  --bg: #f2f5fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #7a8290;
  --border: #e4e9f2;
  --green: #27ae60;
  --orange: #e67e22;
  --red: #e74c3c;
  --purple: #8e5bd8;
  --shadow: 0 3px 12px rgba(40, 60, 120, 0.08);
  --grad-blue: linear-gradient(135deg, #4b7bec, #3867d6);
  --grad-orange: linear-gradient(135deg, #ff9f43, #ee5253);
  --grad-green: linear-gradient(135deg, #26de81, #20bf6b);
  --grad-purple: linear-gradient(135deg, #a55eea, #8854d0);
  --topbar-bg: var(--grad-blue);
  --page-bg: #f2f5fb;
  --input-bg: #ffffff;
}

/* ===== 深色科技风主题 ===== */
[data-theme="dark"] {
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --accent: #22d3ee;
  --bg: #0a0e1a;
  --page-bg: #0a0e1a;
  --card: rgba(20, 28, 48, 0.72);
  --text: #e6ecff;
  --muted: #8b96b5;
  --border: rgba(120, 160, 255, 0.18);
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
  --purple: #c084fc;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  --grad-blue: linear-gradient(135deg, #1e3a8a, #0ea5e9);
  --grad-orange: linear-gradient(135deg, #f97316, #db2777);
  --grad-green: linear-gradient(135deg, #059669, #10b981);
  --grad-purple: linear-gradient(135deg, #7c3aed, #a855f7);
  --topbar-bg: linear-gradient(135deg, #0f1830, #16233f);
  --input-bg: rgba(12, 18, 34, 0.6);
}

/* 深色：科技感网格 + 光晕背景 */
[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(168, 85, 247, 0.12), transparent 55%),
    linear-gradient(180deg, #0a0e1a, #070a12);
  background-attachment: fixed;
}
[data-theme="dark"] body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), transparent 70%);
}
[data-theme="dark"] .app { position: relative; z-index: 1; }
/* 深色：卡片玻璃拟态 + 发光边框 */
[data-theme="dark"] .card {
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.02);
}
[data-theme="dark"] .topbar {
  border-bottom: 1px solid rgba(56,189,248,0.25);
  box-shadow: 0 0 20px rgba(56,189,248,0.15);
}
[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea { background: var(--input-bg); color: var(--text); }
[data-theme="dark"] .chip { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .segment { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .segment button.active { background: rgba(56,189,248,0.16); }
[data-theme="dark"] .tabbar { background: rgba(10,14,26,0.92); border-top: 1px solid var(--border); }
[data-theme="dark"] .month-head { background: transparent; }
/* 深色：仪表盘卡片霓虹发光 */
[data-theme="dark"] .dash-card { box-shadow: 0 0 18px rgba(0,0,0,0.4), 0 0 22px rgba(56,189,248,0.12); }
[data-theme="dark"] .dash-card .dc-value { text-shadow: 0 0 12px rgba(255,255,255,0.25); }
[data-theme="dark"] .hero { box-shadow: 0 0 30px rgba(56,189,248,0.25); }
[data-theme="dark"] .hero .h-main { text-shadow: 0 0 18px rgba(56,189,248,0.5); }
[data-theme="dark"] .result { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .rec-metrics .m .mv, [data-theme="dark"] .rec-odo { text-shadow: 0 0 8px rgba(56,189,248,0.2); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
}

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* 顶部栏（渐变） */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar-bg); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.topbar .user { font-size: 13px; opacity: 0.95; }

.content { flex: 1; padding: 16px; padding-bottom: 80px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: 14px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 6px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field label .req { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,110,240,0.12);
}
.field textarea { resize: vertical; min-height: 56px; }
.field .calc-hint { font-size: 12px; color: var(--primary); margin-top: 4px; }
.row { display: flex; gap: 12px; }
.row > .field { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 13px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; background: #fff; cursor: pointer; user-select: none;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 按钮 */
.btn {
  display: inline-block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--grad-blue); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(56,103,214,0.3);
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #eef2fb; color: var(--primary); box-shadow: none; }
.btn.danger { background: var(--grad-orange); box-shadow: 0 4px 12px rgba(238,82,83,0.3); }
.btn.small { width: auto; padding: 9px 16px; font-size: 14px; }
.btn-row { display: flex; gap: 12px; }

.result {
  margin-top: 14px; padding: 14px; border-radius: 10px; border-left: 4px solid var(--muted);
  background: #f7f9fc; font-size: 14px;
}
.result .big { font-size: 22px; font-weight: 700; }

.msg { font-size: 13px; margin-top: 10px; }
.msg.error { color: var(--red); }
.msg.success { color: var(--green); }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ===== 统计仪表盘卡片 ===== */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dash-card {
  border-radius: 14px; padding: 16px; color: #fff; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.dash-card .dc-icon { position: absolute; right: 10px; top: 8px; font-size: 34px; opacity: 0.28; }
.dash-card .dc-label { font-size: 12px; opacity: 0.92; }
.dash-card .dc-value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.dash-card .dc-unit { font-size: 12px; opacity: 0.9; margin-left: 3px; font-weight: 400; }
.dc-blue { background: var(--grad-blue); }
.dc-orange { background: var(--grad-orange); }
.dc-green { background: var(--grad-green); }
.dc-purple { background: var(--grad-purple); }
.dc-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.dc-pink { background: linear-gradient(135deg, #f472b6, #db2777); }
.dash-wide { grid-column: 1 / -1; }

/* 大号平均油耗展示 */
.hero {
  background: var(--grad-blue); color: #fff; border-radius: 16px; padding: 22px 18px;
  text-align: center; box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero .h-plate { font-size: 13px; opacity: 0.9; }
.hero .h-main { font-size: 44px; font-weight: 800; line-height: 1.1; margin: 8px 0 2px; }
.hero .h-sub { font-size: 13px; opacity: 0.92; }

/* ===== 明细列表 ===== */
.month-head {
  position: sticky; top: 56px; background: var(--bg);
  font-size: 14px; font-weight: 700; color: var(--primary-dark);
  padding: 10px 2px 8px; z-index: 1;
}
.rec-card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.rec-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.rec-odo { font-size: 20px; font-weight: 800; }
.rec-odo small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.rec-date { font-size: 12px; color: var(--muted); }
.rec-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.rec-metrics .m { text-align: left; }
.rec-metrics .m .mv { font-size: 15px; font-weight: 700; }
.rec-metrics .m .ml { font-size: 11px; color: var(--muted); }
.rec-date-big { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.rec-states { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rec-metrics-3 { grid-template-columns: repeat(3, 1fr) !important; }
.rec-sub { display: flex; align-items: center; gap: 12px; font-size: 13px; padding-top: 8px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.rec-sub .trip { color: #444; }
.rec-sub .cons { font-weight: 700; }
.rec-sub .cons.ok { color: var(--green); }
.rec-sub .cons.na { color: var(--muted); }
.rec-sub .rec-act-inline { margin-left: auto; display: flex; gap: 14px; }
.rec-sub .rec-act-inline button { border: none; background: none; font-size: 13px; cursor: pointer; padding: 0; }
.rec-sub .rec-act-inline .edit { color: var(--primary); }
.rec-sub .rec-act-inline .del { color: var(--red); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; color: #fff; font-weight: 600; }
.tag-fuel { padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.rec-actions2 { display: flex; gap: 14px; margin-top: 10px; }
.rec-actions2 button { border: none; background: none; font-size: 13px; cursor: pointer; padding: 0; }
.rec-actions2 .edit { color: var(--primary); }
.rec-actions2 .del { color: var(--red); }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 640px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--border); display: flex; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar a { flex: 1; text-align: center; padding: 9px 0 7px; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabbar a .ic { display: block; font-size: 20px; line-height: 1.15; }
.tabbar a.active { color: var(--primary); }

/* 图表分段 / 时间导航 */
.segment { display: flex; background: #eaeff8; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segment button { flex: 1; border: none; background: none; padding: 9px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--muted); }
.segment button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.custom-range { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.custom-range .cr-field { flex: 1; }
.custom-range .cr-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.custom-range .cr-field input { width: 100%; padding: 9px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
.period-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.period-nav button { width: 40px; height: 36px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 22px; line-height: 1; color: var(--primary); cursor: pointer; }
.period-nav button:disabled { color: #ccc; }
.period-nav #range-title { flex: 1; text-align: center; font-size: 15px; font-weight: 700; }

/* 登录页 */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #4b7bec, #3867d6 60%, #8854d0); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 30px 24px; box-shadow: 0 12px 34px rgba(0,0,0,0.25); }
.auth-card .logo { text-align: center; font-size: 46px; margin-bottom: 4px; }
.auth-card h1 { text-align: center; font-size: 21px; margin: 0 0 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-tabs button { flex: 1; border: none; background: none; padding: 10px; font-size: 15px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.auth-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #444; margin-bottom: 14px; }
.checkbox-row input { width: auto; }

/* 深色：登录页科技风 */
[data-theme="dark"] .auth-wrap {
  background:
    radial-gradient(800px 500px at 20% 0%, rgba(56,189,248,0.25), transparent 55%),
    radial-gradient(700px 500px at 100% 100%, rgba(168,85,247,0.22), transparent 55%),
    linear-gradient(160deg, #0a0e1a, #0d1428 60%, #131a33);
}
[data-theme="dark"] .auth-card {
  background: rgba(18, 26, 46, 0.82);
  border: 1px solid rgba(56,189,248,0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 40px rgba(56,189,248,0.15);
}
[data-theme="dark"] .auth-card .logo { text-shadow: 0 0 20px rgba(56,189,248,0.6); }
[data-theme="dark"] .btn { box-shadow: 0 4px 16px rgba(14,165,233,0.4); }
