@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');
/* tokens inlined — see also tokens.css */
:root {
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 20px 60px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.08);
  --ring: 0 0 0 3px var(--primary-soft, rgba(37, 99, 235, 0.16));
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 252px;
  --content-max: 1280px;
  --grad-primary: linear-gradient(135deg, #2563eb, #7c3aed);
  --grad-primary-hover: linear-gradient(135deg, #1d4ed8, #6d28d9);
}
/* Aligned with landing (blue primary + violet accent) */
[data-theme="light"] {
  --bg: #f8fafc; --bg-alt: #ffffff; --bg-panel: #ffffff; --bg-card: #ffffff;
  --bg-sidebar: #0f172a; --sidebar-text: #94a3b8; --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(124, 58, 237, 0.22); --sidebar-accent: #a78bfa;
  --text: #0f172a; --text-muted: #64748b;
  --border: #e2e8f0; --primary: #2563eb; --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.08); --accent: #7c3aed; --accent-soft: rgba(124, 58, 237, 0.1);
  --success: #059669; --warning: #d97706; --danger: #dc2626;
  --gradient-1: radial-gradient(ellipse 80% 60% at 20% 20%, rgba(124, 58, 237, 0.12), transparent);
  --gradient-2: radial-gradient(ellipse 70% 50% at 80% 10%, rgba(37, 99, 235, 0.1), transparent);
  --gradient-3: radial-gradient(ellipse 60% 40% at 50% 100%, rgba(16, 185, 129, 0.08), transparent);
}
[data-theme="dark"] {
  --bg: #0b1120; --bg-alt: #111827; --bg-panel: #1e293b; --bg-card: #1e293b;
  --bg-sidebar: #020617; --sidebar-text: #64748b; --sidebar-active: #f1f5f9;
  --sidebar-active-bg: rgba(167, 139, 250, 0.18); --sidebar-accent: #a78bfa;
  --text: #f1f5f9; --text-muted: #94a3b8;
  --border: #334155; --primary: #3b82f6; --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.15); --accent: #a78bfa; --accent-soft: rgba(167, 139, 250, 0.12);
  --success: #34d399; --warning: #fbbf24; --danger: #f87171;
  --gradient-1: radial-gradient(ellipse 80% 60% at 20% 20%, rgba(124, 58, 237, 0.2), transparent);
  --gradient-2: radial-gradient(ellipse 70% 50% at 80% 10%, rgba(37, 99, 235, 0.15), transparent);
  --gradient-3: radial-gradient(ellipse 60% 40% at 50% 100%, rgba(16, 185, 129, 0.1), transparent);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  height: 100%;
  margin: 0;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--primary); color: #fff; }

/* Focus visibility (a11y + polish) — only for keyboard nav, not mouse clicks */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* Slim, brand-tinted scrollbars */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 45%, transparent) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 40%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--primary) 55%, var(--text-muted)); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(167, 139, 250, 0.45); }

@keyframes content-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Shell: viewport locked; brand fixed; only nav + content scroll */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

/* —— Sidebar (landing dark nav feel) —— */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  background-image:
    radial-gradient(ellipse 120% 40% at 50% 0%, rgba(124, 58, 237, 0.16), transparent);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.sidebar-brand .brand-mark {
  width: 32px;
  height: 32px;
  padding: 6px;
  color: #fff;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--grad-primary);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.sidebar-brand span { color: var(--sidebar-accent, #a78bfa); }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 12px 10px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-label {
  padding: 14px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
}

.nav-group { margin-bottom: 4px; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.nav-group-toggle .nav-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform var(--transition);
}

.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-group-children {
  padding: 2px 0 6px 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  margin-left: 12px;
}

.nav-group.collapsed .nav-group-children {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 2px;
  font-weight: 500;
  font-size: 13px;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.nav-item .nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.72;
  transition: opacity var(--transition), transform var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  transform: translateX(1px);
}
.nav-item:hover .nav-icon { opacity: 0.95; }

