/* Boost Manager — modern dark/light theme system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root,
[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-elevated: #111820;
  --surface: #151d27;
  --surface-2: #1a2430;
  --border: #243041;
  --border-strong: #2f4056;
  --text: #e8eef6;
  --text-muted: #8b9bb0;
  --text-dim: #5c6d82;
  /* Fact/payout micro-headers: stronger than muted, softer than primary text */
  --text-label: #b7c5d6;
  --primary: #2dd4bf;
  --primary-hover: #14b8a6;
  --primary-soft: rgba(45, 212, 191, 0.14);
  --primary-ink: #04201c;
  --accent: #5865f2;
  --accent-soft: rgba(88, 101, 242, 0.15);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.12);
  --btn-secondary-bg: rgba(45, 212, 191, 0.08);
  --btn-secondary-border: rgba(45, 212, 191, 0.35);
  --btn-secondary-text: #99f6e4;
  --btn-ghost-hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --glow: 0 0 40px rgba(45, 212, 191, 0.08);
  --hero-grad: radial-gradient(ellipse 80% 60% at 20% 20%, rgba(45, 212, 191, 0.18), transparent 55%),
               radial-gradient(ellipse 70% 50% at 90% 10%, rgba(88, 101, 242, 0.14), transparent 50%),
               linear-gradient(165deg, #0b0f14 0%, #0e1520 50%, #0b1218 100%);
  --feed-item-bg: linear-gradient(135deg, #151d27 0%, #121a22 100%);
  --input-bg: #0e141c;
  --scrollbar: #243041;
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --border: #d8e0ea;
  --border-strong: #c0ccd8;
  --text: #0f172a;
  --text-muted: #5a6a7e;
  --text-dim: #8494a7;
  /* Fact/payout micro-headers: stronger than muted, softer than primary text */
  --text-label: #3d4f63;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.12);
  --primary-ink: #ffffff;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --error: #dc2626;
  --error-soft: rgba(220, 38, 38, 0.1);
  --btn-secondary-bg: rgba(13, 148, 136, 0.08);
  --btn-secondary-border: rgba(13, 148, 136, 0.32);
  --btn-secondary-text: #0f766e;
  --btn-ghost-hover: rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
  --glow: 0 0 40px rgba(13, 148, 136, 0.06);
  --hero-grad: radial-gradient(ellipse 80% 60% at 15% 10%, rgba(13, 148, 136, 0.12), transparent 55%),
               radial-gradient(ellipse 60% 40% at 90% 0%, rgba(79, 70, 229, 0.08), transparent 50%),
               linear-gradient(165deg, #eef3f8 0%, #f5f8fb 100%);
  --feed-item-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  --input-bg: #ffffff;
  --scrollbar: #c0ccd8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html {
  scroll-behavior: smooth;
  /* clip (not hidden) so position:sticky sidebars keep working */
  overflow-x: clip;
  max-width: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

body.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

code, .mono, .mono-input {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  align-self: start;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 24px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  color: #041016;
  box-shadow: var(--glow);
}

.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 500;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-icon {
  width: 20px;
  text-align: center;
  opacity: 0.85;
  font-size: 1rem;
}

.nav-sep {
  height: 1px;
  margin: 10px 12px 6px;
  background: var(--border-strong);
  opacity: 0.85;
}

.nav-item-admin {
  margin-top: 2px;
  color: var(--text-muted);
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.nav-item-admin .nav-icon {
  color: var(--warning);
  opacity: 1;
}

.nav-item-admin:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.nav-item-admin.active {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta { min-width: 0; }
.user-meta .name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta .role {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.sidebar-tools {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 0 4px;
  align-items: stretch;
}

.tool-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tool-btn:hover, .tool-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ── Top strip (mobile / content header) ── */
.content-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  min-height: 100vh;
}

.top-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.main {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1200px;
  width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.main.full-bleed {
  max-width: none;
  padding: 0;
}

.footer-mini {
  padding: 16px 32px 28px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Public layout (landing / auth) */
body.public-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--hero-grad);
  background-attachment: fixed;
  overflow-x: hidden;
}

.public-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex-wrap: wrap;
}

.public-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.public-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.public-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
}

.public-main > .alert {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.public-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-ink);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn-accent:hover { filter: brightness(1.08); color: #fff; }

.btn-outline,
.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--btn-secondary-text);
}
.btn-outline:hover,
.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--btn-ghost-hover);
}

