/* ============ Subscription Manager UI ============ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f9;
  --border: #e3e9f2;
  --text: #1e293b;
  --text-2: #475569;
  --muted: #94a3b8;
  --primary: #3b5bdb;
  --primary-dark: #2f49b4;
  --primary-soft: #eef2ff;
  --success: #0ca678;
  --success-soft: #e6f7f2;
  --warning: #e8590c;
  --warning-soft: #fff3e8;
  --danger: #e03131;
  --danger-soft: #fff0f0;
  --info: #1c7ed6;
  --info-soft: #e8f4ff;
  --sidebar: #141c2f;
  --sidebar-active: #233059;
  --sidebar-text: #aebbd2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(15, 23, 42, .06);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 18% 20%, #2b3f80 0%, transparent 42%),
              radial-gradient(circle at 82% 80%, #1a6f8e 0%, transparent 40%),
              linear-gradient(135deg, #101a33 0%, #1d2b52 100%);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px;
  padding: 40px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .logo {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7048e8); color: #fff; font-size: 20px; font-weight: 800;
}
.login-brand h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 8px; height: 43px; }
.login-foot { margin-top: 22px; text-align: center; font-size: 12px; color: var(--muted); }
.lang-switch {
  display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface);
}
.lang-switch button {
  border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600;
}
.lang-switch button.active { background: var(--primary); color: #fff; }
.login-lang { position: absolute; top: 24px; right: 24px; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.sidebar-brand {
  height: 68px; display: flex; align-items: center; gap: 11px; padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #5b7cfa, #7950f2); color: #fff; font-weight: 800; font-size: 17px;
}
.sidebar-brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-brand .sub { font-size: 10px; color: #7e8dab; letter-spacing: .5px; }
.nav { padding: 16px 12px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #65769a; padding: 12px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  cursor: pointer; color: var(--sidebar-text); font-size: 13px; margin-bottom: 3px; border: 0;
  background: transparent; width: 100%; text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-badge { margin-left: auto; background: #e8590c; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 10px; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11px; color: #6f7f9f; }
/* 移动端抽屉（仅窄屏显示） */
.nav-toggle { display: none; border: 0; background: transparent; color: var(--text); font-size: 19px; padding: 4px 6px; cursor: pointer; }
.sidebar-backdrop { display: none; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 68px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .crumb { font-size: 11px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; height: 34px;
  min-width: 34px; padding: 0 9px; cursor: pointer; display: grid; place-items: center; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); }
.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; position: relative; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-chip .uname { font-size: 13px; font-weight: 600; }
.user-menu {
  position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 180px; z-index: 50;
}
.user-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 11px;
  border-radius: 7px; cursor: pointer; font-size: 13px;
}
.user-menu button:hover { background: var(--surface-3); }
.view-root { padding: 24px 28px 48px; flex: 1; }