.nav-item.active {
  background: linear-gradient(90deg, var(--sidebar-active-bg), rgba(124, 58, 237, 0.06));
  color: var(--sidebar-active);
  box-shadow: inset 3px 0 0 var(--sidebar-accent, #a78bfa);
  font-weight: 650;
}
.nav-item.active .nav-icon { opacity: 1; color: var(--sidebar-accent, #a78bfa); }

.nav-item.disabled { opacity: 0.35; pointer-events: none; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--sidebar-text);
  flex-shrink: 0;
}

.sidebar-footer strong { color: #fff; }

.sidebar-footer a {
  color: var(--sidebar-accent, #a78bfa);
  font-size: 12px;
}

.sidebar-footer .btn {
  border-color: rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
}
.sidebar-footer .btn:hover {
  border-color: var(--sidebar-accent, #a78bfa);
  color: #fff;
  background: rgba(167, 139, 250, 0.14);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  z-index: 90;
  border: none;
  padding: 0;
  cursor: pointer;
}

.btn-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-sidebar-toggle:hover { border-color: var(--primary); color: var(--primary); }
.btn-sidebar-toggle svg { width: 18px; height: 18px; }

/* —— Main —— */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  background-image: var(--gradient-1), var(--gradient-2), var(--gradient-3);
  background-attachment: local;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 10;
  gap: 12px;
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 35%, transparent 70%);
  opacity: 0.35;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn-notify .notify-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}
.btn-notify .notify-badge[hidden] { display: none !important; }

/* Logged-in user chip + dropdown */
.user-menu { position: relative; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  background: var(--bg-panel, #fff);
  cursor: pointer;
  font: inherit;
  color: inherit;
  max-width: 260px;
}
.user-chip:hover, .user-chip[aria-expanded="true"] {
  border-color: var(--primary, #2563eb);
  background: var(--primary-soft, #eef2ff);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary, #2563eb);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.user-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.user-role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text-muted);
  flex-shrink: 0;
}
.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--bg-panel, #fff);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.08));
  z-index: 80;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--primary-soft, #eef2ff); }
.user-dropdown .user-dd-danger { color: var(--danger, #b91c1c); }

@media (max-width: 720px) {
  .user-email { display: none; }
  .user-role-tag { display: none; }
}

/* Console language switch (shared with Landing storage key) */
.lang-switch { position: relative; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.lang-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 140px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
}
.lang-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.lang-menu li:hover,
.lang-menu li.active { background: var(--primary-soft); color: var(--primary); }

.content {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  padding: 20px max(24px, calc((100% - var(--content-max)) / 2 + 24px)) 28px;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  animation: content-fade-in 0.32s ease;
}

/* List pages: keep intro / filters / tabs fixed; only .table-scroll / .content-body scrolls */
.content:has(.table-scroll),
.content:has(.content-body) {
  overflow-y: hidden;
  padding-bottom: 20px;
}

.content > .page-intro,
.content > .filter-panel,
.content > .tab-bar,
.content > .inline-stat-row,
.content > .alert-cards,
.content > .info-banner,
.content > .toolbar,
.content > .stat-grid,
.content > .notif-hero,
.content > .notif-toolbar,
.content > #once,
.content > #banner,
.content > #msg,
.content > .pagination,
.content > .filter-actions {
  flex-shrink: 0;
}

.content-body,
.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
}

.table-scroll + .table-scroll {
  margin-top: 16px;
}

.content > .tabs:has(.table-scroll),
.content > .tabs:has(.content-body),
.content > .panel-section.active:has(.table-scroll) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content > .tabs > .tab-list {
  flex-shrink: 0;
}

.tab-panel.active:has(.table-scroll) {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.tab-panel.active:not(:has(.table-scroll)) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.tab-panel.active:has(.table-scroll) > .filter-panel,
.tab-panel.active:has(.table-scroll) > .toolbar,
.tab-panel.active:has(.table-scroll) > .page-intro,
.tab-panel.active:has(.table-scroll) > p,
.tab-panel.active:has(.table-scroll) > .filter-actions,
.tab-panel.active:has(.table-scroll) > .pagination,
.panel-section.active:has(.table-scroll) > .filter-panel,
.panel-section.active:has(.table-scroll) > .tab-bar,
.panel-section.active:has(.table-scroll) > .filter-actions {
  flex-shrink: 0;
}

.panel-section {
  display: none;
}
.panel-section.active {
  display: block;
}
.panel-section.active:has(.table-scroll) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Fallback: sticky filters on pages that still scroll as a whole */
.content:not(:has(.table-scroll)):not(:has(.content-body)) .filter-panel {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* —— Panels & cards —— */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.panel + .panel { margin-top: 20px; }

.panel h2, .panel h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Hero-style panel with a soft gradient wash — use for page-top intro panels */
.panel-hero {
  position: relative;
  overflow: hidden;
  background: var(--gradient-2), var(--gradient-1), var(--bg-panel);
  border: 1px solid var(--border);
}

/* Reusable circular icon badge (KPI cards, notif icons, hero panels, etc.) */
.icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
}
.icon-badge svg { width: 20px; height: 20px; }
.icon-badge.tone-success { background: rgba(5, 150, 105, 0.12); color: var(--success); border-color: rgba(5, 150, 105, 0.28); }
.icon-badge.tone-warning { background: rgba(217, 119, 6, 0.12); color: var(--warning); border-color: rgba(217, 119, 6, 0.28); }
.icon-badge.tone-danger { background: rgba(220, 38, 38, 0.1); color: var(--danger); border-color: rgba(220, 38, 38, 0.26); }
.icon-badge.tone-accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, var(--border)); }
.icon-badge.lg { width: 52px; height: 52px; border-radius: 14px; }
.icon-badge.lg svg { width: 26px; height: 26px; }

/* —— Buttons (landing) —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  background: var(--grad-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
}

.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
}
.btn-danger-outline:hover { background: rgba(220, 38, 38, 0.08); border-color: var(--danger); }

.btn-success-outline {
  background: transparent;
  border: 1px solid color-mix(in srgb, #059669 45%, var(--border));
  color: #047857;
}
.btn-success-outline:hover { background: rgba(5, 150, 105, 0.08); border-color: #059669; }

.btn-warn-outline {
  background: transparent;
  border: 1px solid color-mix(in srgb, #d97706 45%, var(--border));
  color: #b45309;
}
.btn-warn-outline:hover { background: rgba(217, 119, 6, 0.08); border-color: #d97706; }

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* Compact action button groups in admin tables */
.act-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 100%;
}
.act-row .btn {
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* —— Badges —— */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, var(--border));
  color: var(--text-muted);
}

.badge-success,
.badge.on,
.badge-on,
.badge.completed,
.badge.sent,
.badge-paid { background: rgba(5, 150, 105, 0.12); color: var(--success); }
.badge-warning,
.badge.pending,
.badge.uploaded,
.badge-pending { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.badge-muted,
.badge-other,
.badge.other { background: var(--primary-soft); color: var(--text-muted); }
.badge.off,
.badge-off,
.badge.failed,
.badge.void,
.badge.danger { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.badge.issued,
.badge.running { background: rgba(37, 99, 235, 0.12); color: var(--primary); }

/* —— Auth messages —— */
.auth-msg {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
  line-height: 1.45;
}
.auth-msg.err {
  display: block;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.auth-msg.ok {
  display: block;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.auth-lang { position: absolute; top: 16px; right: 16px; }
.auth-card { position: relative; }

.key-reveal {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  font-size: 13px;
  display: none;
}
.key-reveal.show { display: block; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 70%, var(--border));
  font-size: 12px;
  font-family: var(--font-mono);
}

.usage-bar {
  height: 6px;
  background: color-mix(in srgb, var(--bg) 60%, var(--border));
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}
.usage-bar > i { display: block; height: 100%; background: var(--primary); }
.usage-bar.warn > i { background: var(--warning); }
.usage-bar.danger > i { background: var(--danger); }

.review-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* —— KPI / stat grids —— */
.kpi-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card,
.stat-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow), border-color var(--transition);
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--grad-primary);
  opacity: 0.9;
}
.kpi-card.danger-tone::before { background: linear-gradient(135deg, var(--danger), #f97316); }
.kpi-card.info-tone::before { background: linear-gradient(135deg, var(--primary), #38bdf8); }
.kpi-card.success-tone::before { background: linear-gradient(135deg, var(--success), #34d399); }

.kpi-card:hover,
.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
}

.kpi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card strong,
.stat-card .stat-value {
  display: block;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-card span,
.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* —— Tables —— */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th,
table.data-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 75%, var(--bg-panel));
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
table.data-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

table.data-table tbody tr:last-child td { border-bottom: none; }

table.data-table tbody tr {
  transition: background var(--transition);
  box-shadow: inset 0 0 0 0 var(--primary);
}

table.data-table tbody tr:hover td { background: var(--primary-soft); }
table.data-table tbody tr:hover { box-shadow: inset 3px 0 0 0 var(--primary); }

table.data-table a { color: var(--primary); font-weight: 600; }

table.data-table a:hover { text-decoration: underline; }

.panel > .data-table,
.panel[style*="overflow"] .data-table {
  min-width: 640px;
}

/* —— Toolbar & forms —— */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 13px;
}

input, select, textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.5; }

/* —— Model cards —— */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.model-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.model-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.model-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.model-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }

/* —— Model marketplace checkout —— */
.market-page-head { margin-bottom: 20px; }
.market-page-title {
  font-size: clamp(1.35rem, 2vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.market-msg { margin: 12px 0; font-size: 13px; min-height: 1.2em; }
.market-filters {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.market-filter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
}
.market-filter-block {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}
.market-filter-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-muted);
  min-width: 72px;
}
.market-price-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.market-price-inputs input[type="number"] {
  width: 96px;
}
.market-price-sep { color: var(--text-muted); }
.market-filter-summary {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.market-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.market-card-title-row h3 { flex: 1; }
.market-card-title-row .tag { flex-shrink: 0; }
.market-card-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted, #f3f4f6);
}
.market-card-caps { margin: 0; }
.market-hero-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-muted, #f3f4f6);
}
.market-hero-desc {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 52rem;
}
@media (max-width: 900px) {
  .market-filter-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .market-filter-row { grid-template-columns: 1fr; }
}
.market-back { font-size: 13px; margin-bottom: 14px; }
.market-back a { color: var(--primary); text-decoration: none; font-weight: 600; }
.market-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.market-card-top h3 { margin: 0 0 4px; }
.market-card-provider {
  margin: 0 !important;
  font-size: 12px !important;
  color: var(--text-muted);
}
.market-card-desc {
  flex: 1;
  margin: 0 !important;
  font-size: 13px !important;
  line-height: 1.55 !important;
}
.market-card-meta {
  list-style: none;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
}
.market-card-meta li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.market-card-meta span { color: var(--text-muted); }
.market-card-meta strong { font-weight: 650; text-align: right; }
.market-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.market-card-actions .btn { flex: 1; }
.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.75fr);
  gap: 16px;
  align-items: start;
}
.market-hero h1 {
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  margin: 8px 0 6px;
  letter-spacing: -0.02em;
}
.market-hero .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th, .kv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv th { width: 140px; color: var(--text-muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.pkg-card {
  display: block;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}
.pkg-card input { position: absolute; opacity: 0; pointer-events: none; }
.pkg-card-body { padding: 14px; }
.pkg-card:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.pkg-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--bg-panel);
}
.pkg-card-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.pkg-card-price {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--primary);
  margin-bottom: 10px;
}
.pkg-card-feats {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
.market-paybox { position: sticky; top: 16px; }
.paybox-summary {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}
.paybox-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.paybox-summary span { color: var(--text-muted); }
.paybox-amount { color: var(--primary); font-size: 18px; }
.paybox-actions {
  display: grid;
  gap: 8px;
}
.payg-price-hero {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 6px;
}
.payg-price-hero strong {
  font-size: 28px;
  letter-spacing: -0.03em;
  color: var(--primary);
}
.payg-price-hero span { color: var(--text-muted); font-size: 13px; }
.payg-example {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.payg-example > div {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}
.payg-example span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.payg-example strong { font-size: 15px; }
.amount-presets { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 900px) {
  .market-layout { grid-template-columns: 1fr; }
  .market-paybox { position: static; }
}

/* —— Auth pages —— */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: var(--gradient-1), var(--gradient-2), var(--gradient-3);
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  animation: content-fade-in 0.35s ease;
}

.auth-card .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 800;
  font-size: 20px;
}

.auth-card .brand-mark {
  width: 36px;
  height: 36px;
  padding: 7px;
  color: #fff;
  border-radius: 11px;
  background: var(--grad-primary);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.auth-card h1 { font-size: 22px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.02em; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }

.auth-card .btn-primary { width: 100%; padding: 12px; margin-top: 8px; }

/* —— Auth split layout (premium two-column login/register) —— */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 460px);
  background: var(--bg);
}
.auth-hero {
  position: relative;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  color: #fff;
  background: radial-gradient(ellipse 90% 70% at 15% 10%, rgba(124, 58, 237, 0.55), transparent),
    radial-gradient(ellipse 80% 60% at 85% 90%, rgba(37, 99, 235, 0.5), transparent),
    #0f172a;
  overflow: hidden;
}
.auth-hero-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.auth-hero-brand .brand-mark {
  width: 34px; height: 34px; padding: 7px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.14); color: #fff;
}
.auth-hero-title {
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.28;
  max-width: 20ch;
  margin: 0;
}
.auth-hero-sub { color: rgba(255, 255, 255, 0.72); font-size: 14px; line-height: 1.65; max-width: 42ch; margin-top: 14px; }
.auth-hero-feats { list-style: none; margin: 32px 0 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.auth-hero-feats li { display: flex; align-items: flex-start; gap: 12px; font-size: 13px; color: rgba(255, 255, 255, 0.85); }
.auth-hero-feats .feat-icon {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px;
  background: rgba(255, 255, 255, 0.12); display: inline-flex; align-items: center; justify-content: center;
}
.auth-hero-feats .feat-icon svg { width: 15px; height: 15px; }
.auth-hero-foot { font-size: 12px; color: rgba(255, 255, 255, 0.5); }
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  background-image: var(--gradient-1), var(--gradient-3);
  position: relative;
}
.auth-form-side .auth-card { box-shadow: var(--shadow-xl); border: 1px solid var(--border); }
.auth-form-side .auth-lang { position: absolute; top: 20px; right: 20px; }
.auth-shell { grid-template-columns: 1fr; }
@media (min-width: 980px) {
  .auth-hero { display: flex; }
  .auth-shell { grid-template-columns: minmax(0, 1.05fr) minmax(360px, 460px); }
}

