/* ====================================================================
   门票台账系统 · Apple HIG 设计系统
   ==================================================================== */

/* ============ 字体（SF Pro / PingFang）============ */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ============ 设计令牌（Light）============ */
:root, [data-theme="light"] {
  /* 系统色 */
  --sf-blue:       rgb(0, 122, 255);
  --sf-blue-2:     rgb(0, 102, 220);
  --sf-green:      rgb(52, 199, 89);
  --sf-orange:     rgb(255, 149, 0);
  --sf-red:        rgb(255, 59, 48);
  --sf-purple:     rgb(175, 82, 222);
  --sf-pink:       rgb(255, 45, 85);
  --sf-yellow:     rgb(255, 204, 0);

  /* 别名 */
  --primary:       var(--sf-blue);
  --primary-hover: var(--sf-blue-2);
  --success:       var(--sf-green);
  --warning:       var(--sf-orange);
  --danger:        var(--sf-red);
  --info:          var(--sf-blue);

  /* 文字 */
  --text-1: rgba(0, 0, 0, 0.88);
  --text-2: rgba(0, 0, 0, 0.60);
  --text-3: rgba(0, 0, 0, 0.40);
  --text-inverse: #fff;

  /* 背景 */
  --bg:          #ffffff;
  --bg-elev:     #ffffff;
  --bg-page:     #f5f5f7;     /* Apple 灰底 */
  --bg-active:   rgba(0, 0, 0, 0.04);
  --bg-hover:    rgba(0, 0, 0, 0.06);
  --bg-mask:     rgba(0, 0, 0, 0.45);
  --bg-toolbar:  rgba(255, 255, 255, 0.72);

  /* 边框 */
  --border:        rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
  --separator:     rgba(0, 0, 0, 0.06);

  /* 阴影 */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.02);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-3: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-pop: 0 16px 64px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;
}

/* ============ 设计令牌（Dark）============ */
[data-theme="dark"] {
  --sf-blue:       rgb(10, 132, 255);
  --sf-blue-2:     rgb(64, 156, 255);
  --sf-green:      rgb(48, 209, 88);
  --sf-orange:     rgb(255, 159, 10);
  --sf-red:        rgb(255, 69, 58);

  --text-1: rgba(255, 255, 255, 0.92);
  --text-2: rgba(255, 255, 255, 0.60);
  --text-3: rgba(255, 255, 255, 0.40);

  --bg:          #1c1c1e;
  --bg-elev:     #2c2c2e;
  --bg-page:     #000000;
  --bg-active:   rgba(255, 255, 255, 0.06);
  --bg-hover:    rgba(255, 255, 255, 0.10);
  --bg-mask:     rgba(0, 0, 0, 0.65);
  --bg-toolbar:  rgba(28, 28, 30, 0.72);

  --border:        rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --separator:     rgba(255, 255, 255, 0.08);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.40);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.50);
  --shadow-3: 0 8px 32px rgba(0,0,0,0.60);
  --shadow-pop: 0 16px 64px rgba(0,0,0,0.80);
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
code {
  padding: 1px 6px; border-radius: 4px;
  background: var(--bg-active); color: var(--text-1);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

h1,h2,h3,h4,h5 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); }
h2 { font-size: 22px; letter-spacing: -0.02em; }
h3 { font-size: 17px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success, .text-ok { color: var(--success); }
.text-warning, .text-warn { color: var(--warning); }
.text-danger { color: var(--danger); }

/* ============ 布局 ============ */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ============ 侧栏 ============ */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--separator);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; flex-shrink: 0;
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--sf-blue), var(--sf-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.brand-name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.menu { flex: 1; padding: 4px 10px 10px; }
.menu-group {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  padding: 14px 10px 6px; text-transform: uppercase; letter-spacing: 0.06em;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 1px;
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-1);
  cursor: pointer; transition: background .12s;
}
.menu-item:hover { background: var(--bg-active); text-decoration: none; }
.menu-item.active {
  background: var(--primary);
  color: var(--text-inverse);
}
.menu-item.active .ic svg { fill: currentColor; }
.menu-item .ic {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.menu-item .ic svg { width: 18px; height: 18px; fill: var(--text-2); }
.menu-item:hover .ic svg { fill: var(--text-1); }
.menu-item.active .ic svg { fill: var(--text-inverse); }

.user-card {
  padding: 10px; border-top: 1px solid var(--separator);
  flex-shrink: 0;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-sm);
}
.user-info:hover { background: var(--bg-active); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sf-blue), var(--sf-purple));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.user-name { font-size: 13.5px; font-weight: 500; }
.user-role { font-size: 11.5px; color: var(--text-2); }
.user-logout {
  display: block; margin-top: 4px; padding: 6px 8px;
  border-radius: var(--r-sm); font-size: 12.5px; text-align: center;
  color: var(--text-2);
}
.user-logout:hover {
  background: var(--bg-active); color: var(--danger); text-decoration: none;
}

