:root {
  --primary: #1f6feb;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
.app { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { background: #0f172a; color: #e5e7eb; padding: 22px 18px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .04em; color: #fff; margin-bottom: 4px; }
.slogan { color: #94a3b8; font-size: 12px; margin-bottom: 24px; }
.nav {
  --nav-icon-width: 20px;
  --nav-label-width: 8em;
  --nav-label-spacing: .08em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  letter-spacing: var(--nav-label-spacing);
}
.nav a > svg,
.nav a > i,
.nav a > .icon,
.nav a > [class*="icon-"] {
  flex: 0 0 var(--nav-icon-width);
  width: var(--nav-icon-width);
  min-width: var(--nav-icon-width);
  text-align: center;
}
.nav a > span:not(.icon),
.nav a > .menu-label,
.nav a > .nav-label {
  flex: 0 0 var(--nav-label-width);
  width: var(--nav-label-width);
  min-width: var(--nav-label-width);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-group { padding: 18px 12px 7px; color: #64748b; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: var(--nav-label-spacing); white-space: nowrap; }
.nav-group > span { display: block; width: var(--nav-label-width); min-width: var(--nav-label-width); white-space: nowrap; overflow: visible; text-overflow: clip; }
.main { min-width: 0; }
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; }
.content { padding: 26px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.03); }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 650; font-size: 13px; margin-bottom: 6px; color: #374151; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 7px; padding: 10px 11px; font: inherit; background: #fff; }
textarea { min-height: 96px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 7px; padding: 9px 12px; font-weight: 700; cursor: pointer; background: #fff; color: var(--ink); }
.btn.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn.light { border-color: var(--line); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e0f2fe; color: #0369a1; }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.section-title { font-size: 16px; font-weight: 800; margin: 4px 0 14px; }
.page-subtitle { margin-top: 5px; color: var(--muted); font-size: 13px; }
.filter-bar { display: grid; grid-template-columns: minmax(180px,2fr) repeat(5,minmax(120px,1fr)); gap: 10px; align-items: end; padding: 12px; }
.filter-bar input,.filter-bar select { min-width: 0; }
.table-card { padding: 0; overflow: hidden; }
.table-card .pagination { padding: 0 16px 16px; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions .btn { padding: 6px 9px; font-size: 12px; }
.money { font-variant-numeric: tabular-nums; font-weight: 750; white-space: nowrap; }
.status-badge { text-transform: capitalize; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 1px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--line); }
.summary-metric { padding: 15px; background: #fff; }
.summary-metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.summary-metric strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px 24px; }
.detail-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.detail-grid strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.timeline-row { display: grid; grid-template-columns: 150px 130px 130px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-diff { grid-template-columns: 1fr 1fr; }
.audit-diff pre { margin: 0; padding: 12px; max-height: 360px; overflow: auto; border-radius: 7px; background: #f8fafc; font-size: 12px; white-space: pre-wrap; }
.core-form { max-width: 1180px; }
.required { color: var(--danger); }
.check-field { display: flex; align-items: center; gap: 9px; min-height: 42px; margin: 0; }
.check-field input { width: 18px; height: 18px; }
.repeater-block { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.repeat-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)) 76px; gap: 10px; align-items: end; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; }
.repeat-row label { font-size: 11px; }
.form-actions { display: flex; gap: 9px; margin-top: 22px; }
.form-feedback { margin-top: 16px; padding: 11px 13px; border-radius: 7px; font-weight: 700; }
.form-feedback.success { color: #166534; background: #dcfce7; }
.form-feedback.error { color: #991b1b; background: #fee2e2; }
.tab-bar { display: flex; gap: 3px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab-button { border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); background: transparent; font: inherit; font-weight: 750; cursor: pointer; }
.tab-button.active { color: var(--primary); border-bottom-color: var(--primary); }
.internal { border-color: #fed7aa; background: #fff7ed; }
.thumb { width: 64px; height: 64px; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); background: #f8fafc; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-switch { display: inline-flex; align-items: center; gap: 2px; margin: 0 10px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; vertical-align: middle; }
.lang-switch a { color: #475569; padding: 4px 8px; border-radius: 5px; font-size: 12px; font-weight: 800; }
.lang-switch a.active { color: #fff; background: var(--primary); }
.pagination { margin-top: 14px; }
.quote-item { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: #fff; }
.ai-result { display: grid; gap: 12px; margin-top: 12px; }
.admin-security-message { position:fixed; right:20px; bottom:20px; z-index:10000; max-width:min(420px,calc(100vw - 40px)); padding:12px 14px; border:1px solid #f59e0b; border-radius:8px; background:#fffbeb; color:#92400e; box-shadow:0 12px 30px rgba(15,23,42,.18); font-size:13px; font-weight:750; line-height:1.5; }
.admin-workbench { overflow: hidden; }
.admin-shell { min-height: 100vh; height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); background: #eef2f7; }
.workbench-sidebar { overflow-y: auto; padding-bottom: 28px; }
.workbench-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: 64px 44px minmax(0, 1fr); }
.workbench-header { background: #0f172a; color: #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; }
.workbench-breadcrumb { font-size: 15px; font-weight: 800; color: #fff; }
.workbench-user { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.workbench-user .btn { padding: 6px 9px; border-color: rgba(255,255,255,.22); background: transparent; color: #f8fafc; }
.workbench-user .lang-switch { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.06); }
.workbench-user .lang-switch a { color: #cbd5e1; }
.workbench-tabs { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 5px 10px 0; background: #e8edf4; border-bottom: 1px solid #d7dee8; scrollbar-width: thin; }
.workbench-tab { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; max-width: 220px; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; padding: 8px 10px; color: #526176; background: transparent; font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; }
.workbench-tab:hover { background: rgba(255,255,255,.58); color: #172033; }
.workbench-tab.active { color: #172033; background: #fff; border-color: #d7dee8; }
.workbench-tab.is-evicting { opacity: 0; transform: translateY(4px); max-width: 0; padding-left: 0; padding-right: 0; border-width: 0; overflow: hidden; transition: opacity .18s ease, transform .18s ease, max-width .18s ease, padding .18s ease; }
.workbench-tab > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbench-tab-close { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; color: #64748b; font-size: 18px; line-height: 1; }
.workbench-tab-close:hover { background: #e2e8f0; color: #b91c1c; }
.workbench-stage { position: relative; min-height: 0; background: #fff; }
.workbench-frame { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: #f6f8fb; }
.workbench-frame[hidden] { display: none; }
.admin-embed { min-height: 100vh; background: #f6f8fb; }
.embed-main { min-height: 100vh; }
.embed-content { padding: 24px; }
.admin-backbar { display: flex; align-items: center; margin-bottom: 14px; }
.admin-backbar[hidden] { display: none; }
.admin-back-button { width: auto; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .admin-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .workbench-header { height: 58px; padding: 0 10px; }
  .workbench-user { gap: 5px; font-size: 11px; }
  .workbench-user .btn { padding: 5px 6px; font-size: 11px; }
  .workbench-user .lang-switch { display: none; }
  .workbench-sidebar { padding: 16px 10px; }
  .embed-content { padding: 16px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .timeline-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .filter-bar,.detail-grid,.audit-diff { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .summary-metric strong { font-size: 17px; }
}