.mock-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  background: rgba(217, 119, 6, 0.1);
  padding: 5px 10px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}
.mock-tag.live {
  color: var(--success);
  background: rgba(5, 150, 105, 0.1);
}

.topbar-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.topbar-link:hover { color: var(--primary); }

/* —— Tabs —— */
.tabs { margin-bottom: 0; }
.tab-list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* —— Progress —— */
.progress-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  border-radius: 999px;
}

/* —— Split / chat —— */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .split-grid { grid-template-columns: 1fr; } }

.chat-box {
  min-height: 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
}
.chat-msg { margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; max-width: 90%; }
.chat-msg.user { background: var(--primary-soft); margin-left: auto; }
.chat-msg.assistant { background: var(--bg-panel); border: 1px solid var(--border); }

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.chat-bubble .chat-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
}
.chat-bubble .chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-bubble .chat-meta {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.chat-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 16px;
}

.playground-kind-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.kind-tab {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.kind-tab:hover { border-color: var(--primary); color: var(--primary); }
.kind-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.cap-chip {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #f3f4f6;
}
.cap-chip.in { background: #eef2ff; }
.cap-chip.out { background: #ecfdf5; }
.cap-chip.kind { background: #fef3c7; }

/* —— Playground (FM-U03) —— */
.playground-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
}
.playground-banner strong { color: var(--warning); }

.playground-layout {
  display: grid;
  grid-template-columns: minmax(280px, 32%) 1fr;
  gap: 20px;
  min-height: calc(100vh - 200px);
}
@media (max-width: 1024px) {
  .playground-layout { grid-template-columns: 1fr; min-height: auto; }
}

.playground-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.playground-config .panel { margin: 0; }
.config-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.param-row label { font-weight: 500; min-width: 100px; }
.param-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.param-row .param-value {
  min-width: 36px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.template-chip {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.template-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.playground-chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  padding: 0;
  overflow: hidden;
}
.playground-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.playground-toolbar .session-title {
  font-weight: 700;
  font-size: 14px;
}
.playground-toolbar-actions { display: flex; gap: 8px; }

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 50%, transparent);
}
.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.chat-msg-meta {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.chat-msg.user .chat-msg-meta { color: rgba(255,255,255,0.85); }
.chat-msg.assistant .chat-msg-meta { color: var(--text-muted); }
.chat-msg.system {
  align-self: center;
  max-width: 100%;
  background: var(--accent-soft);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.playground-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.playground-file-actions .file-pick { cursor: pointer; font-size: 12px; }
.playground-file-actions .file-pick.is-muted { opacity: 0.55; }
.playground-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.playground-file-preview .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
}
.playground-file-preview .file-chip img,
.playground-file-preview .file-chip video {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}
.playground-file-preview .file-chip audio {
  max-width: 220px;
  height: 32px;
}
.playground-file-preview .file-chip-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.playground-input-bar {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: var(--bg-panel);
  flex-shrink: 0;
}
.playground-input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.playground-input-row textarea {
  flex: 1;
  min-height: 72px;
  max-height: 160px;
  resize: vertical;
}
.playground-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.playground-stats strong { color: var(--text); }

.saved-list {
  list-style: none;
  font-size: 13px;
}
.saved-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.saved-list li:last-child { border-bottom: none; }
.saved-list button {
  font-size: 12px;
  padding: 4px 10px;
}

.chart-placeholder {
  height: 200px;
  background: linear-gradient(180deg, var(--primary-soft), transparent);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.chart-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-box h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.chart-canvas-wrap {
  position: relative;
  height: 260px;
}
.chart-canvas-wrap.sm { height: 220px; }

.period-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-panel);
}
.period-toggle button {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.period-toggle button.active {
  background: var(--primary);
  color: #fff;
}
.period-toggle button:not(.active):hover {
  background: var(--primary-soft);
  color: var(--text);
}

/* —— Audit logs / Team (FM-U07 · FM-U08) —— */
.filter-panel { margin-bottom: 10px; flex-shrink: 0; }
.filter-panel.panel {
  /* Keep opaque when sticky / above scrolling tables */
  background: var(--bg-panel);
  padding: 14px 16px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: 10px;
  align-items: end;
}
.filter-grid > .form-group {
  margin: 0;
  min-width: 0;
}
.filter-grid > .form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.filter-grid > .form-group input[type="date"],
.filter-grid > .form-group input[type="datetime-local"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.input-date {
  min-height: 40px;
  padding: 8px 40px 8px 12px;
  color-scheme: light;
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
  background-color: var(--bg-panel);
  position: relative;
}
/* Hide native icon; .date-field-trigger + showPicker() provide a clear control */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.date-field {
  position: relative;
  display: block;
  width: 100%;
}
.date-field input[type="date"],
.date-field input[type="month"],
.date-field input[type="datetime-local"],
.date-field .input-date {
  width: 100%;
  padding-right: 40px;
}
.date-field-trigger {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}
.date-field-trigger:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
/* Chips / wide controls: span two columns when space allows */
.filter-grid > .form-group:has(.filter-chips),
.filter-grid > .form-group.filter-span-2 {
  grid-column: span 2;
}
.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
}
.filter-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}
@media (max-width: 1200px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid > .form-group:has(.filter-chips),
  .filter-grid > .form-group.filter-span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid > .form-group:has(.filter-chips),
  .filter-grid > .form-group.filter-span-2 { grid-column: auto; }
}
.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-range input { width: auto; flex: 1; min-width: 0; }
.date-sep { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  color: var(--text-muted);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.type-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}
.mono-sm { font-family: var(--font-mono); font-size: 12px; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }
.sort-icon { font-size: 10px; opacity: 0.7; }

.table-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.pagination-info { font-size: 13px; color: var(--text-muted); }

.alert-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.alert-card {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}
.alert-card-warning {
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.06);
}
.alert-card-icon { font-size: 22px; line-height: 1; }
.alert-card-body strong { display: block; margin-bottom: 4px; font-size: 14px; }
.alert-card-body p { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.alert-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 200;
}
.drawer-overlay[hidden] { display: none; }
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.detail-drawer.open { transform: translateX(0); }
/* Centered detail panel (preferred for model catalog etc.) */
.detail-drawer.detail-drawer--center {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(720px, calc(100vw - 48px));
  height: auto;
  max-height: min(88vh, 900px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -46%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.detail-drawer.detail-drawer--center.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.detail-drawer.detail-drawer--center .drawer-body {
  max-height: calc(min(88vh, 900px) - 72px);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h2 { font-size: 16px; font-weight: 700; }
.drawer-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.drawer-close:hover { background: var(--primary-soft); color: var(--primary); }
.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }

.detail-list { font-size: 13px; }
.detail-list.grid,
.detail-list.dl-grid {
  display: grid;
  grid-template-columns: minmax(110px, 160px) 1fr;
  gap: 10px 16px;
  margin: 0;
}
.detail-list.grid dt,
.detail-list.dl-grid dt {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
}
.detail-list.grid dd,
.detail-list.dl-grid dd {
  margin: 0;
  word-break: break-all;
}
.detail-list dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 16px;
  margin-bottom: 4px;
}
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { margin: 0; line-height: 1.5; }
.text-danger { color: var(--danger); }

.info-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.info-banner strong { font-size: 15px; display: block; margin-bottom: 2px; }
.info-banner-meta { font-size: 13px; color: var(--text-muted); }

.role-list { display: flex; flex-direction: column; gap: 10px; }
.role-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.role-card:hover { border-color: var(--primary); }
.role-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}
.role-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.role-card p { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.role-perm-count { font-size: 11px; font-weight: 600; color: var(--primary); }
.role-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--text-muted);
}
.role-tag.custom { background: var(--accent-soft); color: var(--accent); }