/* ============ 顶部条 ============ */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; height: 52px;
  background: var(--bg-toolbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.topbar .page-title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  margin: 0; flex-shrink: 0;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.theme-toggle, .menu-toggle {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.theme-toggle:hover, .menu-toggle:hover { background: var(--bg-active); color: var(--text-1); }
.theme-toggle svg, .menu-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.menu-toggle { display: none; }

/* 全局搜索 */
.global-search {
  position: relative; flex: 1; max-width: 380px;
}
.global-search input {
  width: 100%; padding: 6px 12px 6px 32px; font-size: 13px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--bg-active); color: var(--text-1);
  font-family: inherit;
  transition: all .12s;
}
.global-search input:focus {
  outline: none; background: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}
.global-search::before {
  content: ''; position: absolute; left: 10px; top: 50%;
  width: 14px; height: 14px; transform: translateY(-50%);
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 1 0-.7.7l.27.28v.79l5 5 1.49-1.5zm-6 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 9.5 14'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 1 0-.7.7l.27.28v.79l5 5 1.49-1.5zm-6 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 9.5 14'/></svg>") center/contain no-repeat;
}
.global-search-result {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--separator);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  max-height: 60vh; overflow: auto; z-index: 100;
}
.gs-sec + .gs-sec { border-top: 1px solid var(--separator); }
.gs-sec-head {
  font-size: 11px; color: var(--text-3); padding: 10px 14px 4px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.gs-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 14px; text-decoration: none; color: inherit;
  border-left: 2px solid transparent;
}
.gs-item:hover { background: var(--bg-active); border-left-color: var(--primary); text-decoration: none; }
.gs-sub { width: 100%; }
.gs-empty { padding: 20px; text-align: center; color: var(--text-3); }

/* ============ 内容区 ============ */
.content {
  padding: 20px 24px;
  max-width: 1440px; width: 100%;
  margin: 0 auto;
}

/* ============ 卡片 ============ */
.card {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1px solid var(--separator);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }

/* 页头 */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.page-head h2 { font-size: 22px; margin: 0 0 4px; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 500;
  font-family: inherit; letter-spacing: -0.005em;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; transition: all .12s;
  user-select: none; white-space: nowrap;
  background: transparent; color: var(--text-1);
}
.btn:hover { text-decoration: none; }
.btn:focus { outline: none; }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(0,122,255,.25); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

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

.btn-ghost {
  background: var(--bg-active); color: var(--text-1);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-secondary {
  background: var(--bg); color: var(--primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-active); border-color: var(--primary); }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { background: var(--danger); filter: brightness(.92); }

.btn-link { background: transparent; color: var(--primary); padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; }

/* ============ 表单 ============ */
.input, .form-input, .form-select, .form-textarea, select, input[type=text],
input[type=number], input[type=date], input[type=password], input[type=email],
input[type=tel], textarea {
  width: 100%;
  padding: 7px 12px; font-size: 13.5px; line-height: 1.4;
  font-family: inherit; color: var(--text-1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: all .12s;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .form-input:focus, .form-select:focus, .form-textarea:focus,
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}
input[type=checkbox], input[type=radio] {
  width: auto; padding: 0; appearance: auto;
  margin-right: 6px; vertical-align: middle;
}

/* 下拉箭头 */
select, .form-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2399999c'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 30px;
}

textarea, .form-textarea { resize: vertical; min-height: 80px; }

.input-sm, .form-input-sm { padding: 4px 8px; font-size: 12.5px; border-radius: var(--r-xs); }

/* 表单行：水平排列 label + input */
.form-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.form-row > label, .form-row > .form-label {
  width: 88px; flex-shrink: 0; text-align: right;
  font-size: 13.5px; color: var(--text-2);
}
.form-row > .input, .form-row > select, .form-row > textarea, .form-row > .form-input,
.form-row > .form-select, .form-row > .form-textarea { flex: 1; }

/* 表单网格：紧凑多列 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 14px;
}
.form-grid .form-field { display: flex; flex-direction: column; gap: 4px; }
.form-grid .form-field label,
.form-grid .form-field .form-label {
  font-size: 12px; color: var(--text-2); font-weight: 500;
}
.form-grid .form-field .input,
.form-grid .form-field select { width: 100%; }

/* 内联表单（紧凑筛选条）*/
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 14px;
}
.filter-bar .input,
.filter-bar select { width: auto; min-width: 0; padding: 6px 10px; font-size: 13px; }
.filter-bar select { padding-right: 26px; }
.filter-bar input[type=date] { padding: 5px 10px; }
.filter-bar .check-inline {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text-2); padding: 4px 8px;
  border-radius: var(--r-sm); cursor: pointer; user-select: none;
}
.filter-bar .check-inline:hover { background: var(--bg-active); }

.check-inline {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; user-select: none;
}

.form-actions {
  display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end;
}

.form-textarea { font-size: 13px; }
.mt-2 { margin-top: 8px; }

