/* =========================================================
   车辆租赁管理系统 — UI Design System v2
   纯 CSS / 零依赖 · 设计 Token 驱动 · 保留全部旧类名
   方向：现代靛蓝 + 中性灰 · 柔和阴影 · 8pt 间距 · 微交互
   ========================================================= */

:root {
  /* —— 品牌主色（靛蓝）—— */
  --primary-50:  #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;   /* 主色 */
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;

  /* —— 中性色 —— */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;
  --white:   #ffffff;

  /* —— 语义色 —— */
  --green-50: #ecfdf5; --green-500: #10b981; --green-600: #059669; --green-700: #047857;
  --red-50:   #fef2f2; --red-500:   #ef4444; --red-600:   #dc2626; --red-700:   #b91c1c;
  --amber-50: #fffbeb; --amber-500: #f59e0b; --amber-600: #d97706; --amber-700: #b45309;
  --sky-500:  #0ea5e9;

  /* —— 表面 —— */
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-ink: var(--ink-600);
  --sidebar-active-bg: var(--primary-50);

  --line: var(--ink-200);
  --line-soft: var(--ink-100);

  /* —— 文本 —— */
  --text:       var(--ink-900);
  --text-soft:  var(--ink-600);
  --text-muted: var(--ink-500);

  /* —— 阴影层级 —— */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px -2px rgba(15,23,42,.08), 0 2px 6px -2px rgba(15,23,42,.05);
  --shadow-lg: 0 16px 40px -12px rgba(15,23,42,.18), 0 6px 16px -8px rgba(15,23,42,.10);
  --shadow-focus: 0 0 0 4px rgba(99,102,241,.16);

  /* —— 圆角 —— */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  /* —— 间距（8pt 网格）—— */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* —— 动效 —— */
  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: 120ms var(--ease);
  --t-normal: 200ms var(--ease);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--primary-50), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #f0fdfa, transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary-600); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-700); text-decoration: none; }

/* 线性 SVG 图标（统一描边，随文字色变色） */
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.ic { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: 0 0 248px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  box-shadow: var(--shadow-sm);
}
.sidebar .brand {
  height: 66px; display: flex; align-items: center; gap: 12px;
  padding: 0 22px; font-size: 16px; font-weight: 700; color: var(--ink-900);
  letter-spacing: .2px; border-bottom: 1px solid var(--line-soft);
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: 0 4px 10px -2px rgba(99,102,241,.5);
}
.sidebar nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  color: var(--sidebar-ink); font-size: 14px; font-weight: 500;
  border-radius: var(--r-sm); position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar nav a:hover { background: var(--ink-100); color: var(--ink-900); text-decoration: none; }
.sidebar nav a.active {
  background: var(--sidebar-active-bg); color: var(--primary-700); font-weight: 600;
}
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: var(--r-full); background: var(--primary-500);
}
.sidebar nav a .ic {
  width: 20px; height: 20px; flex: 0 0 20px; color: var(--ink-400);
  transition: color var(--t-fast), transform var(--t-fast);
}
.sidebar nav a:hover .ic { color: var(--ink-700); transform: scale(1.08); }
.sidebar nav a.active .ic { color: var(--primary-600); }

.main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 66px; background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar .menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.topbar .title { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--text-soft); }
.topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700;
  box-shadow: var(--shadow-sm);
}
.content { padding: var(--s-6); max-width: 1440px; width: 100%; }

/* ============ 移动遮罩 ============ */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px); z-index: 35;
}
.overlay.show { display: block; }