.perm-tree { display: flex; flex-direction: column; gap: 16px; }
.perm-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.perm-leaf {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
}
.perm-leaf input { width: auto; flex-shrink: 0; }
.perm-code {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.perm-panel-actions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }

/* Alias used by Admin Live pages */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay[hidden] { display: none !important; }

.modal {
  width: min(480px, 100%);
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-height: 90vh;
  overflow: auto;
}
.overlay .modal:not(:has(.modal-header)) { padding: 22px 24px; }
.overlay .modal h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 10px;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* —— KYC 企业实名（FM-U09） —— */
/* Fill content column (already capped by --content-max padding) — avoid left-aligned 920px gap */
.kyc-page {
  width: 100%;
  max-width: none;
}

.kyc-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 20px;
  margin-bottom: 24px;
  align-items: stretch;
}
.kyc-hero-copy {
  position: relative;
  overflow: hidden;
  padding: 28px 28px 24px;
  border-radius: var(--radius-lg);
  background:
    var(--gradient-2),
    var(--gradient-1),
    var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.kyc-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}
.kyc-hero-title {
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 10px;
  color: var(--text);
}
.kyc-hero-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 18px;
  max-width: 56ch;
}
.kyc-benefit-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.kyc-benefit-list li {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
}

.kyc-mock-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: rgba(217, 119, 6, 0.08);
  border: 1px dashed rgba(217, 119, 6, 0.35);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
}
.kyc-mock-bar .filter-chip { padding: 4px 12px; font-size: 11px; }