/* ---------- Common ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h2 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 15px; cursor: pointer; font-size: 13px; font-weight: 600; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; white-space: nowrap; transition: all .15s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-body { padding: 20px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-card .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi-card .value { font-size: 27px; font-weight: 750; margin: 8px 0 4px; letter-spacing: -.5px; }
.kpi-card .foot { font-size: 11px; color: var(--muted); }
.kpi-card .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.kpi-card.warn .bar { background: var(--warning); }
.kpi-card.ok .bar { background: var(--success); }
.kpi-card.danger .bar { background: var(--danger); }

.charts-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 1100px) { .charts-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { min-height: 280px; }
.chart-wrap { padding: 16px 20px; height: 235px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; height: 100%; }
.donut-legend { flex: 1; font-size: 12px; }
.donut-legend div { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.donut-legend .n { margin-left: auto; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-col .bar { width: 100%; max-width: 34px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #5b7cfa, #3b5bdb); min-height: 3px; }
.bar-col .lbl { font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar-col .val { font-size: 11px; font-weight: 700; color: var(--text-2); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 11px 20px; border-bottom: 1px solid var(--surface-2); display: flex; align-items: center; gap: 12px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .main { flex: 1; min-width: 0; }
.mini-list .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mini-list .r { text-align: right; font-size: 12px; white-space: nowrap; }

/* ---------- Tables ---------- */
.table-tools {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-tools .grow { flex: 1; }
.input, .select, textarea.input {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 13px; outline: none; min-height: 36px;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,91,219,.1); }
.input::placeholder { color: var(--muted); }
.select { cursor: pointer; padding-right: 28px; }
label.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 11px 16px; background: var(--surface-2); color: var(--text-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbff; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { display: flex; gap: 5px; justify-content: flex-end; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.orange { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.gray { background: var(--surface-3); color: var(--muted); }
.badge.purple { background: #f3edff; color: #7048e8; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 11px; margin-right: 4px; }
.checkbox { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty .ic { font-size: 30px; opacity: .45; margin-bottom: 8px; }
.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.pagination .pages { display: flex; gap: 5px; align-items: center; }
.pagination button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  min-width: 30px; height: 30px; padding: 0 8px; cursor: pointer; font-size: 12px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Modal / form ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal.wide { max-width: 860px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { border: 0; background: transparent; cursor: pointer; font-size: 20px; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.field .input, .field .select { width: 100%; }
.req { color: var(--danger); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.info-item { background: var(--surface-2); border-radius: 9px; padding: 12px 14px; }
.info-item .k { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.info-item .v { font-weight: 600; font-size: 13px; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; padding: 10px 14px; cursor: pointer; font-size: 13px;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.alert { padding: 12px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; }
.alert.info { background: var(--info-soft); color: #155a9e; }
.alert.warn { background: var(--warning-soft); color: #a64708; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--success-soft); color: #08785a; }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; min-height: 190px; resize: vertical; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-line input { width: 15px; height: 15px; accent-color: var(--primary); }
.inline-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 9px; box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 250px; max-width: 380px;
  font-size: 13px; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(59,91,219,.25); border-top-color: var(--primary);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 50px; color: var(--muted); }

/* ---------- v2 additions ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-card .stat-label { color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.stat-card .stat-value { font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.orange .stat-value { color: #e8590c; }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.blue .stat-value { color: var(--primary); }
.stat-card.gray .stat-value { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 12px; }
.bar-label { width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-value { width: 34px; text-align: right; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 12px; }
.spark-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.spark-bar { width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--primary), #7b93f0); }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 8px; }
.check-group { display: flex; gap: 18px; flex-wrap: wrap; padding: 8px 0; }
.check-group label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--info-soft); color: #155a9e; font-size: 11px; font-weight: 700; margin-right: 4px; }
.nowrap { white-space: nowrap; }
.small { font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; margin-bottom: 18px; font-size: 13px; }
.detail-grid b { color: var(--muted); font-size: 11px; text-transform: uppercase; display: block; margin-bottom: 3px; }
.detail-grid .full { grid-column: 1 / -1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays { margin-bottom: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.cal-cell { min-height: 88px; border: 1px solid var(--border); border-radius: 8px; padding: 7px; background: var(--surface); font-size: 11px; }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.warn { border-color: #f59f00; }
.cal-day { font-weight: 700; font-size: 12px; margin-bottom: 5px; }
.cal-badge { border-radius: 5px; padding: 2px 4px; margin-bottom: 3px; }
.cal-badge.exp { background: var(--warning-soft); color: #a64708; }
.cal-badge.sent { background: var(--success-soft); color: #08785a; }
/* ============ 高效管理界面 / Efficient management UI ============ */
/* 快速筛选胶囊 */
.quick-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.quick-filter .chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  padding: 7px 15px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: .15s;
}
.quick-filter .chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.quick-filter-label { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.chip-count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); font-size: 11px; line-height: 18px; text-align: center;
}
.quick-filter .chip:hover .chip-count, .panel-more .chip-count { background: rgba(255,255,255,.22); color: #fff; }
.panel-more .chip-count { margin-left: 2px; }

/* 可点击 KPI */
.kpi-clickable .stat-card { cursor: pointer; border: 1px solid var(--border); text-align: left; transition: .15s; }
.kpi-clickable .stat-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow); }

/* 明细面板 */
.panel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.card.panel { padding: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.panel-more { color: var(--primary); font-size: 12px; text-decoration: none; white-space: nowrap; padding: 3px 8px; border: 1px solid var(--primary); border-radius: 5px; background: var(--primary); color: #fff; }
.panel-more:hover { opacity: .85; }
.panel.expired-panel, .panel-expired { border-top: 3px solid var(--danger); }
.panel-foot { margin-top: 8px; text-align: center; font-size: 12px; color: var(--danger); }
.secondary-panels { margin-top: 2px; }
.detail-table th { color: var(--muted); font-weight: 600; }
.detail-table td.cell-main { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data.compact { font-size: 12px; }
.data.compact th, .data.compact td { padding: 6px 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 5px;
  cursor: pointer; font-size: 12px; color: #fff; margin: 1px; padding: 0;
}
.ico-preview { background: #f39c12; } .ico-send { background: #2980b9; }
.ico-mailme { background: #16a085; } .ico-open { background: #7f8c8d; }
.ico-save { background: #27ae60; } .ico-renew { background: #27ae60; }
.ico-copy { background: #8e44ad; } .ico-del { background: #e74c3c; }
.icon-btn:hover { filter: brightness(.9); }

/* 快速添加栏 */
.quick-add { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.quick-add > summary { cursor: pointer; padding: 12px 18px; font-weight: 700; color: var(--primary); font-size: 14px; list-style: none; }
.quick-add > summary::-webkit-details-marker { display: none; }
.quick-add > summary::before { content: '▸ '; }
.quick-add[open] > summary::before { content: '▾ '; }
.quick-add-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 0 18px 16px; }
.quick-add-form .input, .quick-add-form .select { padding: 7px 10px; font-size: 12px; height: 36px; }
.quick-add-form input[type=email] { width: 190px; }
.quick-add-form input[type=date] { width: 145px; }
.quick-add-form input[name=notes], .quick-add-form input[name=tags] { width: 100px; }
.quick-add-form input[name=amount] { width: 90px; }

/* 紧凑筛选 */
.card-flush { padding: 0; overflow: hidden; }
.compact-filters { padding: 14px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.compact-filters .input, .compact-filters .select { height: 34px; padding: 6px 10px; font-size: 12px; }
.compact-filters .dash { color: var(--muted); }
.clear-link { color: var(--danger); font-size: 12px; white-space: nowrap; }

/* 批量操作条 */
.batch-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.check-all { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.batch-count { color: var(--primary); font-size: 12px; font-weight: 700; }
.batch-spacer { flex: 1; }
.batch-send { background: #e67e22; color: #fff; border-color: #e67e22; }
.batch-renew { background: #27ae60; color: #fff; border-color: #27ae60; }
.batch-tag { background: #8e44ad; color: #fff; border-color: #8e44ad; }
.batch-delete { background: #e74c3c; color: #fff; border-color: #e74c3c; }

/* 行内编辑表格 */
.inline-table { font-size: 12px; width: 100%; }
.inline-table th, .inline-table td { padding: 5px 6px; white-space: nowrap; }
.inline-table .col-id { color: var(--muted); font-size: 11px; }
.inline-table .col-email { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.inline-table .col-remain { font-weight: 700; text-align: center; }
.remain-red { color: #e74c3c; } .remain-orange { color: #f39c12; } .remain-green { color: #27ae60; }
.inline-table .col-amount { width: 72px; }
.inline-table .col-note { width: 90px; }
.inline-table .col-sent { text-align: center; color: var(--muted); }
.inline-table .col-actions { text-align: center; }
.inline-ctl {
  width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); font-size: 11px; height: 30px;
}
.inline-ctl:focus { border-color: var(--primary); outline: none; }
.inline-ctl[type=date] { width: 128px; }
.inline-table tr.dirty { background: #fff8e1; }
.inline-table tbody tr:hover { background: var(--surface-2); }

@media (max-width: 1200px) {
  .panel-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
}

/* ============ 移动端适配 / Mobile ============ */
@media (max-width: 860px) {
  .nav-toggle { display: grid; place-items: center; }
  .topbar { gap: 10px; padding: 0 12px; height: 56px; }
  .topbar h1 { font-size: 15px; }
  .topbar .crumb { font-size: 10px; }
  .topbar-right { gap: 7px; }
  .topbar-right .lang-switch button { padding: 4px 8px; font-size: 11px; }
  .user-chip .uname { display: none; }

  .sidebar {
    position: fixed; top: 0; left: 0; width: 258px; height: 100vh; flex-basis: 258px;
    transform: translateX(-100%); transition: transform .2s ease; z-index: 40;
    box-shadow: 8px 0 30px rgba(0,0,0,.3);
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35; background: rgba(8,15,30,.5);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .app-shell.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .view-root { padding: 14px 12px 40px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-head h2 { font-size: 18px; }
  .page-head > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-head .btn { flex: 1 1 auto; text-align: center; }

  .quick-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; -webkit-overflow-scrolling: touch; }
  .quick-filter-label { flex: 0 0 auto; }
  .quick-filter .chip { flex: 0 0 auto; white-space: nowrap; padding: 6px 12px; font-size: 12px; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 12px 13px; }
  .stat-value { font-size: 21px; }
  .panel-grid { gap: 12px; }
  .panel-head { font-size: 13px; }

  .filters, .compact-filters, .quick-add-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .filters .input, .filters .select, .compact-filters .input, .compact-filters .select,
  .quick-add-form .input, .quick-add-form .select { flex: 1 1 135px; min-width: 0; }
  .compact-filters .dash { display: none; }
  .batch-bar { padding: 8px 12px; gap: 6px; }
  .batch-bar .btn { flex: 1 1 auto; }

  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inline-table { min-width: 940px; }
  .inline-table th, .inline-table td { padding: 6px 5px; }
  .panel .data.compact { min-width: 480px; }
  .icon-btn { min-width: 30px; height: 30px; padding: 0 6px; }
  .pager { flex-wrap: wrap; gap: 8px; justify-content: center; }

  .modal { width: calc(100% - 24px); max-height: calc(100vh - 32px); }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding: 12px 16px; }
  .form-grid { gap: 12px; }
  .login-card { padding: 26px 20px; border-radius: 14px; }
  .login-screen { padding: 16px; }
}

@media (max-width: 480px) {
  .topbar-right .lang-switch { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 19px; }
  .panel-head { flex-direction: column; align-items: flex-start; }
  .panel-actions { width: 100%; }
  .detail-table th, .detail-table td { padding: 5px 6px; }
}