.btn-danger {
  background: var(--error-soft);
  color: var(--error);
  border-color: transparent;
}
.btn-danger:hover { border-color: var(--error); }

.btn-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ── Cards / surfaces ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-highlight {
  border-color: rgba(45, 212, 191, 0.35);
  background: var(--primary-soft);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-head h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-body {
  padding: 16px 20px 20px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-header .sub {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

.role-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.role-pill {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-new {
  background: var(--primary);
  color: #04201c;
  animation: pulse-badge 2s ease-in-out infinite;
}

.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-accepted, .badge-open, .badge-approved, .badge-paid, .badge-completed {
  background: var(--success-soft); color: var(--success);
}
.badge-rejected, .badge-archived, .badge-cancelled {
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-cancelled { color: #c45c5c; }
.badge-in_progress { background: var(--accent-soft); color: var(--accent); }
.badge-closed { background: var(--success-soft); color: var(--success); }

.order-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.order-actions .action-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-actions .action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.order-actions .cancel-reason-input {
  width: 100%;
  max-width: 420px;
}

@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(45, 212, 191, 0); }
}

/* ── Order feed ── */
.feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  display: block;
  background: var(--feed-item-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.25s;
  animation: feed-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative;
  overflow: hidden;
}

.order-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s;
}

.order-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.order-card:hover::before { background: var(--primary); }

.order-card.unread {
  border-color: rgba(45, 212, 191, 0.35);
}
.order-card.unread::before { background: var(--primary); }

.order-card:nth-child(1) { animation-delay: 0.02s; }
.order-card:nth-child(2) { animation-delay: 0.07s; }
.order-card:nth-child(3) { animation-delay: 0.12s; }
.order-card:nth-child(4) { animation-delay: 0.17s; }
.order-card:nth-child(5) { animation-delay: 0.22s; }
.order-card:nth-child(n+6) { animation-delay: 0.27s; }

@keyframes feed-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.order-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.order-card-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.order-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.order-meta {
  display: block;
}

.order-meta-structured {
  margin-top: 10px;
}

.order-card-badges,
.detail-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge-role {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.order-facts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
}

.order-facts-compact {
  gap: 8px;
}

.fact-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.fact-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fact-label {
  color: var(--text-label);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.fact-value {
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.fact-key-level {
  color: var(--text);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.fact-key-dungeon {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fact-money {
  color: var(--warning);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.fact-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.fact-block > .fact-label {
  margin-bottom: 2px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.06em;
}

.fact-keys-block {
  gap: 4px;
}

.fact-keys {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fact-keys li {
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: var(--text);
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.3;
}

.fact-keys .key-star {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 0.75rem;
}

.fact-keys .key-pref .key-star {
  color: var(--text-muted);
}

.fact-keys .key-lvl {
  color: var(--primary);
  font-weight: 800;
}

.fact-keys .key-flag {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
}

.fact-pay {
  gap: 6px;
  padding-top: 8px;
}

/* Isolated 3-col payment grid — independent of card footer */
.fact-pay-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 10px;
  row-gap: 0;
  width: 100%;
  box-sizing: border-box;
}

.fact-pay-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fact-pay-left {
  text-align: left;
  justify-self: stretch;
}

.fact-pay-right {
  text-align: right;
  justify-self: stretch;
}

.fact-pay-right .fact-pay-item {
  align-items: flex-end;
}

.fact-pay-bank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  gap: 1px;
  padding: 0 6px;
  min-width: 0;
  justify-self: center;
}

.fact-pay-bank-icon {
  font-size: 0.92rem;
  line-height: 1;
  margin-bottom: 0;
}

.fact-pay-bank .fact-label {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-label);
}

.fact-money-bank {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--warning);
  line-height: 1.2;
}

.fact-pay-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.fact-pay-item .fact-label {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-label);
}

.fact-pay-item .fact-value {
  font-size: 0.82rem;
  font-weight: 600;
}

.fact-pay-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fact-pay-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fact-pay-line .fact-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-label);
}

.fact-pay-line .fact-value {
  font-size: 0.9rem;
  font-weight: 600;
}

.fact-pay-grid .fact-value {
  font-size: 0.9rem;
}

.fact-pay-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}

.fact-over {
  color: var(--error);
}

.fact-warn {
  margin-top: 2px;
  color: var(--error);
  font-size: 0.8rem;
  font-weight: 700;
}

.fact-role-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.fact-role-line .fact-value {
  font-size: 0.9rem;
}

.order-facts-compact .fact-pay {
  gap: 5px;
  padding-top: 6px;
}

.order-facts-compact .fact-pay-grid {
  column-gap: 8px;
}

.order-facts-compact .fact-pay-side {
  gap: 5px;
}

.order-facts-compact .fact-money-bank {
  font-size: 0.88rem;
}

.order-facts-compact .fact-pay-item .fact-value {
  font-size: 0.78rem;
}

.order-facts-compact .fact-pay-bank-icon {
  font-size: 0.85rem;
}

/* legacy row layout kept for any leftover markup */
.fact-row {
  display: grid;
  grid-template-columns: minmax(88px, 34%) 1fr;
  gap: 8px 12px;
  align-items: baseline;
}

.fact-pay-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fact-role {
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.meta-chip.gold {
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.25);
  background: var(--warning-soft);
}

.meta-chip.key {
  color: var(--primary);
  border-color: rgba(45, 212, 191, 0.25);
  background: var(--primary-soft);
}

.order-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 10px;
}