/* ============ 表格 ============ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 9px 12px; text-align: left;
  border-bottom: 1px solid var(--separator);
  font-size: 13px;
}
.table th {
  font-weight: 500; color: var(--text-2);
  background: var(--bg-active);
  font-size: 12.5px;
  position: sticky; top: 0;
}
.table tr:hover td { background: var(--bg-active); }
.table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; margin: -6px -8px; padding: 6px 8px; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table .no-data { color: var(--text-3); text-align: center; padding: 30px 0; }

.table-compact th, .table-compact td { padding: 6px 8px; font-size: 12.5px; }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 500; line-height: 1.4;
  white-space: nowrap;
}
.badge-ok      { background: rgba(52,199,89,.12); color: var(--success); }
.badge-warn    { background: rgba(255,149,0,.12); color: var(--warning); }
.badge-info    { background: rgba(0,122,255,.12); color: var(--primary); }
.badge-danger  { background: rgba(255,59,48,.12); color: var(--danger); }
.badge-muted   { background: var(--bg-active);    color: var(--text-2); }
[data-theme="dark"] .badge-ok     { background: rgba(48,209,88,.18); }
[data-theme="dark"] .badge-warn   { background: rgba(255,159,10,.18); }
[data-theme="dark"] .badge-info   { background: rgba(10,132,255,.18); }
[data-theme="dark"] .badge-danger { background: rgba(255,69,58,.18); }

/* 席位徽章：按档次配色 */
.seat-class { font-weight: 600; }
.seat-class[data-v="商务座"] { background: rgba(175,82,222,.14); color: #af52de; }
.seat-class[data-v="一等座"] { background: rgba(255,149,0,.14);  color: var(--warning); }
.seat-class[data-v="二等座"] { background: rgba(0,122,255,.14);  color: var(--primary); }
.seat-class[data-v="无座"]   { background: var(--bg-active);     color: var(--text-2); }
.seat-class[data-v="硬座"]   { background: rgba(142,142,147,.18);color: #6e6e73; }
.seat-class[data-v="卧铺"]   { background: rgba(50,173,230,.14); color: #32ade6; }
.seat-class[data-v="软卧"]   { background: rgba(52,199,89,.14);  color: var(--success); }
[data-theme="dark"] .seat-class[data-v="商务座"] { background: rgba(175,82,222,.22); color: #d68bff; }
[data-theme="dark"] .seat-class[data-v="一等座"] { background: rgba(255,159,10,.20); color: #ffb84d; }
[data-theme="dark"] .seat-class[data-v="二等座"] { background: rgba(10,132,255,.20); color: #5eb1ff; }
[data-theme="dark"] .seat-class[data-v="无座"]   { background: rgba(142,142,147,.30); color: var(--text-2); }
[data-theme="dark"] .seat-class[data-v="硬座"]   { background: rgba(142,142,147,.30); color: #b0b0b8; }
[data-theme="dark"] .seat-class[data-v="卧铺"]   { background: rgba(50,173,230,.22);  color: #6dceff; }
[data-theme="dark"] .seat-class[data-v="软卧"]   { background: rgba(48,209,88,.22);   color: #6df09b; }

/* 票种徽章：成人/儿童/学生/残军 按语义配色 */
.pax-type { font-weight: 600; }
.pax-type[data-v="成人"], .pax-type[data-v="成人票"] { background: rgba(0,122,255,.12);  color: var(--primary); }
.pax-type[data-v="儿童"], .pax-type[data-v="儿童票"] { background: rgba(255,149,0,.14);  color: var(--warning); }
.pax-type[data-v="学生"], .pax-type[data-v="学生票"] { background: rgba(52,199,89,.14);  color: var(--success); }
.pax-type[data-v="残军"], .pax-type[data-v="残军票"] { background: rgba(175,82,222,.14); color: #af52de; }
[data-theme="dark"] .pax-type[data-v="成人"], [data-theme="dark"] .pax-type[data-v="成人票"] { background: rgba(10,132,255,.20);  color: #5eb1ff; }
[data-theme="dark"] .pax-type[data-v="儿童"], [data-theme="dark"] .pax-type[data-v="儿童票"] { background: rgba(255,159,10,.20);  color: #ffb84d; }
[data-theme="dark"] .pax-type[data-v="学生"], [data-theme="dark"] .pax-type[data-v="学生票"] { background: rgba(48,209,88,.20);   color: #6df09b; }
[data-theme="dark"] .pax-type[data-v="残军"], [data-theme="dark"] .pax-type[data-v="残军票"] { background: rgba(175,82,222,.22);  color: #d68bff; }

/* ============ 模态 ============ */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.show, .modal[style*="block"], .modal[style*="flex"] { display: flex; }
.modal-mask {
  position: absolute; inset: 0;
  background: var(--bg-mask);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal-body, .modal-card {
  position: relative; max-width: 520px; width: 100%;
  background: var(--bg-elev); border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
}
.modal-head h3 { font-size: 17px; font-weight: 600; margin: 0; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-active); border: 0; color: var(--text-2);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-1); }
.modal-content, .modal-card > *:not(.modal-head):not(.modal-actions) {
  padding: 0 20px; flex: 1; overflow: auto;
}
.modal-card { padding: 20px; }
.modal-card h3 { margin-bottom: 12px; }
.modal-actions, .modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 20px 16px; flex-shrink: 0;
}

/* ============ 统计卡片 ============ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--separator);
  border-radius: var(--r-lg); padding: 16px 18px;
  transition: all .15s;
}
.stat-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.stat-label {
  font-size: 12.5px; color: var(--text-2);
  font-weight: 500; margin-bottom: 6px;
}
.stat-value {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.1; color: var(--text-1);
}
.stat-extra { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }

/* ============ Toast ============ */
.toast-stack {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200; pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--separator);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  color: var(--text-1);
  pointer-events: auto;
  animation: toast-in .25s ease;
  max-width: 360px;
}
.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 分页 ============ */
.pager {
  display: flex; gap: 4px; justify-content: center; padding: 14px 0;
}
.pager .btn { padding: 4px 10px; min-width: 32px; }
.pager .btn.active {
  background: var(--primary); color: #fff;
}

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f5f5f7 0%, #e5e5ea 100%);
  padding: 20px;
}
[data-theme="dark"] .login-wrap {
  background: linear-gradient(135deg, #1c1c1e 0%, #000 100%);
}
.login-card {
  background: var(--bg-elev); border-radius: var(--r-xl);
  padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-pop);
}
.login-brand {
  text-align: center; margin-bottom: 24px;
}
.login-brand .brand-logo {
  width: 48px; height: 48px; margin: 0 auto 10px; font-size: 26px;
}
.login-brand h1 { font-size: 18px; font-weight: 600; margin: 0; }
.login-brand p { font-size: 13px; color: var(--text-2); margin: 4px 0 0; }
.login-card .form-row { flex-direction: column; align-items: stretch; gap: 4px; }
.login-card .form-row label { width: auto; text-align: left; font-size: 12.5px; color: var(--text-2); }

/* ============ 工作台 ============ */
.dash-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
.dash-today .today-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 6px 0 0;
}
.today-item {
  display: block; text-align: center; padding: 14px 6px;
  border-radius: var(--r-md); background: var(--bg-active);
  text-decoration: none; color: inherit; transition: all .15s;
}
.today-item:hover { background: var(--bg-hover); transform: translateY(-1px); text-decoration: none; }
.today-item.highlight { background: rgba(255,149,0,.08); }
.today-num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.today-lbl { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }

.dash-quick .quick-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px 0 0;
}
.quick-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 8px; border-radius: var(--r-md); background: var(--bg-active);
  font-size: 13px; text-decoration: none; color: var(--text-1);
  transition: all .12s; border: 1px solid transparent;
}
.quick-btn:hover {
  background: var(--bg-hover); border-color: var(--primary); color: var(--primary);
  text-decoration: none;
}
.quick-btn span { font-size: 16px; color: var(--primary); font-weight: 600; }

/* 趋势图 */
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.legend .dot-a { background: var(--primary); }
.legend .dot-b { background: var(--success); }

.trend-chart {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 24px 8px 8px; min-height: 200px;
  border-bottom: 1px solid var(--separator);
}
.tc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tc-bar-wrap {
  display: flex; align-items: flex-end; gap: 4px; height: 140px;
  width: 100%; justify-content: center;
}
.tc-bar {
  width: 14px; border-radius: 4px 4px 0 0;
  transition: opacity .15s; cursor: default;
}
.tc-bar:hover { opacity: 0.7; }
.tc-bar-a { background: var(--primary); }
.tc-bar-b { background: var(--success); }
.tc-label {
  text-align: center; font-size: 11.5px; color: var(--text-2);
  line-height: 1.3; padding-top: 6px;
}
.tc-label small { display: block; font-size: 10px; color: var(--text-3); }

.rank { font-weight: 600; }
.rank-1 { color: #d4af37; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

/* ============ 订单分组卡片 ============ */
.group-card {
  background: var(--bg-elev); border: 1px solid var(--separator);
  border-radius: var(--r-lg); margin-bottom: 10px; overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; cursor: pointer;
}
.group-head:hover { background: var(--bg-active); }
.group-head .arrow { transition: transform .2s; color: var(--text-3); }
.group-card.open .group-head .arrow { transform: rotate(90deg); }
.group-body { display: none; padding: 0; border-top: 1px solid var(--separator); }
.group-card.open .group-body { display: block; }

/* 分组卡片内部布局 */
.group-head { gap: 14px; flex-wrap: wrap; padding: 12px 14px; cursor: pointer; }
.group-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; font-size: 12.5px; color: var(--text-2); }
.group-stats strong { color: var(--text-1); }

/* 分组卡片字段网格（上下对齐） */
.group-grid {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) repeat(7, minmax(80px, 1fr));
  gap: 8px 14px;
  align-items: center;
  width: 100%;
}
.gg-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gg-cell.gg-title { min-width: 0; }
.gg-label { font-size: 11px; color: var(--text-3); font-weight: 500; letter-spacing: .3px; }
.gg-val { font-size: 13.5px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gg-val.small { font-size: 12.5px; }
.gg-val.mono { font-family: var(--font-mono, monospace); font-size: 12px; }
@media (max-width: 980px) {
  .group-grid { grid-template-columns: repeat(2, 1fr); }
}

.fold-ic { display: inline-block; transition: transform .2s; color: var(--text-3); font-size: 10px; width: 14px; text-align: center; }
.group-card.open .fold-ic { transform: rotate(90deg); }

/* 可搜索下拉 */
.search-dropdown { position: relative; }
.search-dropdown-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  margin-top: 4px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
}
.search-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--separator);
  font-size: 13px;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.ss-hover { background: var(--bg-active); }

/* 可搜索下拉：自动增强的 <select class="input"> */
.ss-wrap { position: relative; }
.ss-hidden { display: none !important; }
.ss-input { width: 100%; }
.ss-item.ss-current { background: var(--bg-active); }
.ss-item.ss-current strong { color: var(--primary); }

.parsed-trip-edit {
  padding: 12px;
  background: var(--bg-active);
  border-radius: 8px;
  margin-bottom: 6px;
}

/* 分组体内嵌内容 */
.orders-table { padding: 6px 14px; overflow-x: auto; }
.group-meta { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 14px; font-size: 12.5px; color: var(--text-2); background: var(--bg-active); border-top: 1px solid var(--separator); }
.group-meta strong { color: var(--text-1); margin-right: 4px; }
.log-line { padding: 4px 14px; font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--separator); }

/* 子订单表格对齐 */
.orders-grid th, .orders-grid td { white-space: nowrap; }
.orders-grid th { background: var(--bg-active); font-weight: 600; }
.orders-grid tr:hover td { background: var(--bg-active); }
.orders-grid .right { text-align: right; }
.orders-grid .center { text-align: center; }
.orders-grid .mono { font-family: var(--font-mono); }
.group-no { font-weight: 600; font-size: 14px; }
.group-name { color: var(--text-2); font-size: 12.5px; }

/* 批量栏 */
.batch-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev); padding: 10px 16px;
  border: 1px solid var(--separator);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  margin: 10px 0;
}

/* ============ 出行日历 ============ */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--bg-active); border-radius: var(--r-md) var(--r-md) 0 0; }
.cal-head-cell { padding: 10px; text-align: center; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--separator);
  border: 1px solid var(--separator); border-radius: 0 0 var(--r-md) var(--r-md);
  overflow: hidden;
}
.cal-cell {
  background: var(--bg); padding: 6px;
  min-height: 110px; display: flex; flex-direction: column; gap: 4px;
}
.cal-empty { background: var(--bg-active); }
.cal-today { background: rgba(0,122,255,.04); }
.cal-weekend { background: rgba(255,149,0,.02); }
.cal-day { display: flex; align-items: baseline; justify-content: space-between; }
.cal-day-num { font-weight: 600; font-size: 13px; }
.cal-today .cal-day-num {
  background: var(--primary); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.cal-count { font-size: 10px; color: var(--text-3); }
.cal-event {
  display: block; padding: 4px 6px; border-radius: var(--r-xs);
  background: var(--bg-active); border-left: 3px solid var(--primary);
  font-size: 11px; line-height: 1.4; text-decoration: none; color: inherit;
}
.cal-event:hover {
  background: var(--bg-hover); transform: translateX(2px);
  text-decoration: none;
}
.cal-event .cal-time { font-weight: 600; color: var(--primary); margin-right: 4px; }
.cal-event .cal-train { font-weight: 600; }
.cal-event .cal-route { color: var(--text-2); margin-top: 2px; }
.cal-event .cal-agency { font-size: 10.5px; margin-top: 1px; }
.cal-more {
  display: block; text-align: center; font-size: 11px;
  color: var(--primary); padding: 2px; text-decoration: none;
}
.cal-more:hover { background: var(--bg-active); border-radius: var(--r-xs); }

/* 弹窗 kv 列表 */
.kv-list { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; }
.kv-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--separator); }
.kv-row:last-child { border-bottom: none; }
.kv-key { width: 80px; color: var(--text-2); flex-shrink: 0; }
.day-list-item {
  display: grid; grid-template-columns: 50px 60px 1fr auto auto;
  gap: 10px; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--separator); text-decoration: none; color: inherit;
}
.day-list-item:hover { background: var(--bg-active); text-decoration: none; }
.day-list-item:last-child { border-bottom: none; }

