/* === Icon === */
.icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
  stroke: currentColor;
}
.icon--inline { vertical-align: -2px; }

/* === Reset & 基础 === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 16px 0; }

/* === 通用工具类 === */
.text-muted { color: var(--color-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.ml-2 { margin-left: 8px; } .ml-3 { margin-left: 12px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* === Card === */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__sub { color: var(--color-muted); font-size: 13px; }

/* === Stat Card === */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stat-card__label { color: var(--color-muted); font-size: 13px; margin-bottom: 6px; }
.stat-card__value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}
.stat-card__icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 18px;
  flex-shrink: 0;
}
.stat-card__icon .icon { vertical-align: 0; }
.stat-card--success .stat-card__icon { background: var(--color-success-light); color: var(--color-success); }
.stat-card--warning .stat-card__icon { background: var(--color-warning-light); color: var(--color-warning); }
.stat-card--danger .stat-card__icon { background: var(--color-danger-light); color: var(--color-danger); }

/* === Button === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--color-text);
  user-select: none;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--lg { height: 42px; padding: 0 22px; font-size: 15px; }

.btn--primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn--primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

.btn--secondary { background: #fff; color: var(--color-text-soft); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-muted-light); }

.btn--ghost { background: transparent; color: var(--color-primary); border-color: transparent; padding: 0 8px; }
.btn--ghost:hover { background: var(--color-primary-light); }

.btn--danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn--danger-ghost { background: transparent; color: var(--color-danger); border-color: transparent; padding: 0 8px; }
.btn--danger-ghost:hover { background: var(--color-danger-light); }

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--color-muted-light);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  font-weight: 500;
  line-height: 1.6;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-muted);
}
.badge--success { background: var(--color-success-light); color: var(--color-success); border-color: transparent; }
.badge--success::before { background: var(--color-success); }
.badge--warning { background: var(--color-warning-light); color: var(--color-warning); border-color: transparent; }
.badge--warning::before { background: var(--color-warning); }
.badge--danger { background: var(--color-danger-light); color: var(--color-danger); border-color: transparent; }
.badge--danger::before { background: var(--color-danger); }
.badge--primary { background: var(--color-primary-light); color: var(--color-primary); border-color: transparent; }
.badge--primary::before { background: var(--color-primary); }

/* === Form === */
.form-field { display: block; margin-bottom: 16px; }
.form-field > label { display: block; color: var(--color-muted); font-size: 12px; margin-bottom: 6px; }
.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field input[type="search"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field select,
.form-field textarea,
input[type="text"].input,
input[type="number"].input,
input[type="search"].input,
input[type="email"].input,
input[type="password"].input,
select.input,
textarea.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 14px;
  color: var(--color-text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-field textarea, textarea.input { height: auto; padding: 8px 12px; resize: vertical; min-height: 80px; line-height: 1.6; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-field input:disabled, .form-field select:disabled { background: var(--color-muted-light); color: var(--color-muted); cursor: not-allowed; }
.form-help { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }
.form-required::after { content: ' *'; color: var(--color-danger); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  vertical-align: middle;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  transition: .15s;
  border-radius: 22px;
}
.switch__slider::before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 2px; top: 2px;
  background: #fff;
  transition: .15s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .switch__slider { background: var(--color-primary); }
.switch input:checked + .switch__slider::before { transform: translateX(18px); }

/* === Table === */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}
.table th { background: var(--color-muted-light); color: var(--color-muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbff; }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; text-align: right; }
.table .actions { display: inline-flex; gap: 4px; }
.table .row-warning td { background: var(--color-warning-light) !important; }
.table .row-warning td:first-child { box-shadow: inset 3px 0 0 0 var(--color-warning); }

/* === FilterBar === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-bar .form-field { margin-bottom: 0; min-width: 160px; flex: 1 1 160px; }
.filter-bar__actions { display: flex; gap: 8px; align-items: flex-end; }

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-top: 0;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  font-size: 13px;
  color: var(--color-muted);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a, .pagination .pages span {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-soft);
  background: #fff;
}
.pagination .pages a:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.pagination .pages .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .pages .disabled { color: var(--color-muted); background: var(--color-muted-light); cursor: not-allowed; }

/* === Drawer === */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 999;
  display: none;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 720px; max-width: 95vw;
  background: #fff;
  z-index: 1000;
  box-shadow: -4px 0 12px rgba(0,0,0,.06);
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-mask.is-open { display: block; }
.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.drawer__title { font-weight: 600; font-size: 15px; }
.drawer__close { cursor: pointer; color: var(--color-muted); border: 0; background: transparent; font-size: 20px; }
.drawer__body { flex: 1; overflow: auto; padding: 20px; }
.drawer__footer { padding: 12px 20px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; justify-content: flex-end; }

/* === Modal === */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-mask.is-open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal__header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.modal__title { font-weight: 600; font-size: 15px; }
.modal__close { cursor: pointer; color: var(--color-muted); border: 0; background: transparent; font-size: 20px; }
.modal__body { padding: 20px; overflow: auto; }
.modal__footer { padding: 12px 20px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; justify-content: flex-end; }

/* === Flash === */
.flash {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 2000;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  min-width: 240px;
  text-align: center;
}
.flash--success { border-color: var(--color-success); color: var(--color-success); background: var(--color-success-light); }
.flash--error { border-color: var(--color-danger); color: var(--color-danger); background: var(--color-danger-light); }
.flash--info { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-light); }

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 20px; margin: 0; font-weight: 600; }
.page-header .actions { display: flex; gap: 8px; }

/* === Login === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15,23,42,.08);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .muted { color: var(--color-muted); font-size: 13px; margin-bottom: 28px; }
.login-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.login-tab {
  flex: 1; text-align: center; padding: 8px; cursor: pointer;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-size: 13px; color: var(--color-muted); background: #fff;
}
.login-tab.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* === KV List === */
.kv { display: grid; grid-template-columns: 110px 1fr; row-gap: 8px; column-gap: 12px; font-size: 13px; }
.kv > dt { color: var(--color-muted); }
.kv > dd { margin: 0; color: var(--color-text); }

/* === Empty === */
.empty {
  text-align: center;
  color: var(--color-muted);
  padding: 32px 16px;
  font-size: 13px;
}

/* === 提示卡片 === */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
}
.notice--info { background: var(--color-primary-light); color: var(--color-primary); border-color: transparent; }
.notice--warning { background: var(--color-warning-light); color: var(--color-warning); border-color: transparent; }
.notice--danger { background: var(--color-danger-light); color: var(--color-danger); border-color: transparent; }
.notice--success { background: var(--color-success-light); color: var(--color-success); border-color: transparent; }