/* ── Layout grids ── */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 100%;
  align-items: start;
}

/* Right dashboard column (Мои заказы / Архив) floats with viewport */
.dash-side {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

.admin-tabs {
  margin-bottom: 18px;
  max-width: 100%;
}

.admin-tab-panel[hidden] {
  display: none !important;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
  box-sizing: border-box;
}

.admin-layout > .panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.admin-layout > .panel > .panel-body {
  flex: 1 1 auto;
}

.admin-users-panel .panel-body {
  padding: 16px 20px 20px;
  overflow-x: auto;
  box-sizing: border-box;
}

.admin-users-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  box-sizing: border-box;
}

.admin-users-table {
  width: 100%;
  table-layout: auto;
}

.admin-users-table th,
.admin-users-table td {
  vertical-align: top;
}

.admin-users-table th:nth-child(1),
.admin-users-table td:nth-child(1) {
  width: 1%;
  min-width: 180px;
  white-space: nowrap;
}

.admin-users-table th:nth-child(2),
.admin-users-table td:nth-child(2) {
  width: 1%;
  min-width: 220px;
}

.admin-users-table th:nth-child(3),
.admin-users-table td:nth-child(3) {
  width: auto;
  min-width: 280px;
}

.admin-user-cell {
  overflow-wrap: normal;
  word-break: normal;
}

.admin-extra-roles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.admin-role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.admin-role-chips .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: none;
  box-sizing: border-box;
}

.admin-revoke-form {
  display: inline-flex;
  flex: 0 0 auto;
}

.admin-revoke-btn {
  padding: 0 4px;
}

.admin-role-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-role-form .ui-input,
.admin-role-form select {
  flex: 1 1 auto;
  width: auto;
  min-width: 160px;
  max-width: 100%;
  box-sizing: border-box;
}

.admin-role-form select,
.admin-role-form select option {
  white-space: nowrap;
}

.admin-role-form .btn {
  flex: 0 0 auto;
}

.branding-panel {
  margin-bottom: 20px;
}