/* ============ 提示 ============ */
.alert {
  padding: 10px 14px; border-radius: var(--r-md);
  margin-bottom: 12px; font-size: 13px;
  border: 1px solid;
}
.alert-info {
  background: rgba(0,122,255,.06); color: var(--primary);
  border-color: rgba(0,122,255,.18);
}
.alert-danger {
  background: rgba(255,59,48,.06); color: var(--danger);
  border-color: rgba(255,59,48,.18);
}

/* 拖动排序 */
.sortable { list-style: none; padding: 0; margin: 12px 0; }
.sortable li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg-active); border-radius: var(--r-md);
  margin-bottom: 6px; cursor: move; user-select: none;
}
.sortable li:hover { background: var(--bg-hover); }
.drag-handle { color: var(--text-3); font-size: 18px; }

/* 权限格 */
.perm-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
}
.perm-grid label {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--bg-active); font-size: 13px;
  cursor: pointer; user-select: none;
}
.perm-grid label:hover { background: var(--bg-hover); }
.perm-grid input[type=checkbox]:checked + span { color: var(--primary); font-weight: 500; }

/* 流水选项 */
.flow-item {
  padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--separator); margin-bottom: 6px;
  cursor: pointer; transition: all .12s;
}
.flow-item:hover { background: var(--bg-active); border-color: var(--primary); }