.kyc-status-card {
  margin: 0;
  padding: 22px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.kyc-status-card[data-status="pending"] { border-color: rgba(217, 119, 6, 0.35); }
.kyc-status-card[data-status="approved"] { border-color: rgba(5, 150, 105, 0.35); }
.kyc-status-card[data-status="rejected"] { border-color: rgba(220, 38, 38, 0.3); }
.kyc-status-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.kyc-status-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}
.kyc-status-icon svg { width: 26px; height: 26px; }
.kyc-status-icon.pending {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--warning);
}
.kyc-status-icon.approved {
  background: rgba(5, 150, 105, 0.12);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--success);
}
.kyc-status-icon.rejected {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--danger);
}
.kyc-status-text { min-width: 0; flex: 1; }
.kyc-status-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.kyc-status-title-row h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.kyc-status-text p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}
.kyc-status-meta {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.kyc-reject-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-radius: var(--radius);
  font-size: 13px;
}
.kyc-reject-box strong { display: block; margin-bottom: 6px; color: var(--danger); }
.kyc-reject-box p { margin: 0; color: var(--text); line-height: 1.5; }

.kyc-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-panel) 70%, var(--border));
  border: 1px solid var(--border);
}
.kyc-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.kyc-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.kyc-step.is-active {
  background: var(--bg-panel);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.kyc-step.is-active .kyc-step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.kyc-step.is-done { color: var(--success); }
.kyc-step.is-done .kyc-step-num {
  background: rgba(5, 150, 105, 0.12);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--success);
}