.branding-hint {
  margin: 0 0 14px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.row-highlight td {
  background: var(--warning-soft);
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.mt-lg { margin-top: 24px; }
.mt-md { margin-top: 16px; }
.gap-sm { gap: 8px; }

/* ── Forms ── */
.form, .form-grid {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.form label, .form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
}

.form input, .form textarea, .form select,
.form-grid input, .form-grid textarea, .form-grid select,
.ui-input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-ui);
  background: var(--input-bg);
  color: var(--text);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form input:focus, .form textarea:focus, .form select:focus,
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus,
.ui-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.ui-input-sm {
  padding: 6px 8px;
  font-size: 0.8rem;
}

.mono-input {
  font-family: var(--font-mono) !important;
  font-size: 0.9rem;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.inline-form .ui-input,
.inline-form select {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.role-edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.role-edit-card {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  max-width: 100%;
  overflow: hidden;
}

.role-edit-card:not(.role-accordion) {
  padding: 14px;
}

.role-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.role-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
}

.role-accordion.is-open .role-accordion-header {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--surface) 55%, var(--surface-2));
}

.role-accordion-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 180px;
  min-width: 0;
  margin: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.role-accordion-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.role-accordion-title {
  font-size: 0.95rem;
}

.role-sys-badge {
  font-size: 0.75rem;
}

.role-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.role-currency-inline {
  margin: 0;
  min-width: 0;
}

.role-currency-inline .ui-input {
  min-width: 88px;
  width: auto;
}

.role-accordion-body {
  padding: 14px;
}

.role-accordion-body[hidden] {
  display: none !important;
}

.accordion-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
  margin-left: 4px;
}

.role-accordion.is-open > .role-accordion-header .accordion-chevron,
.preset-card.is-open > .preset-card-face .accordion-chevron {
  transform: rotate(-135deg);
}

.preset-btns-compact {
  gap: 6px;
}

.preset-btns-compact .preset-btn {
  min-width: 0;
  padding-inline: 10px;
}

.preset-create-panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preset-create-panel[hidden] {
  display: none !important;
}

.preset-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.preset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 96px;
}

.preset-card.is-open {
  grid-column: 1 / -1;
}

.preset-card-face {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  min-height: 96px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  position: relative;
  width: 100%;
}

.preset-card-face:hover {
  background: color-mix(in srgb, var(--surface) 40%, var(--surface-2));
}

.preset-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  padding-right: 20px;
}

.preset-card-face .accordion-chevron {
  position: absolute;
  top: 18px;
  right: 16px;
}

.preset-card-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.preset-card-body[hidden] {
  display: none !important;
}

.preset-edit-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preset-edit-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preset-apply-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.preset-apply-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  min-width: 110px;
  justify-content: center;
}

.preset-btn.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.perm-matrix {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 14px;
}

.perm-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 12px;
}

.perm-group-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 8px;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 12px;
}

.perm-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
}

.perm-check input {
  width: auto;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.checkbox-row input { width: auto; accent-color: var(--primary); }

/* ── Auth ── */
.auth-card {
  max-width: 420px;
  width: 100%;
  margin: 40px auto 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  animation: feed-in 0.4s ease both;
  box-sizing: border-box;
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Landing portal (company login gate) ── */
.portal {
  flex: 1 1 auto;
  display: grid;
  place-content: center;
  place-items: center;
  justify-items: center;
  text-align: center;
  width: 100%;
  min-height: 100%;
  padding: 32px 16px;
  position: relative;
  box-sizing: border-box;
}

body.public-layout .portal {
  min-height: calc(100vh - 88px);
}

/* Logged-in shell fallback: center portal in main pane */
body.app-shell .main:has(> .portal) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
}

body.app-shell .main > .portal {
  flex: 1 1 auto;
  min-height: 100%;
  width: 100%;
}

.portal::before {
  content: '';
  position: absolute;
  inset: 12% 50% auto;
  width: min(520px, 90vw);
  height: 280px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--primary) 18%, transparent), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.portal-mark {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-ink);
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--accent)));
  box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
  margin-bottom: 28px;
  animation: feed-in 0.45s ease both;
}

.portal-brand {
  position: relative;
  z-index: 1;
  font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.08;
  color: var(--text);
  margin-bottom: 14px;
  animation: feed-in 0.5s ease 0.04s both;
}