/* 边栏遮罩 */
.sidebar-mask {
  display: none; position: fixed; inset: 0;
  background: var(--bg-mask); z-index: 49;
}

/* ============ 移动端 ============ */
@media (max-width: 820px) {
  body { font-size: 14px; }
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    width: 240px; z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.show { transform: translateX(0); }
  body.sidebar-open .sidebar-mask { display: block; }
  .main { margin-left: 0; width: 100%; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 8px 14px; }
  .topbar .global-search { display: none; }
  .content { padding: 14px; }
  .card { padding: 14px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h2 { font-size: 19px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: 1fr; gap: 10px; }
  .dash-today .today-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-quick .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-wrap: wrap; }
  .filter-bar .input,
  .filter-bar select { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .batch-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    border-radius: 0; flex-wrap: wrap; margin: 0;
    z-index: 30; padding: 10px 12px;
  }
  .batch-bar .btn { flex: 1 1 auto; min-width: 0; }
  .modal-body, .modal-card { max-width: 96%; width: 96%; max-height: 92vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .form-row > label { width: auto; text-align: left; }
  .cal-cell { min-height: 70px; padding: 3px; }
  .cal-event { font-size: 10px; padding: 2px 4px; }
  .cal-event .cal-route, .cal-event .cal-agency { display: none; }
  .day-list-item { grid-template-columns: 1fr; gap: 4px; }
  .trend-chart { padding: 16px 4px 6px; gap: 4px; }
  .tc-bar { width: 8px; }
  .tc-bar-wrap { gap: 2px; }
}

/* 日志 diff 行 */
.diff-row { background: var(--bg-active); padding: 0 !important; }
.diff-box { padding: 10px 18px; background: var(--bg-active); }
.diff-box table tr td { padding: 4px 8px; border: 0; }

/* ============ 流水关联弹窗 ============ */
.flow-modal-card {
  max-width: 900px !important;
  width: 92vw;
}
.flow-modal-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-active);
  border-radius: 6px;
}
.flow-search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.flow-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.flow-search-input {
  padding-left: 40px !important;
  height: 42px;
  font-size: 14px;
  border-radius: 8px;
}
.flow-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,113,235,.12);
}