/* === Chat 工单 === */
.chat { display: flex; flex-direction: column; gap: 12px; }
.chat__msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.chat__msg--in { background: var(--color-muted-light); align-self: flex-start; }
.chat__msg--out { background: var(--color-primary); color: #fff; align-self: flex-end; }
.chat__meta { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.chat__msg--out + .chat__meta { text-align: right; }

/* === 通用响应式网格（替代视图中行内的 grid-template-columns）=== */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-side-340 { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
.grid-side-360 { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }
.grid-2-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* === 移动端汉堡按钮 === */
.nav-toggle {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--color-text-soft);
}
.nav-toggle:hover { color: var(--color-primary); border-color: var(--color-primary); }
.sidebar-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 49;
}
.sidebar-mask.is-open { display: block; }

/* === 响应式断点 === */

/* 平板：< 1100px 已在 admin.css/dealer.css 处理（侧栏收成 60px） */

/* 中小屏：< 900px */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2-1, .grid-side-340, .grid-side-360, .grid-2-cols { grid-template-columns: 1fr; }
  .filter-bar .form-field { flex: 1 1 100%; min-width: 100%; }
  .content { padding: 16px; }
  .page-header h1 { font-size: 18px; }
  .stat-card__value { font-size: 18px; }
}

/* 小屏 / 手机：< 640px */
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0,0,0,.1);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__brand, .sidebar__group-title, .sidebar__item span { display: inline !important; }
  .sidebar__item { justify-content: flex-start !important; padding: 10px 18px !important; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar__right { gap: 10px; font-size: 12px; flex-wrap: wrap; }
  .topbar__search { width: 100%; max-width: none; order: 99; }
  .stat-grid { grid-template-columns: 1fr; gap: 12px; }
  .stat-card { padding: 14px 16px; }
  .stat-card__value { font-size: 20px; }
  .content { padding: 12px; }
  .card { padding: 16px; }
  .filter-bar { padding: 12px; }
  .filter-bar__actions { width: 100%; }
  .filter-bar__actions .btn { flex: 1; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1; min-width: 0; }
  .modal { width: 100%; border-radius: 12px 12px 0 0; align-self: flex-end; max-height: 92vh; }
  .modal-mask { align-items: flex-end; }
  .drawer { width: 100%; max-width: 100vw; }
  .pagination { flex-direction: column; gap: 8px; }
  .login-card { padding: 24px 20px; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; }
  .kv { grid-template-columns: 90px 1fr; }
  .stat-card__icon { width: 38px; height: 38px; }
  .page-header { gap: 8px; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1; }
}