.portal-tagline {
  position: relative;
  z-index: 1;
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 36ch;
  margin: 0 auto 32px;
  line-height: 1.45;
  animation: feed-in 0.55s ease 0.08s both;
}

.portal-welcome {
  position: relative;
  z-index: 1;
  font-size: 0.95rem;
  color: var(--text-dim);
  max-width: 42ch;
  margin: -16px auto 28px;
  line-height: 1.45;
  animation: feed-in 0.55s ease 0.1s both;
}

.portal-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  animation: feed-in 0.55s ease 0.14s both;
}

.portal-actions .portal-cta {
  min-width: 148px;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

.portal-extras {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin-top: 40px;
  animation: feed-in 0.6s ease 0.18s both;
}

.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.portal-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.feature-list { list-style: none; }
.feature-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.feature-list li:last-child { border-bottom: none; }
.feat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.demo-accounts {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
}
.demo-title { font-weight: 700; color: var(--text); margin-bottom: 8px; }
.demo-accounts p { margin: 4px 0; }
.demo-accounts code {
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.branding-toggles {
  align-items: center;
}
.branding-toggle-hint {
  font-size: 0.82rem;
  margin: -4px 0 12px;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  animation: feed-in 0.3s ease both;
}

.alert-error {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 28px 12px;
  text-align: center;
}

/* ── Characters ── */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.char-card {
  position: relative;
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.char-card:hover {
  border-color: color-mix(in srgb, var(--char-color, var(--primary)) 55%, var(--border));
  transform: translateY(-2px);
}

.char-card-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--char-color, var(--primary));
}

.char-card-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.char-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, var(--char-color, var(--primary)) 50%, transparent);
  flex-shrink: 0;
  background: var(--surface);
}

.char-thumb-placeholder {
  background: color-mix(in srgb, var(--char-color, var(--primary)) 25%, var(--surface));
}

.char-card-title { min-width: 0; }