/* ============ 卡片 / 统计 ============ */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--s-4); margin-bottom: var(--s-6);
}
.card {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--line-soft);
  transition: transform var(--t-normal), box-shadow var(--t-normal);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card::after {
  content:""; position:absolute; inset:0 0 auto 0; height:3px;
  background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
  opacity:0; transition: opacity var(--t-normal);
}
.card:hover::after { opacity: 1; }
.card .label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.card .value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.5px; }
.card .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.card.accent-blue   { /* 顶部细色条 */ }
.card.accent-blue::before,
.card.accent-green::before,
.card.accent-orange::before,
.card.accent-red::before {
  content:""; position:absolute; left:0; right:0; top:0; height:3px;
}
.card.accent-blue::before   { background: linear-gradient(90deg,var(--primary-400),var(--primary-600)); }
.card.accent-green::before  { background: linear-gradient(90deg,#34d399,var(--green-600)); }
.card.accent-orange::before { background: linear-gradient(90deg,#fbbf24,var(--amber-600)); }
.card.accent-red::before    { background: linear-gradient(90deg,#f87171,var(--red-600)); }

/* ============ 面板 ============ */
.panel {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  border: 1px solid var(--line-soft); margin-bottom: var(--s-6); overflow: hidden;
}
.panel-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  background: linear-gradient(180deg, #fff, var(--ink-50));
}
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.panel-body { padding: 20px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data th, table.data td {
  padding: 13px 14px; text-align: left;
  border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
table.data th {
  background: var(--ink-50); color: var(--text-soft);
  font-weight: 600; font-size: 12.5px; letter-spacing: .3px; text-transform: none;
  position: sticky; top: 0;
}
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--primary-50); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.actions a { margin-right: 10px; font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--text-muted); }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  line-height: 1.5;
}
.badge-green  { background: var(--green-50); color: var(--green-700); }
.badge-red    { background: var(--red-50);   color: var(--red-700); }
.badge-orange { background: var(--amber-50); color: var(--amber-700); }
.badge-gray   { background: var(--ink-100);  color: var(--ink-600); }
.badge-blue   { background: var(--primary-50); color: var(--primary-700); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 600;
  font-family: inherit; line-height: 1.4;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--ink-50); border-color: var(--ink-300); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #fff; border-color: transparent; box-shadow: 0 4px 12px -4px rgba(79,70,229,.6);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-600), var(--primary-700)); color:#fff; }
.btn-danger { background: var(--surface); color: var(--red-600); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-50); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-link { border: none; background: none; padding: 0; color: var(--primary-600); cursor: pointer; font-size: 13.5px; }
.btn-link:hover { color: var(--primary-700); }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.form-group .req::after { content: " *"; color: var(--red-500); }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
  width: 100%; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-300); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary-500); box-shadow: var(--shadow-focus);
}

/* ============ 预警横幅 ============ */
.alert-banner {
  border-radius: var(--r-md); padding: 13px 18px; margin-bottom: var(--s-5);
  display: flex; align-items: center; gap: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.alert-banner.urgent { background: var(--red-50); color: var(--red-700); border-color: #fecaca; }
.alert-banner.warning { background: var(--amber-50); color: var(--amber-700); border-color: #fde68a; }
.alert-banner.ok { background: var(--green-50); color: var(--green-700); border-color: #a7f3d0; }
.alert-banner .ic { font-size: 18px; }

/* ============ 筛选条 ============ */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(99,102,241,.18), transparent 55%),
    radial-gradient(800px 500px at 90% 90%, rgba(14,165,233,.16), transparent 55%),
    linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #1e3a8a 100%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-wrap::before {
  content:""; position:absolute; inset:0;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 22px 22px; opacity:.5;
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.6);
  width: 100%; max-width: 410px; padding: 40px 34px;
  animation: cardIn .5s var(--ease) both;
}
@keyframes cardIn { from { opacity:0; transform: translateY(14px) scale(.98); } to { opacity:1; transform:none; } }
.login-card h1 { margin: 0 0 4px; font-size: 23px; letter-spacing: .2px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 800; letter-spacing: .3px; margin-bottom: 4px; }
.login-logo {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px -4px rgba(99,102,241,.6);
}
.login-card .sub { color: var(--text-muted); margin-bottom: 26px; font-size: 13.5px; }
.login-card .form-group { margin-bottom: 18px; }

/* ============ 提示 ============ */
.flash { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: var(--s-4); font-size: 13.5px; font-weight: 500; }
.flash-ok  { background: var(--green-50); color: var(--green-700); border: 1px solid #a7f3d0; }
.flash-err { background: var(--red-50);   color: var(--red-700);   border: 1px solid #fecaca; }

/* ============ 还款计划：批量操作 ============ */
.amt-input {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13px; background: var(--surface); color: var(--ink-900);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.amt-input:focus { outline: none; border-color: var(--primary-400); box-shadow: 0 0 0 3px var(--primary-100); }
.rowcheck, .checkall { width: 16px; height: 16px; accent-color: var(--primary-500); cursor: pointer; }
.panel-head .toolbar .btn-sm { margin-left: 6px; }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  /* 侧边栏变为抽屉：fixed 定位、默认移出视口左侧，展开时滑入并置顶 */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 232px; flex-basis: 232px;
    transform: translateX(-100%);
    transition: transform var(--t-normal);
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  /* 内容区在窄屏不再让出侧边栏宽度，并确保在侧边栏之下（点击不穿透） */
  .main { margin-left: 0; position: relative; z-index: 10; }
  .topbar .menu-btn { display: block; }
  .content { padding: var(--s-4); }
  /* 遮罩层级在侧边栏之下、内容之上 */
  .overlay { z-index: 45; }
}

/* ============ 统计中心：卡片 ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5);
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.5px; color: var(--ink-900); }
.stat-value.ok { color: var(--green-700); }
.stat-value.err { color: var(--red-700); }
.stat-sub { font-size: 12.5px; color: var(--text-muted); }

/* ============ 统计中心：键值行 ============ */
.kv {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--ink-50); border-radius: var(--r-md);
  font-size: 13.5px;
}
.kv span { color: var(--text-soft); font-weight: 500; }
.kv b { color: var(--ink-900); font-weight: 700; }
.kv b.ok { color: var(--green-700); }
.kv b.err { color: var(--red-700); }

/* ============ 通用辅助 ============ */
.muted { color: var(--text-muted); }
.row-paid { background: var(--green-50); }
.total-row td { font-weight: 700; background: var(--ink-50); border-top: 2px solid var(--line); }