.kyc-form { display: flex; flex-direction: column; gap: 16px; }
.kyc-form .panel { margin: 0; }
.kyc-section { padding: 22px 24px 8px; }
.kyc-section-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.kyc-section-index {
  flex-shrink: 0;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
}
.kyc-section-index--ok {
  color: var(--success);
  background: rgba(5, 150, 105, 0.12);
}
.kyc-section-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.kyc-section-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.kyc-optional {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}
.kyc-invoice-block {
  margin: 4px 0 18px;
  padding: 16px 16px 4px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px dashed var(--border);
}
.kyc-invoice-block h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 20px;
}
.form-grid-full { grid-column: 1 / -1; }
.req { color: var(--danger); }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.upload-zone {
  border: 1.5px dashed color-mix(in srgb, var(--border) 70%, var(--primary));
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  background: linear-gradient(180deg, var(--bg-panel), var(--bg));
  outline: none;
}
.upload-zone:hover, .upload-zone.dragover, .upload-zone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
  transform: translateY(-1px);
}
.upload-zone.has-file {
  border-color: var(--success);
  border-style: solid;
  background: rgba(5, 150, 105, 0.06);
}
.upload-zone-inner { pointer-events: none; }
.upload-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--primary);
}
.upload-icon svg { width: 22px; height: 22px; }
.upload-zone.has-file .upload-icon {
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.1);
}
.upload-zone strong { display: block; font-size: 13px; margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }
.upload-filename {
  display: block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  word-break: break-all;
}