.char-name {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-realm { font-size: 0.78rem; color: var(--text-dim); }
.char-spec { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 10px; }

.char-specs {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.char-specs li {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 8px;
}
.char-specs li.is-active {
  background: color-mix(in srgb, var(--char-color, var(--primary)) 14%, transparent);
  color: var(--text);
  font-weight: 600;
}
.char-role-ico { text-align: center; }
.char-role-label { color: var(--text-label); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.char-stats {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--char-color, var(--primary));
}
.char-rio a { font-size: 0.75rem; }

.char-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.char-action-form .btn,
.char-delete-form .btn { width: 100%; }

.add-char-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.add-char-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.add-char-tab.active {
  border-color: var(--primary);
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

/* ── Cabinet tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ── Applicants ── */
.applicant-list { display: flex; flex-direction: column; gap: 10px; }

.applicant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
  animation: feed-in 0.35s ease both;
}

.applicant-info { min-width: 0; }
.applicant-info .who { font-weight: 700; }
.applicant-info .spec { font-size: 0.85rem; color: var(--text-muted); }
.applicant-info .msg { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.applicant-key {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}

.applicant-key .key-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.applicant-key .meta-chip.key {
  font-size: 0.95rem;
  font-weight: 700;
}

.applicant-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Order detail + chat ── */
.order-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}

.order-detail-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.order-chat-panel {
  position: sticky;
  top: 1rem;
  height: calc(100vh - 2rem);
  max-height: calc(100vh - 2rem);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.order-chat-panel > .panel-head {
  flex-shrink: 0;
}

.order-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.order-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 320px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 28px 12px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.chat-author {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.chat-thumb {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, var(--char-color, var(--primary)) 50%, transparent);
  flex-shrink: 0;
  background: var(--surface);
}

.chat-thumb-user {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  border-color: var(--border);
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
}

.chat-author .char-name {
  font-size: 0.88rem;
}

.chat-author .char-realm {
  font-size: 0.7rem;
}

.chat-author .badge {
  font-size: 0.65rem;
  padding: 2px 6px;
}

.chat-bubble {
  margin-left: 46px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}

.chat-time {
  display: block;
  margin-top: 5px;
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.order-chat-compose {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px 14px 14px;
  background: var(--surface);
}

.order-chat-compose textarea {
  width: 100%;
  min-height: 52px;
  max-height: 140px;
  resize: vertical;
  margin: 0;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-ui);
  line-height: 1.4;
  background: var(--input-bg);
  color: var(--text);
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.order-chat-compose textarea::placeholder {
  color: var(--text-dim);
}

.order-chat-compose textarea:hover {
  border-color: var(--border-strong);
}

.order-chat-compose textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.order-chat-compose .btn {
  min-height: 52px;
  padding: 12px 18px;
  align-self: stretch;
  box-shadow: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.order-chat-compose .btn-primary {
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 28%, transparent);
}

.order-chat-compose .btn-primary:hover {
  box-shadow: 0 3px 12px color-mix(in srgb, var(--primary) 34%, transparent);
}

@media (max-width: 1100px) {
  .order-detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .order-chat-panel {
    position: static;
    height: auto;
    max-height: none;
    min-height: 480px;
  }

  .order-chat-messages {
    min-height: 280px;
    max-height: min(58vh, 520px);
  }
}

/* ── Detail panel ── */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.detail-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.detail-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0 10px;
}

.detail-desc {
  color: var(--text-muted);
  margin-bottom: 16px;
  max-width: 60ch;
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:hover td { background: var(--surface-2); }

.key-display {
  margin-top: 16px;
  padding: 14px;
  background: var(--success-soft);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  word-break: break-all;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.stat-card .label {
  font-size: 0.75rem;
  color: var(--text-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 4px;
  color: var(--primary);
}

.balance-big {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--primary);
}

.balance-currency {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0;
}

.ref-box {
  padding: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  word-break: break-all;
}

/* Compact side list */
.side-list { display: flex; flex-direction: column; gap: 8px; }
.side-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.side-item:hover { border-color: var(--primary); }

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); font-size: 0.85rem; }

/* Create-order extras */
.req-keys-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  max-width: 100%;
}

.req-keys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.req-keys-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.req-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.7fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  width: 100%;
}

.req-key-row label {
  min-width: 0;
}

.calc-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-secondary-border);
  background: var(--primary-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-box.calc-box-warn {
  border-color: #c44;
  background: rgba(196, 68, 68, 0.08);
}

.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.calc-row strong {
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 800;
}

.calc-row strong.calc-over {
  color: #c44;
}

.calc-warn {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(196, 68, 68, 0.35);
  color: #c44;
  font-size: 0.85rem;
  font-weight: 700;
}

.fact-pay-warn {
  border-color: rgba(196, 68, 68, 0.4);
}

.fact-over {
  color: #c44 !important;
}

.fact-warn {
  margin-top: 2px;
  color: #c44;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
}

.os-notif-banner {
  position: relative;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-secondary-border);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.9rem;
  pointer-events: auto;
}

.os-notif-banner[hidden] { display: none !important; }

.os-notif-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  z-index: 61;
  pointer-events: auto;
}

.os-notif-banner [data-os-notif-enable],
.os-notif-banner [data-os-notif-dismiss] {
  position: relative;
  z-index: 62;
  pointer-events: auto !important;
  cursor: pointer !important;
  opacity: 1 !important;
}