.flow-list {
  max-height: 56vh;
  overflow-y: auto;
  border: 1px solid var(--separator);
  border-radius: 8px;
  background: var(--bg-card, #fff);
}

.flow-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  transition: background-color .12s;
}
.flow-card:last-child { border-bottom: none; }
.flow-card:hover { background: var(--bg-active); }
.flow-card-exact {
  background: linear-gradient(90deg, rgba(0,180,80,.08), rgba(0,180,80,.02));
  border-left: 3px solid var(--ok, #00b450);
}
.flow-card-exact:hover {
  background: linear-gradient(90deg, rgba(0,180,80,.14), rgba(0,180,80,.05));
}
.flow-card-fit {
  border-left: 3px solid var(--info, #0099ee);
}

.flow-card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.flow-card-amts {
  flex: 1;
  min-width: 0;
}
.flow-card-avail {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}
.flow-card-total {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 3px;
}
.flow-card-meta {
  text-align: right;
  min-width: 0;
  color: var(--text-2);
  flex-shrink: 0;
}
.flow-card-meta > div { line-height: 1.5; }
.flow-card-subj {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 6px;
}

/* 已关联占比进度条 */
.flow-bar {
  height: 4px;
  background: rgba(0,0,0,.06);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.flow-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--info, #0099ee));
  border-radius: 2px;
}

.flow-card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.flow-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  line-height: 1.5;
}
.flow-tag-ok { background: rgba(0,180,80,.15); color: #008a40; }
.flow-tag-warn { background: rgba(255,149,0,.15); color: #cc6800; }
.flow-tag-info { background: rgba(0,153,238,.15); color: #006bb3; }
.flow-tag-muted { background: rgba(0,0,0,.06); color: var(--text-2); }

@media (prefers-color-scheme: dark) {
  .flow-tag-ok { background: rgba(0,200,90,.18); color: #58d989; }
  .flow-tag-warn { background: rgba(255,170,30,.18); color: #ffc060; }
  .flow-tag-info { background: rgba(50,170,255,.18); color: #5fbfff; }
}

/* ============ v2.3 流水弹窗 — 单行卡片 ============ */
.flow-modal-card {
  max-width: 880px !important;
  width: 92vw;
}
.flow-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.flow-amt-tag {
  padding: 6px 12px;
  background: rgba(0,113,235,.08);
  border: 1px solid rgba(0,113,235,.2);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-2);
}
.flow-amt-tag strong { color: var(--primary); font-size: 15px; margin-left: 4px; }

/* 显眼搜索框 */
.flow-search-wrap {
  position: relative;
  margin-bottom: 10px;
}
.flow-search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--text-3);
  pointer-events: none;
  z-index: 2;
}
.flow-search-input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 46px;
  font-size: 15px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card, #fff);
  color: var(--text-1);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.flow-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,113,235,.12);
}
.flow-match-hint {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.flow-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.flow-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg-active);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background-color .12s;
}
.flow-chip:hover { background: rgba(0,113,235,.08); }
.flow-chip input { margin: 0; }
.flow-chip:has(input:checked) {
  background: rgba(0,113,235,.12);
  border-color: rgba(0,113,235,.3);
  color: var(--primary);
}

.flow-list {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--bg-card, #fff);
}

/* 单行流水 */
.flow-row {
  position: relative;
  padding: 14px 16px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  transition: background-color .12s;
}
.flow-row:last-child { border-bottom: none; }
.flow-row:hover {
  background: rgba(0,113,235,.04);
}
.flow-row-exact {
  background: linear-gradient(90deg, rgba(0,180,80,.07), transparent 50%);
  border-left: 3px solid var(--ok, #00b450);
  padding-left: 13px;
}
.flow-row-exact:hover {
  background: linear-gradient(90deg, rgba(0,180,80,.13), rgba(0,113,235,.04) 50%);
}
.flow-row-fit {
  border-left: 3px solid var(--info, #0099ee);
  padding-left: 13px;
}

.fr-ribbon {
  position: absolute;
  top: 0; right: 0;
  padding: 2px 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  border-bottom-left-radius: 6px;
}
.fr-ribbon-ok { background: var(--ok, #00b450); color: #fff; }
.fr-ribbon-warn { background: var(--warn, #ff9500); color: #fff; }
.fr-ribbon-info { background: var(--info, #0099ee); color: #fff; }

.fr-main {
  display: flex;
  gap: 16px;
  align-items: center;
}
.fr-amt-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 130px;
  flex-shrink: 0;
}
.fr-amt, .fr-amt-fit, .fr-amt-exact {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.fr-amt { color: var(--text-1); }
.fr-amt-fit { color: var(--info, #0099ee); }
.fr-amt-exact { color: var(--ok, #00b450); }
.fr-amt-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}

.fr-info { flex: 1; min-width: 0; }
.fr-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fr-meta-line {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.7;
}
.fr-meta-line.muted { color: var(--text-3); }

.fr-tag-muted, .fr-tag-warn {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.fr-tag-muted { background: rgba(0,0,0,.06); color: var(--text-2); }
.fr-tag-warn  { background: rgba(255,149,0,.15); color: #cc6800; }

.fr-bar {
  margin-top: 10px;
  height: 3px;
  background: rgba(0,0,0,.05);
  border-radius: 2px;
  overflow: hidden;
}
.fr-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--info, #0099ee));
}

/* ============ 富分页 ============ */
.pager-rich {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 4px;
  justify-content: center;
}
.pg-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}
.pg-btn {
  display: inline-block;
  min-width: 32px;
  padding: 5px 10px;
  text-align: center;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card, #fff);
  color: var(--text-1);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color .12s, border-color .12s;
}
.pg-btn:hover {
  background: rgba(0,113,235,.08);
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.pg-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pg-active:hover { background: var(--primary); color: #fff; }
.pg-disabled {
  color: var(--text-3);
  background: var(--bg-active);
  cursor: not-allowed;
  pointer-events: none;
  opacity: .5;
}
.pg-ellipsis {
  padding: 5px 6px;
  color: var(--text-3);
  font-size: 13px;
}
.pg-jump-input {
  width: 60px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  background: var(--bg-card, #fff);
  color: var(--text-1);
  outline: none;
}
.pg-jump-input:focus { border-color: var(--primary); }

/* ============ Refund Tab ============ */
.refund-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--separator);
  margin-bottom: 16px;
}
.refund-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  border-radius: 8px 8px 0 0;
}
.refund-tab:hover {
  background: var(--bg-active);
  color: var(--text-1);
}
.refund-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(0,113,235,.04);
}
.rt-icon { font-size: 18px; }
.rt-label { font-weight: 600; }
.rt-count {
  background: var(--bg-active);
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 24px;
  text-align: center;
}
.refund-tab.active .rt-count {
  background: var(--primary);
  color: #fff;
}

.refund-pane { display: none; }
.refund-pane.active { display: block; }

/* ============ 退票审核状态按钮组 ============ */
.status-tabs {
  display: inline-flex;
  background: var(--bg-active);
  padding: 6px;
  border-radius: 12px;
  gap: 4px;
}
.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-size: 15.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
  line-height: 1.2;
}
.status-tab:hover {
  background: rgba(0,113,235,.08);
  color: var(--text-1);
}
.status-tab.active {
  background: var(--bg-card, #fff);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.st-icon {
  font-size: 18px;
}
.st-cnt {
  display: inline-block;
  min-width: 24px;
  padding: 1px 9px;
  font-size: 13px;
  background: rgba(0,0,0,.08);
  border-radius: 11px;
  text-align: center;
  font-weight: 600;
  color: var(--text-2);
}
.status-tab.active .st-cnt {
  background: var(--primary);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .status-tab.active {
    background: rgba(255,255,255,.08);
  }
}

/* ============ v1.0.1 增量：动态 modal 表单 & 权限 UI 美化 ============ */

/* form-group 兼容样式 (agency / station / payment_method 等老页面的模态表单结构) */
.form-group {
  display: flex; flex-direction: column;
  gap: 4px; margin-bottom: 10px; flex: 1; min-width: 0;
}
.form-group > label {
  font-size: 12.5px; color: var(--text-2); font-weight: 500;
  text-align: left; width: auto;
}
.form-row .form-group { margin-bottom: 0; }
/* form-row 包含 form-group 时改用网格 */
.modal-card .form-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 14px; align-items: end;
}
.modal-card .form-row > label { width: auto; text-align: left; }
.modal-card .form-row > .form-group label { color: var(--text-2); font-size: 12.5px; }
.form-hint {
  font-size: 12px; color: var(--text-3);
  padding: 8px 10px; background: var(--bg-active);
  border-radius: var(--r-sm); margin: 6px 0 10px;
}

/* badge-success / badge-primary 别名 */
.badge-success { background: rgba(52,199,89,.12); color: var(--success); }
.badge-primary { background: rgba(0,122,255,.12); color: var(--primary); }

/* ============ 操作员管理页 (users.php) UI 美化 ============ */
.user-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin-top: 14px;
}
.user-card-item {
  background: var(--bg-elev);
  border: 1px solid var(--separator);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: all .15s;
}
.user-card-item:hover {
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.user-card-item.is-disabled { opacity: .55; }
.uc-head {
  display: flex; align-items: center; gap: 12px;
}
.uc-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--sf-purple, var(--primary)));
  color: #fff; font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.uc-avatar.is-admin {
  background: linear-gradient(135deg, var(--sf-orange), var(--danger));
}
.uc-name { font-size: 15px; font-weight: 600; color: var(--text-1); }
.uc-sub  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.uc-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-2);
  padding: 6px 0; border-top: 1px dashed var(--separator);
}
.uc-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.uc-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  padding-top: 6px; border-top: 1px solid var(--separator);
}
.uc-actions .btn { padding: 4px 12px; font-size: 12.5px; }

/* 权限分组（按业务域分块展示） */
.perm-board {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 50vh; overflow: auto;
  padding: 4px;
}
.perm-section {
  background: var(--bg-active);
  border-radius: var(--r-md);
  padding: 10px 12px 8px;
}
.perm-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.perm-section-title {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  display: inline-flex; align-items: center; gap: 6px;
}
.perm-section-title .ps-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
}
.perm-section-count {
  font-size: 11.5px; color: var(--text-3);
}
.perm-section-toggle {
  background: transparent; border: 0; color: var(--primary);
  font-size: 11.5px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px;
}
.perm-section-toggle:hover { background: var(--bg-hover); }
.perm-section-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
}
.perm-section-items label {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: var(--r-sm);
  background: var(--bg);
  font-size: 12.5px; color: var(--text-1);
  cursor: pointer; user-select: none;
  transition: all .12s;
  border: 1px solid transparent;
}
.perm-section-items label:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.perm-section-items label.is-checked {
  background: rgba(0,122,255,.08);
  border-color: rgba(0,122,255,.25);
  color: var(--primary);
  font-weight: 500;
}
.perm-section-items .perm-key {
  font-size: 11px; color: var(--text-3);
  font-family: var(--font-mono); margin-left: auto;
}
.perm-section-items label.is-checked .perm-key { color: var(--primary); opacity: .7; }

/* 角色模板栏 */
.role-tpl-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--bg-active);
  border-radius: var(--r-md); margin-bottom: 12px;
}
.role-tpl-bar > strong { font-size: 13px; color: var(--text-1); }
.role-tpl-bar .check-inline { font-size: 12.5px; color: var(--text-2); }