.kyc-form-actions {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}
.kyc-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  cursor: pointer;
  line-height: 1.5;
}
.kyc-agree input { width: auto; margin-top: 3px; flex-shrink: 0; }
.kyc-form-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.kyc-form-actions-row .form-hint { margin: 0; flex: 1; min-width: 200px; }
.kyc-form-actions-row .btn { min-width: 140px; }

.kyc-summary-panel { margin-bottom: 20px; }
.kyc-summary-list { margin-top: 8px; }
.kyc-contract-cta { margin-top: 8px; }
.kyc-contract-cta .kyc-section-head { margin-bottom: 16px; }

@media (max-width: 900px) {
  .kyc-hero { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
  .kyc-step-label { display: none; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .kyc-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kyc-hero-copy { padding: 20px; }
  .kyc-form-actions { bottom: 8px; }
}

/* —— Console 站内信 / 消息 —— */
.notif-page { width: 100%; }
.notif-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
}
.notif-hero-copy {
  padding: 24px 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--gradient-2), var(--bg-panel);
  box-shadow: var(--shadow);
}
.notif-hero-copy h1 {
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.notif-hero-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 56ch;
}
.notif-kpi {
  min-width: 140px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.notif-kpi strong {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--primary);
  line-height: 1;
}
.notif-kpi span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.notif-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.notif-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.notif-list {
  padding: 0;
}
.notif-list:not(.table-scroll) {
  overflow: hidden;
}
.notif-empty {
  padding: 48px 24px;
  text-align: center;
}
.notif-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
}
.notif-empty-icon svg { width: 26px; height: 26px; }
.notif-empty h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.notif-empty p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.notif-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: color-mix(in srgb, var(--bg) 65%, var(--bg-panel)); }
.notif-item.is-unread {
  background: linear-gradient(90deg, var(--primary-soft), transparent 48%);
}
.notif-item.is-unread .notif-title { color: var(--text); }
.notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.notif-icon svg { width: 18px; height: 18px; }
.notif-icon.cat-kyc,
.notif-icon.cat-billing { color: var(--primary); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.notif-icon.cat-budget,
.notif-icon.cat-alert { color: var(--warning); background: rgba(217, 119, 6, 0.1); border-color: rgba(217, 119, 6, 0.28); }
.notif-icon.cat-system { color: var(--text-muted); }
.notif-main { min-width: 0; }
.notif-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.notif-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.notif-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  margin: 0 0 8px;
}
.notif-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.notif-meta a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.notif-meta a:hover { text-decoration: underline; }
.notif-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10050;
  display: none;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.14),
    0 4px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid transparent;
  pointer-events: none;
  word-break: break-word;
}
.toast.show {
  display: block;
  animation: toast-in 0.22s ease;
}
.toast.ok {
  color: #065f46;
  background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 100%);
  border-color: #a7f3d0;
  box-shadow:
    inset 3px 0 0 #10b981,
    0 18px 40px rgba(15, 23, 42, 0.14),
    0 4px 12px rgba(15, 23, 42, 0.06);
}
.toast.err {
  color: #991b1b;
  background: linear-gradient(180deg, #fef2f2 0%, #fff1f2 100%);
  border-color: #fecaca;
  box-shadow:
    inset 3px 0 0 #ef4444,
    0 18px 40px rgba(15, 23, 42, 0.14),
    0 4px 12px rgba(15, 23, 42, 0.06);
}
[data-theme="dark"] .toast.ok {
  color: #a7f3d0;
  background: linear-gradient(180deg, #064e3b 0%, #052e26 100%);
  border-color: #047857;
  box-shadow:
    inset 3px 0 0 #34d399,
    0 18px 40px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .toast.err {
  color: #fecaca;
  background: linear-gradient(180deg, #7f1d1d 0%, #450a0a 100%);
  border-color: #b91c1c;
  box-shadow:
    inset 3px 0 0 #f87171,
    0 18px 40px rgba(0, 0, 0, 0.35);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* —— Console API Keys —— */
.key-once-banner {
  margin-bottom: 16px;
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.28);
  font-size: 13px;
  line-height: 1.55;
}
.key-once-code {
  display: inline-block;
  margin-top: 8px;
  word-break: break-all;
  font-size: 13px;
}
.key-reveal-masked {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg, #f8fafc) 88%, var(--border, #e2e8f0));
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text-muted, #64748b);
  letter-spacing: 0.04em;
  user-select: none;
}
.key-reveal-confirm {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.28);
  color: #047857;
  font-size: 13px;
  line-height: 1.55;
}
.key-models-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.45;
}
.key-models-toggle input { width: auto; margin-top: 2px; flex-shrink: 0; }
.key-models-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.key-models-head label { margin: 0; }
.key-models-tools { display: flex; gap: 6px; }
.key-model-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface, #fff);
}
.key-model-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg, #f8fafc);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.key-model-item:hover {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
}
.key-model-item:has(input:checked) {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--bg, #f8fafc));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}
.key-model-item input { width: auto; margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); }
.key-model-item.is-orphan {
  opacity: 0.72;
  border-style: dashed;
}
.key-model-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.key-model-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  font-weight: 600;
  color: var(--text);
}
.key-model-name { word-break: break-word; }
.key-model-id {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  word-break: break-all;
}
.key-model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.key-model-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
}
.key-model-tag.is-sub {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}
.key-model-tag.is-payg {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}
.key-model-tag.is-provider {
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border) 35%, transparent);
  border-color: var(--border);
}
.key-model-tag.is-warn {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}
.key-models-empty a {
  margin-left: 4px;
  color: var(--primary);
  text-decoration: none;
}
.key-models-empty a:hover { text-decoration: underline; }
.ops-cell { white-space: nowrap; }