.os-notif-banner [data-os-notif-enable]:disabled,
.os-notif-banner [data-os-notif-dismiss]:disabled {
  cursor: pointer !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.boost-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.boost-toast {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  line-height: 1.35;
  animation: boost-toast-in 0.2s ease both;
}

.boost-toast-ok {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
}

.boost-toast-error {
  border-color: color-mix(in srgb, var(--error) 45%, var(--border));
}

.boost-toast-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes boost-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Desktop: never let the mobile drawer backdrop intercept clicks */
.sidebar-backdrop {
  display: none;
  pointer-events: none;
}

.os-notif-status {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* Unread flash indicator in sidebar */
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #04201c;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* Mobile */
.mobile-nav-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
}

/* Stack users table only when admin is already single-column (narrow screens). */
@media (max-width: 1100px) {
  .grid-2,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .dash-side {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .admin-users-table th:nth-child(1),
  .admin-users-table td:nth-child(1),
  .admin-users-table th:nth-child(2),
  .admin-users-table td:nth-child(2),
  .admin-users-table th:nth-child(3),
  .admin-users-table td:nth-child(3) {
    width: auto;
    min-width: 0;
    white-space: normal;
  }

  .admin-users-table,
  .admin-users-table thead,
  .admin-users-table tbody,
  .admin-users-table tr,
  .admin-users-table th,
  .admin-users-table td {
    display: block;
    width: 100% !important;
  }

  .admin-users-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .admin-users-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .admin-users-table tr:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .admin-users-table td {
    padding: 6px 0;
    border-bottom: none;
  }

  .admin-users-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--text-dim);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .admin-users-table td:first-child[data-label]::before {
    content: none;
    margin: 0;
  }

  .admin-role-chips .badge {
    white-space: nowrap;
  }

  .admin-role-form .ui-input,
  .admin-role-form select {
    min-width: 160px;
  }
}

@media (max-width: 900px) {
  body.app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .top-strip { display: flex; }
  .mobile-nav-toggle { display: grid; place-items: center; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .grid-3, .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .dash-side {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .form-row { grid-template-columns: 1fr; }
  .req-key-row { grid-template-columns: 1fr !important; }
  .public-topbar {
    padding: 14px 16px;
  }
  .public-main {
    padding: 16px 16px 40px;
  }
  .auth-card {
    margin: 24px auto;
    padding: 24px 18px;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
    pointer-events: none;
  }
  .sidebar-backdrop.show {
    display: block;
    pointer-events: auto;
  }
  .req-key-row { grid-template-columns: 1fr; }

  .fact-pay-grid {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  .fact-pay-bank {
    order: -1;
    padding: 0;
  }

  .fact-pay-right {
    text-align: left;
  }

  .fact-pay-right .fact-pay-item {
    align-items: flex-start;
  }
}

/* ── Payouts page ── */
.payout-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  max-width: 360px;
}

.payout-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.payout-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--feed-item-bg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, transform 0.15s;
}

.payout-card:hover {
  border-color: var(--border-strong);
}

.payout-card-pending {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 18%, transparent), var(--shadow-sm);
}

.payout-card-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.payout-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.payout-avatar {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.payout-user-meta { min-width: 0; flex: 1; }
.payout-username {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.payout-role {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.payout-char {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--char-color, var(--border)) 35%, var(--border));
  background: color-mix(in srgb, var(--char-color, var(--primary)) 8%, var(--surface));
  border-left: 3px solid var(--char-color, var(--primary));
}

.payout-char-empty {
  border-style: dashed;
  border-left-width: 1px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
}

.payout-char-thumb {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.payout-char-thumb-ph {
  background: var(--surface-2);
}

.payout-char-meta { min-width: 0; flex: 1; }
.payout-char-name {
  font-weight: 650;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.payout-char-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 1px;
}
.payout-char-stats {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.payout-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 14px;
}

.payout-fact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.payout-fact-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-label);
  line-height: 1.3;
}

.payout-fact-value {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.payout-fact-sm {
  font-size: 0.92rem;
  font-weight: 600;
}

.payout-amount {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 800;
}

.payout-fact-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.payout-details {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.payout-details > .payout-fact-label {
  display: block;
  margin-bottom: 2px;
}

.payout-details p {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.payout-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 132px;
}

.payout-card-actions .btn {
  width: 100%;
}

.payout-empty-panel {
  margin-top: 4px;
}

.payout-empty {
  text-align: center;
  padding: 48px 24px !important;
}

.payout-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
}

.payout-empty h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.payout-empty .sub {
  max-width: 420px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 0.92rem;
}

@media (max-width: 720px) {
  .payout-card {
    grid-template-columns: 1fr;
  }
  .payout-card-actions {
    flex-direction: row;
    min-width: 0;
    width: 100%;
  }
  .payout-card-actions form {
    flex: 1;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .order-card, .auth-card, .portal-mark, .portal-brand, .portal-tagline, .portal-actions, .portal-extras,
  .applicant-card, .alert, .payout-card {
    animation: none !important;
  }
}