/* user list 容器（替换原 table） */
.user-list-card .card-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 8px;
}
.user-list-card h3 { margin: 0; }

/* 退票卡片样式预留（不与 status-tabs 冲突） */

/* ============ v1.0.2 增量：订单详情页子订单表格 - 最后 3 列固定不滚 ============ */
/* 启用方式: 给 .table-wrap 加上 .gd-sticky-cols 类即可 */
.gd-sticky-cols {
  position: relative;
  /* 让横向滚动条只在主区域出现，固定列不参与滚动 */
}
/* 三个固定列: 采购流水(倒数3) / 状态(倒数2) / 操作(倒数1) */
.gd-sticky-cols table.orders-grid th:nth-last-child(-n+3),
.gd-sticky-cols table.orders-grid td:nth-last-child(-n+3) {
  position: sticky;
  background: var(--bg-elev);
  z-index: 2;
}
/* 操作列(最右): right=0 */
.gd-sticky-cols table.orders-grid th:last-child,
.gd-sticky-cols table.orders-grid td:last-child {
  right: 0;
  min-width: 100px;
  width: 100px;
}
/* 状态列(倒数第2): right=100px(操作列宽度) */
.gd-sticky-cols table.orders-grid th:nth-last-child(2),
.gd-sticky-cols table.orders-grid td:nth-last-child(2) {
  right: 100px;
  min-width: 80px;
  width: 80px;
}
/* 采购流水列(倒数第3): right=180px */
.gd-sticky-cols table.orders-grid th:nth-last-child(3),
.gd-sticky-cols table.orders-grid td:nth-last-child(3) {
  right: 180px;
  min-width: 90px;
  width: 90px;
}
/* 最左固定列加左侧阴影,提示滚动边界 */
.gd-sticky-cols table.orders-grid th:nth-last-child(3),
.gd-sticky-cols table.orders-grid td:nth-last-child(3) {
  box-shadow: -6px 0 10px -6px rgba(0,0,0,0.15);
  border-left: 1px solid var(--separator);
}
/* hover 行时,固定列背景一起变 */
.gd-sticky-cols table.orders-grid tbody tr:hover > td:nth-last-child(-n+3) {
  background: var(--bg-active);
}
/* 表头固定列背景与表头其他列保持一致 */
.gd-sticky-cols table.orders-grid thead th:nth-last-child(-n+3) {
  background: #f0f3f7;
  z-index: 3;
}
[data-theme="dark"] .gd-sticky-cols table.orders-grid thead th:nth-last-child(-n+3) {
  background: #2c2c2e;
}
[data-theme="dark"] .gd-sticky-cols table.orders-grid th:nth-last-child(-n+3),
[data-theme="dark"] .gd-sticky-cols table.orders-grid td:nth-last-child(-n+3) {
  background: var(--bg-elev);
}
[data-theme="dark"] .gd-sticky-cols table.orders-grid tbody tr:hover > td:nth-last-child(-n+3) {
  background: var(--bg-active);
}
/* 移动端小屏时也保持固定,但缩窄列宽避免占用太多空间 */
@media (max-width: 820px) {
  .gd-sticky-cols table.orders-grid th:last-child,
  .gd-sticky-cols table.orders-grid td:last-child {
    min-width: 84px; width: 84px;
  }
  .gd-sticky-cols table.orders-grid th:nth-last-child(2),
  .gd-sticky-cols table.orders-grid td:nth-last-child(2) {
    right: 84px; min-width: 68px; width: 68px;
  }
  .gd-sticky-cols table.orders-grid th:nth-last-child(3),
  .gd-sticky-cols table.orders-grid td:nth-last-child(3) {
    right: 152px; min-width: 76px; width: 76px;
  }
}