@media (max-width: 720px) {
  .notif-hero { grid-template-columns: 1fr; }
  .notif-item { grid-template-columns: 40px minmax(0, 1fr); }
  .notif-actions { grid-column: 2; flex-direction: row; justify-content: flex-start; }
}

/* —— Admin 页面通用（§9.x） —— */
.page-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.55;
  max-width: 72ch;
}
.content > .filter-panel + .table-scroll,
.content > .filter-panel + .panel.table-scroll,
.content > .page-intro + .filter-panel {
  margin-top: 0;
}
.content > .filter-panel + .panel {
  margin-top: 8px;
}
.table-scroll.panel,
.panel.table-scroll {
  margin-top: 8px;
}

/* Confirm dialog (archive / shared EmLogicConfirm) */
.confirm-modal {
  width: min(440px, 100%);
  max-width: none;
  overflow: hidden;
}
.confirm-modal .confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff7ed;
  color: #c2410c;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
  line-height: 1;
}
.confirm-modal.tone-danger .confirm-icon {
  background: #fef2f2;
  color: #b91c1c;
}
.confirm-modal.tone-info .confirm-icon {
  background: #eff6ff;
  color: #1d4ed8;
}
.confirm-modal .confirm-body-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.confirm-modal .confirm-copy { min-width: 0; flex: 1; }
.confirm-modal .confirm-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}
.confirm-modal .confirm-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}
.confirm-modal .confirm-meta {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg, #f8fafc);
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
  word-break: break-all;
}
.confirm-modal .confirm-prompt label {
  font-size: 12px;
  font-weight: 600;
}
.confirm-modal .confirm-prompt input.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}
.page-intro code {
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 80%, var(--border));
  color: var(--text);
}

.inline-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.inline-stat {
  padding: 14px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.inline-stat .label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.inline-stat .value { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.inline-stat .value.danger { color: var(--danger); }
.inline-stat .value.success { color: var(--success); }
.inline-stat .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.admin-toolbar input, .admin-toolbar select { width: auto; min-width: 140px; }
.admin-toolbar .spacer { flex: 1; min-width: 8px; }

.split-detail {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) { .split-detail { grid-template-columns: 1fr; } }

.detail-side-panel {
  position: sticky;
  top: 16px;
}
.detail-side-panel h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.timeline {
  list-style: none;
  font-size: 13px;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  padding-left: 20px;
}
.timeline li {
  position: relative;
  padding-bottom: 16px;
  color: var(--text-muted);
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.timeline li.active { color: var(--text); font-weight: 600; }
.timeline li.active::before { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline li.done::before { background: var(--success); }

.perm-tree-admin { font-size: 13px; line-height: 1.8; }
.perm-tree-admin .perm-folder { font-weight: 600; margin-top: 8px; }
.perm-tree-admin .perm-leaf-item { padding-left: 20px; color: var(--text-muted); }
.perm-tree-admin .perm-leaf-item code { font-size: 11px; margin-right: 8px; }

.preview-box {
  min-height: 200px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.kpi-card .trend-up { color: var(--success); font-size: 13px; font-weight: 600; }
.kpi-card .trend-down { color: var(--danger); font-size: 13px; font-weight: 600; }
.kpi-card.danger-tone strong { color: var(--danger); }
.kpi-card.info-tone strong { color: var(--primary); }

.shortcut-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; }

/* —— Responsive shell —— */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-backdrop { display: block; }
  .btn-sidebar-toggle { display: inline-flex; }
  .content { padding: 16px 16px 32px; max-width: none; }
  .topbar { padding: 0 14px; height: 56px; }
  .topbar-title { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid, .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card, .kpi-card { padding: 14px 16px; }
  .stat-card .stat-value, .kpi-card strong { font-size: 20px; }
  .detail-drawer { width: 100vw; }
  .detail-drawer.detail-drawer--center {
    width: calc(100vw - 24px);
    max-height: 92vh;
  }
  .filter-hint { margin-left: 0; width: 100%; }
  /* Narrow topbar: keep actions usable — email lives in title / dropdown */
  .user-email { display: none; }
  .user-chip { max-width: 148px; }
  .topbar-actions { flex-wrap: nowrap; gap: 6px; }
  .topbar-actions .btn { white-space: nowrap; }
}

@media (max-width: 520px) {
  .stat-grid, .kpi-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn .btn-label-hide-sm { display: none; }
}