/* ============ v1.0.7 增量: 搜索框美化 ============ */

/* 顶部全局搜索框升级 */
.topbar .global-search {
  flex: 1; max-width: 460px;
}
.topbar .global-search input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  font-size: 13.5px;
  border: 1px solid transparent;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--bg-active), var(--bg, #f5f5f7));
  color: var(--text-1);
  font-family: inherit;
  transition: all .18s cubic-bezier(.4, 0, .2, 1);
  letter-spacing: .01em;
}
.topbar .global-search input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}
.topbar .global-search input:hover {
  background: var(--bg-elev, #fff);
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
}
.topbar .global-search input:focus {
  outline: none;
  background: var(--bg-elev, #fff);
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(0, 122, 255, .12),
    0 2px 12px rgba(0, 122, 255, .08);
}
.topbar .global-search::before {
  width: 16px; height: 16px;
  left: 14px;
  background: var(--primary);
  opacity: .65;
  transition: all .15s;
}
.topbar .global-search input:focus + .global-search::before,
.topbar .global-search:focus-within::before {
  opacity: 1;
  transform: translateY(-50%) scale(1.08);
}

/* 全局搜索结果面板增强 */
.topbar .global-search-result {
  top: calc(100% + 8px);
  border-radius: var(--r-lg, 12px);
  border: 1px solid var(--separator);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, .12),
    0 4px 12px rgba(0, 0, 0, .06);
  animation: gs-fade-in .15s ease-out;
}
@keyframes gs-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 页内"搜索"输入框美化(通过 placeholder 包含"搜索"或"关键字"识别) */
.input[placeholder*="搜索"],
.input[placeholder*="关键字"] {
  padding-left: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  background-size: 14px 14px;
  border-radius: 8px;
  transition: all .15s;
}
.input[placeholder*="搜索"]:hover,
.input[placeholder*="关键字"]:hover {
  border-color: var(--border-strong, #d1d1d6);
}
.input[placeholder*="搜索"]:focus,
.input[placeholder*="关键字"]:focus {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23007aff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, .12);
}

/* 渠道排名表格的特殊行 hover */
.ranking-row:hover {
  background: var(--bg-active) !important;
}
.ranking-row:hover .rank {
  transform: scale(1.08);
  transition: transform .15s;
}
.sort-h {
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.sort-h:hover {
  background: var(--bg-active);
  color: var(--primary);
}
