/* Unified product interface layer
   Keeps the existing business markup intact while normalizing layout and controls. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --ink: #172033;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #dfe4ec;
  --line-strong: #cbd3df;
  --brand: #2f5bd3;
  --brand-hover: #274db2;
  --brand-soft: #edf2ff;
  --ok: #247a57;
  --ok-soft: #eaf6f0;
  --warn: #9a6619;
  --warn-soft: #fff5df;
  --bad: #b34343;
  --bad-soft: #fff0f0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .045);
  --shadow-float: 0 18px 48px rgba(16, 24, 40, .16);
  --radius-panel: 8px;
  --radius-control: 6px;
}

html { background: var(--bg); }
body {
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
body * { letter-spacing: 0; }
button, input, select, textarea { color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-underline-offset: 3px; }

/* Application shell */
.app {
  grid-template-columns: 244px minmax(0, 1fr);
  background: var(--bg);
}
.app.sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
.sidebar {
  background: #101828;
  box-shadow: inset -1px 0 rgba(255,255,255,.05);
}
.brand {
  min-height: 72px;
  padding: 13px 12px 12px 15px;
  border-bottom: 1px solid rgba(255,255,255,.075);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #294eb5;
  font-size: 16px;
}
.brand-copy strong { font-size: 15px; font-weight: 750; }
.brand-copy span { margin-top: 3px; color: #8593a8; font-size: 10px; font-weight: 600; }
.sidebar-toggle {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.nav { gap: 2px; padding: 10px 0 14px; }
.nav-dashboard,
.nav-parent {
  min-height: 44px;
  padding: 0 15px;
  gap: 11px;
  color: #aab5c5;
  font-size: 13px;
  font-weight: 650;
}
.nav-icon { width: 18px; height: 18px; color: #8090a7; }
.nav-dashboard:hover,
.nav-parent:hover { color: #f7f9fc; background: rgba(255,255,255,.04); }
.nav-dashboard.active {
  color: #fff;
  background: #294ba9;
  box-shadow: inset 3px 0 #8fb1ff;
}
.nav-parent.active { color: #f4f7fc; background: rgba(255,255,255,.025); }
.nav-group.expanded .nav-children { padding: 2px 0 5px; }
.nav-children { background: rgba(5, 12, 24, .18); }
.nav-children button {
  min-height: 36px;
  padding: 0 14px 0 43px;
  color: #91a0b5;
  font-size: 12px;
  font-weight: 500;
}
.nav-children button::before { left: 27px; width: 3px; height: 3px; background: #59687e; }
.nav-children button:hover { color: #fff; background: rgba(255,255,255,.035); }
.nav-children button.active {
  color: #fff;
  background: #202c40;
  font-weight: 650;
}
.nav-children button.active::before { background: #86aaff; box-shadow: none; }
.sidebar-footer { padding: 10px 12px 12px; }
.system-footer-info.sidebar-meta { min-height: 30px; margin-bottom: 8px; font-size: 10px; }
.sidebar-logout-button {
  min-height: 36px;
  border-radius: 6px;
  color: #f7c7c7;
  font-size: 12px;
  font-weight: 650;
}
.sidebar-collapsed .sidebar { width: 72px; min-width: 72px; }
.sidebar-collapsed .brand { min-height: 72px; }
.sidebar-collapsed .nav-dashboard,
.sidebar-collapsed .nav-parent { min-height: 46px; }

.workspace {
  max-width: 1800px;
  padding: 0 24px 32px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 14;
  min-height: 60px;
  margin: 0 -24px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(223, 228, 236, .9);
  background: rgba(244, 246, 249, .94);
  backdrop-filter: blur(12px);
}
.topbar-account-cluster {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .035);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.topbar-account-cluster:hover {
  border-color: var(--line-strong);
  background: #fff;
}
.topbar-account-cluster:focus-within {
  border-color: rgba(47, 91, 211, .52);
  box-shadow: 0 0 0 3px rgba(47, 91, 211, .09);
}
.topbar-account-divider {
  width: 1px;
  height: 22px;
  flex: 0 0 auto;
  background: var(--line);
}
.user-switch {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}
.status-pill {
  min-height: 36px;
  padding: 0 11px 0 9px;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}
.status-pill span {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.status-pill strong { color: #475467; font-size: 11px; font-weight: 650; white-space: nowrap; }
.status-pill.saving span {
  box-shadow: 0 0 0 3px var(--brand-soft);
  animation: topbar-status-pulse 1.25s ease-in-out infinite;
}
.status-pill.saved span,
.status-pill.ok span { box-shadow: 0 0 0 3px var(--ok-soft); }
.status-pill.bad {
  border: 0;
  color: var(--bad);
  background: var(--bad-soft);
}
.status-pill.bad strong { color: var(--bad); }
.status-pill.bad span { box-shadow: 0 0 0 3px rgba(179, 67, 67, .1); }
@keyframes topbar-status-pulse {
  0%, 100% { opacity: .72; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.12); }
}
.profile-button {
  min-height: 36px;
  padding: 3px 7px 3px 6px;
  gap: 9px;
  border: 0;
  border-radius: 6px;
  transition: background-color .18s ease, transform .12s ease;
}
.profile-button:hover { background: var(--surface-2); }
.profile-button:active { transform: translateY(1px); }
.profile-button:focus-visible { outline: 2px solid rgba(47, 91, 211, .42); outline-offset: 1px; }
.profile-avatar { width: 30px; height: 30px; border-radius: 7px; font-size: 12px; }
.profile-copy { min-width: 78px; gap: 0; }
.profile-copy strong { max-width: 144px; font-size: 12px; line-height: 1.35; font-weight: 720; }
.profile-copy em { color: var(--muted); font-size: 10px; line-height: 1.3; font-weight: 600; }
.profile-chevron { width: 14px; height: 14px; margin-left: 1px; color: #98a2b3; transition: transform .18s ease; }
.profile-button:hover .profile-chevron { transform: translateX(1px); color: #667085; }

/* AI model connection feedback */
.ai-model-test.is-loading {
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--brand);
  background: var(--brand-soft);
  border-color: rgba(47, 91, 211, .22);
  opacity: 1;
}
.ai-model-test .button-spinner { width: 12px; height: 12px; }
.ai-model-test-result {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.35;
}
.ai-model-test-result.ok { color: var(--ok); }
.ai-model-test-result.bad { color: var(--bad); }
.ai-model-test-result.testing { color: var(--brand); }
.ai-model-test-result .button-spinner { width: 11px; height: 11px; }
.ai-model-test-result b {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-head {
  min-height: 108px;
  align-items: center;
  padding: 20px 0 18px;
}
.page-head > div:first-child { min-width: 0; }
.page-head p {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}
.page-head h1 {
  color: #101828;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 750;
}
.page-head > div > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.page-actions { flex: 0 0 auto; }
.view {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.view > * { min-width: 0; max-width: 100%; }

/* Surfaces and section hierarchy */
.panel,
.dashboard-hero-main,
.dashboard-next-panel,
.dashboard-filter-panel,
.dashboard-metric,
.dashboard-list-panel,
.monitor-overview,
.backup-table-card,
.role-permission-table {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; }
.panel-head {
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom-color: #e8ecf2;
}
.panel-head h2 { color: #1d2939; font-size: 16px; font-weight: 720; }
.panel-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.grid-2 { gap: 14px; }
.grid-3, .card-grid { gap: 12px; }

.admin-summary,
.metric-grid,
.dashboard-metric-grid { gap: 10px; }
.metric,
.admin-summary > article,
.admin-summary > div,
.maintenance-card {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  box-shadow: none;
}
.metric { min-height: 108px; padding: 14px; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric strong { margin-top: 13px; font-size: 25px; font-weight: 750; }
.metric small { margin-top: 7px; font-size: 11px; }

/* Dashboard */
.dashboard-hero { gap: 12px; }
.dashboard-hero-main {
  min-height: 158px;
  padding: 20px 22px;
  background: #fff;
}
.dashboard-hero-main::after { display: none; }
.dashboard-eyebrow {
  padding: 3px 6px;
  border-radius: 4px;
  color: #3153a4;
  background: var(--brand-soft);
  font-size: 10px;
  font-weight: 700;
}
.dashboard-hero-main h2 { margin-top: 8px; font-size: 22px; font-weight: 750; }
.dashboard-hero-main p { margin-top: 6px; color: #59677a; font-size: 13px; }
.dashboard-hero-chips { gap: 6px; }
.dashboard-chip {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  background: #f8fafc;
}
.dashboard-chip em { font-size: 11px; font-weight: 600; }
.dashboard-chip strong { font-size: 12px; font-weight: 750; }
.dashboard-next-panel { min-height: 158px; gap: 10px; padding: 14px; }
.dashboard-next-head span { font-size: 11px; font-weight: 700; }
.dashboard-next-head strong { font-size: 12px; font-weight: 650; }
.dashboard-action-list { gap: 7px; }
.dashboard-action {
  min-height: 56px;
  grid-template-columns: 24px minmax(0,1fr);
  gap: 8px;
  padding: 8px;
  border-color: #e1e7ef;
  border-radius: 7px;
  background: #f8fafc;
  box-shadow: none;
}
.dashboard-action.action-01,
.dashboard-action.action-02,
.dashboard-action.action-03,
.dashboard-action.action-04 { border-color: #e1e7ef; background: #f8fafc; }
.dashboard-action b { width: 24px; height: 24px; border-radius: 5px; font-size: 10px; }
.dashboard-action strong { font-size: 12px; }
.dashboard-action small { font-size: 10px; }
.dashboard-action:hover { border-color: #b8c7e8; background: #fff; box-shadow: none; }
.dashboard-filter-panel {
  grid-template-columns: minmax(155px,.25fr) minmax(0,1fr);
  gap: 12px;
  padding: 11px 12px;
}
.dashboard-filter-title strong { font-size: 13px; }
.dashboard-filter-title span { font-size: 11px; }
.dashboard-filter-grid { gap: 8px; }
.dashboard-filter-grid select { min-height: 36px; border-radius: 6px; }
.dashboard-metric { min-height: 104px; padding: 13px 14px; }
.dashboard-metric::before { height: 2px; }
.dashboard-metric span { font-size: 12px; font-weight: 700; }
.dashboard-metric em, .dashboard-metric small { font-size: 11px; }
.dashboard-metric strong { font-size: 26px; font-weight: 780; }
.dashboard-activity-grid { gap: 12px; }
.dashboard-list-line {
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #e8ecf2;
  border-radius: 0;
  background: transparent;
}
.dashboard-list-line:last-child { border-bottom: 0; }
.dashboard-list-line:hover { background: #f8fafc; transform: none; }

/* Buttons and form controls */
.primary-button,
.ghost-button,
.danger-button,
.text-button,
.text-danger,
.icon-button {
  min-height: 36px;
  border-radius: var(--radius-control);
  font-size: 12px;
  font-weight: 650;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.primary-button { background: var(--brand); border-color: var(--brand); }
.primary-button:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.primary-button.subtle { color: #294da9; background: var(--brand-soft); border-color: #ccd8f7; }
.ghost-button { color: #344054; background: #fff; border-color: var(--line-strong); }
.ghost-button:hover { color: #1d2939; background: #f8fafc; border-color: #aeb8c7; }
.danger-button { color: var(--bad); background: var(--bad-soft); border-color: #f0caca; }
.danger-button.subtle { background: #fff7f7; }
.text-button,
.text-danger { min-height: 28px; padding: 3px 6px; border-radius: 5px; }
.text-button:hover { background: var(--brand-soft); }
.text-danger:hover { background: var(--bad-soft); }
.icon-button { width: 36px; padding: 0; }
.button-spinner { width: 14px; height: 14px; }

.field { gap: 6px; }
.field span,
.field > label { color: #344054; font-size: 12px; font-weight: 650; }
.field input,
.field select,
.field textarea,
.compact-filter-select,
.add-row input {
  min-height: 38px;
  border-color: var(--line-strong);
  border-radius: var(--radius-control);
  color: #1d2939;
  background: #fff;
  font-weight: 500;
}
.field textarea { min-height: 88px; }
.field input::placeholder,
.field textarea::placeholder,
.keyword-filter input::placeholder,
.log-filter-panel input::placeholder { color: #98a2b3; font-weight: 400; }
.field input:hover,
.field select:hover,
.field textarea:hover,
.compact-filter-select:hover { border-color: #aeb8c7; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.compact-filter-select:focus {
  border-color: #7390dc;
  box-shadow: 0 0 0 3px rgba(47, 91, 211, .10);
}
.field-hint { color: var(--muted); font-size: 11px; }
.required-star { color: #d92d20; }
.checkline { font-size: 12px; font-weight: 650; }
.checkline input { width: 15px; height: 15px; }

/* Filters */
.filters,
.library-filter-bar,
.log-filter-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.025);
}
.library-filter-bar,
.library-filter-bar.list-filter-bar,
.library-filter-bar.monitor-filter-bar,
.library-filter-bar.template-filter-bar,
.library-filter-bar.exception-filter-bar,
.library-filter-bar.check-filter-bar,
.library-filter-bar.monitor-history-filter-bar,
.library-filter-bar.monitor-handled-filter-bar {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  min-height: 54px;
  padding: 7px;
  overflow: visible;
}
.library-filter-bar > .keyword-filter,
.library-filter-bar > .library-keyword-filter {
  flex: 1 1 280px;
  min-width: 240px;
}
.library-filter-bar > .compact-filter-select {
  flex: 0 1 126px;
  min-width: 92px;
  width: auto;
}
.library-filter-bar > .range-filter { flex: 0 1 286px; min-width: 240px; }
.library-filter-bar > .filter-more,
.library-filter-bar > .compact-clear-button,
.library-filter-bar > .filter-inline-actions { flex: 0 0 auto; }
.library-filter-bar > span:empty { display: none; }
.library-filter-bar.library-filters-inline {
  overflow: hidden;
}
.library-filter-scroll {
  min-width: 0;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 7px;
  padding-bottom: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #cbd3df transparent;
}
.library-filter-scroll::-webkit-scrollbar { height: 4px; }
.library-filter-scroll::-webkit-scrollbar-thumb { border-radius: 4px; background: #cbd3df; }
.library-filter-scroll > .keyword-filter {
  flex: 1 0 270px;
  min-width: 270px;
  max-width: 420px;
}
.library-filter-scroll > .compact-filter-select {
  flex: 0 0 104px;
  min-width: 104px;
}
.library-filter-scroll > .library-fee-filter {
  flex: 0 0 190px;
  min-width: 190px;
  grid-template-columns: auto minmax(48px, 1fr) auto minmax(48px, 1fr);
}
.library-filter-scroll > .library-date-filter {
  flex: 0 0 286px;
  min-width: 286px;
  grid-template-columns: auto minmax(92px, 1fr) auto minmax(92px, 1fr) 20px;
}
.library-filter-bar.library-filters-inline > .compact-clear-button {
  flex: 0 0 auto;
  border-color: var(--line-strong);
  background: #fff;
}
.keyword-filter,
.library-keyword-filter {
  min-height: 38px;
  gap: 8px;
  padding: 0 10px;
  border-color: var(--line-strong);
  border-radius: var(--radius-control);
  background: #fbfcfe;
}
.keyword-filter:focus-within,
.library-keyword-filter:focus-within {
  border-color: #7390dc;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47,91,211,.10);
}
.keyword-filter label,
.keyword-filter span,
.library-keyword-filter span { color: #667085; font-size: 11px; font-weight: 650; }
.keyword-filter input,
.library-keyword-filter input { color: #1d2939; font-size: 12px; font-weight: 500; }
.keyword-clear-button,
.date-range-clear-button {
  width: 20px;
  height: 20px;
  flex-basis: 20px;
  border-radius: 4px;
  color: #667085;
  background: #eef2f6;
  font-size: 14px;
}
.compact-filter-select { height: 38px; padding: 6px 26px 6px 9px; font-size: 12px; font-weight: 550; }
.range-filter {
  min-height: 38px;
  padding: 4px 7px;
  border-color: var(--line-strong);
  border-radius: var(--radius-control);
  background: #fbfcfe;
}
.range-filter span { color: #667085; font-size: 11px; font-weight: 650; }
.range-filter input { min-height: 28px; padding: 2px 4px; background: transparent; font-size: 11px; }
.filter-more summary {
  min-height: 38px;
  border-color: var(--line-strong);
  border-radius: var(--radius-control);
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}
.filter-more summary:hover { background: #f8fafc; }
.filter-more-popover {
  z-index: 18;
  border-color: var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-float);
}
.compact-clear-button { min-height: 38px; padding-inline: 12px; }

.log-workspace .log-filter-panel,
.log-filter-panel {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: #f8fafc;
  box-shadow: none;
  overflow: hidden;
}
.log-filter-scroll {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  flex: 1 1 auto;
  gap: 8px;
  padding-bottom: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #cbd3df transparent;
}
.log-filter-scroll::-webkit-scrollbar { height: 4px; }
.log-filter-scroll::-webkit-scrollbar-thumb { border-radius: 4px; background: #cbd3df; }
.log-filter-scroll > label {
  min-width: 104px;
  flex: 0 0 104px;
}
.log-filter-scroll > .log-filter-keyword {
  min-width: 260px;
  flex: 1 0 260px;
}
.log-filter-scroll > .log-filter-range {
  min-width: 264px;
  flex: 0 0 264px;
}
.log-filter-panel label { gap: 5px; }
.log-filter-panel label > span { color: #667085; font-size: 11px; font-weight: 650; }
.log-filter-panel .compact-filter-select,
.log-filter-panel input { height: 36px; border-color: var(--line-strong); border-radius: 6px; font-size: 12px; }
.log-filter-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  padding-bottom: 2px;
}

/* List headers and bulk actions */
.table-context {
  min-height: 52px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
}
.table-context > div { gap: 2px; }
.table-context strong { color: #1d2939; font-size: 13px; font-weight: 700; }
.table-context span { color: var(--muted); font-size: 11px; }
.bulk-bar {
  min-height: 48px;
  gap: 6px;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafc;
}
.bulk-bar.has-selection { border-color: #cbd8f6; background: #f2f5ff; }
.bulk-bar > strong { color: #475467; font-size: 11px; font-weight: 650; }
.bulk-bar .primary-button,
.bulk-bar .ghost-button,
.bulk-bar .danger-button { min-height: 32px; padding-inline: 9px; }
.table-head-toggle {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: #475467;
  font-size: 11px;
  font-weight: 600;
}

/* Data tables */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
}
.table-context + .table-wrap,
.bulk-bar + .table-wrap,
.table-context + .table-native-top-scroll + .table-wrap,
.bulk-bar + .table-native-top-scroll + .table-wrap {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.panel > .table-wrap:first-child,
.user-management-panel .table-wrap,
.backup-table-wrap,
.channel-table-wrap,
.log-table-wrap { border-radius: var(--radius-panel); }
.table-native-top-scroll {
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f5f7fa;
  scrollbar-color: #aab5c4 #edf1f5;
  scrollbar-width: thin;
}
.table-native-top-scroll-content { height: 1px; }
.table-wrap.has-native-top-scroll { border-top-left-radius: 0; border-top-right-radius: 0; }
.table-wrap.has-native-top-scroll::-webkit-scrollbar { height: 0; }
.table-wrap.has-native-top-scroll { scrollbar-width: none; }
.table-top-scroll { height: 16px; margin: 4px 0 0; padding: 3px 0; }
.table-top-scroll-track { height: 8px; border-radius: 3px; background: #edf1f5; }
.table-top-scroll-thumb { border-radius: 2px; background: #aab7c8; }

table {
  min-width: 980px;
  color: #344054;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 10px 11px;
  border-bottom-color: #e8ecf2;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 38px;
  color: #667085;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
tbody tr { transition: background-color .14s ease; }
tbody tr:hover > td { background: #f9fbfd; }
tbody tr:last-child > td { border-bottom: 0; }
td strong { color: #1d2939; font-weight: 680; }
.message-cell { min-width: 240px; }
.library-table .action-col,
.monitor-table .action-col {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  box-shadow: -10px 0 18px rgba(16,24,40,.055);
}
.library-table th.action-col,
.monitor-table th.action-col {
  z-index: 5;
  background: #f8fafc;
}
.library-table tbody tr:hover td.action-col,
.monitor-table tbody tr:hover td.action-col { background: #f9fbfd; }
.channel-table th:last-child,
.channel-table td:last-child,
.user-management-panel table th:last-child,
.user-management-panel table td:last-child,
.backup-table th:last-child,
.backup-table td:last-child,
.view[data-page="generation/tasks"] table th:last-child,
.view[data-page="generation/tasks"] table td:last-child,
.view[data-page="generation/templates"] table th:last-child,
.view[data-page="generation/templates"] table td:last-child,
.view[data-page="monitor/exceptions"] table th:last-child,
.view[data-page="monitor/exceptions"] table td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  box-shadow: -10px 0 18px rgba(16,24,40,.055);
}
.channel-table th:last-child,
.user-management-panel table th:last-child,
.backup-table th:last-child,
.view[data-page="generation/tasks"] table th:last-child,
.view[data-page="generation/templates"] table th:last-child,
.view[data-page="monitor/exceptions"] table th:last-child {
  z-index: 5;
  background: #f8fafc;
}
.channel-table th:last-child { width: 224px; }
.channel-table td:last-child { min-width: 224px; }
.channel-table td:last-child .row-actions { flex-wrap: nowrap; }
.channel-table tbody tr:hover td:last-child,
.user-management-panel table tbody tr:hover td:last-child,
.backup-table tbody tr:hover td:last-child,
.view[data-page="generation/tasks"] table tbody tr:hover td:last-child,
.view[data-page="generation/templates"] table tbody tr:hover td:last-child,
.view[data-page="monitor/exceptions"] table tbody tr:hover td:last-child { background: #f9fbfd; }
.library-table td[data-library-column="review"] .library-bilingual-cell,
.library-table td[data-library-column="review"] .library-plain-preview,
.monitor-table td[data-monitor-column="review"] .library-plain-preview,
.monitor-table td[data-monitor-column="translation"] .library-plain-preview {
  min-width: 180px;
}
.row-actions,
.monitor-row-actions { flex-wrap: nowrap; white-space: nowrap; }
.row-actions .text-button,
.row-actions .text-danger,
.monitor-row-actions .text-button,
.monitor-row-actions .text-danger { padding-inline: 5px; }
.column-resize-handle::after { background: #b7c2d1; }
.library-bilingual-cell { gap: 3px; }
.library-bilingual-cell strong { font-size: 12px; }
.library-bilingual-cell em { color: #667085; font-size: 11px; }
.library-plain-preview,
.review-snippet { line-height: 1.5; }
.badge,
.warranty-chip,
.log-level-pill,
.log-module-pill {
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
}
.pagination {
  min-height: 52px;
  margin-top: 0;
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 11px;
}
.pagination .ghost-button { min-height: 32px; }
.page-size-control { height: 32px; border-radius: 6px; }

/* Tabs and settings */
.settings-layout { gap: 12px; }
.settings-tabs,
.subtabs,
.monitor-config-tabs {
  min-height: 46px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.025);
}
.settings-tabs button,
.subtabs button,
.monitor-config-tabs button {
  position: relative;
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 0;
  color: #667085;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.settings-tabs button::after,
.subtabs button::after,
.monitor-config-tabs button::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  background: transparent;
}
.settings-tabs button:hover,
.subtabs button:hover,
.monitor-config-tabs button:hover { color: #344054; background: #f8fafc; }
.settings-tabs button.active,
.subtabs button.active,
.monitor-config-tabs button.active { color: var(--brand); background: transparent; }
.settings-tabs button.active::after,
.subtabs button.active::after,
.monitor-config-tabs button.active::after { background: var(--brand); }

.config-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.config-panel > .panel-head,
.config-panel > .config-toolbar,
.config-panel > .maintenance-overview,
.config-panel > .admin-summary,
.config-panel > .footer-actions {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow);
}
.config-panel > .panel-head { margin-bottom: 12px; }
.config-panel > .footer-actions { margin-top: 12px; }
.settings-section-grid { gap: 12px; }
.settings-block,
.setting-band,
.config-card,
.ai-resource-card,
.model-card,
.channel-card,
.route-card,
.monitor-pace-card,
.maintenance-card {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--shadow);
}
.settings-block { padding: 15px; }
.settings-block > header,
.setting-band-head,
.ai-resource-card > header,
.config-card > header {
  margin-bottom: 13px;
  padding-bottom: 11px;
  border-bottom: 1px solid #e8ecf2;
}
.settings-block > header strong,
.setting-band-head strong { color: #1d2939; font-size: 14px; font-weight: 700; }
.settings-block > header span,
.setting-band-head span { color: var(--muted); font-size: 11px; }
.setting-note {
  border-color: #dce3ed;
  border-radius: 6px;
  color: #475467;
  background: #f8fafc;
}
.footer-actions {
  gap: 7px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e8ecf2;
}
.ai-section-footer,
.credential-footer-actions { border-radius: 0; background: transparent; }

/* AI resource workbench */
.ai-settings-panel .ai-console {
  gap: 12px;
  padding: 14px;
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: #f6f8fb;
}
.ai-console-head { gap: 14px; padding-bottom: 12px; }
.ai-console-title { gap: 4px; }
.ai-console-title strong { font-size: 19px; font-weight: 740; }
.ai-console-title p { color: var(--muted); font-size: 12px; }
.ai-health-pill { min-height: 32px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.ai-route-matrix,
.ai-resource-card { gap: 10px; padding: 12px; border-color: var(--line); border-radius: var(--radius-panel); box-shadow: none; }
.ai-route-matrix header,
.ai-resource-card > header { padding-bottom: 10px; }
.ai-route-matrix header strong,
.ai-resource-card header strong { font-size: 14px; font-weight: 700; }
.ai-route-summary span { border-radius: 5px; font-size: 10px; font-weight: 650; }
.ai-route-table { border-radius: 6px; }
.ai-route-table-head { font-size: 11px; font-weight: 700; }
.ai-route-config-row { border-left-width: 3px; }
.ai-section-footer span { font-size: 11px; font-weight: 550; }
.ai-resource-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.ai-resource-card { overflow: hidden; }
.ai-resource-body.provider {
  grid-template-columns: minmax(190px, .32fr) minmax(0, 1fr);
  gap: 12px;
}
.ai-resource-body.model {
  grid-template-columns: minmax(250px, .36fr) minmax(0, 1fr);
  gap: 12px;
}
.ai-provider-list { max-height: 430px; }
.ai-provider-list-item { min-height: 62px; }
.ai-provider-card,
.ai-model-card { border-color: var(--line); border-radius: var(--radius-panel); background: #fff; }
.ai-provider-card .form-grid,
.ai-model-card .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.ai-model-provider-note {
  grid-template-columns: minmax(150px,.35fr) minmax(190px,.5fr) minmax(0,1fr);
  border-radius: 6px;
}
.ai-model-provider-note strong,
.ai-model-provider-note span,
.ai-model-provider-note em { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-inline-create { border-radius: 6px; }
.ai-provider-create-form {
  grid-template-columns: minmax(170px,.8fr) minmax(180px,.8fr) minmax(260px,1.3fr) auto;
  align-items: end;
}
.ai-provider-create-form > .field { min-width: 0; }
.ai-provider-create-form > .primary-button { align-self: end; }

/* Workflow and generation forms */
.stepper {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
}
.stepper button {
  min-height: 68px;
  padding: 11px 13px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
}
.stepper button:last-child { border-right: 0; }
.stepper button.active { background: var(--brand-soft); box-shadow: inset 0 -2px var(--brand); }
.stepper button.done { background: #f2faf6; box-shadow: inset 0 -2px var(--ok); }
.stepper strong { width: 22px; height: 22px; font-size: 11px; }
.stepper span { margin-top: 6px; font-size: 12px; font-weight: 700; }
.stepper small { margin-top: 3px; font-size: 10px; }
.task-stage-panel,
.batch-generation-panel { border-radius: var(--radius-panel); }
.task-stage-grid { gap: 0; }
.task-stage-main,
.task-stage-side { padding: 16px; }
.task-stage-side { background: #f8fafc; }
.advanced-settings,
.batch-common-settings { border-color: var(--line); border-radius: var(--radius-panel); }
.advanced-settings summary,
.batch-common-settings summary { min-height: 46px; border-radius: 7px; }
.setting-band { box-shadow: none; }
.upload-drop,
.mini-upload { border-radius: var(--radius-panel); background: #f8fafc; }
.batch-product-row { border-color: var(--line); border-radius: var(--radius-panel); box-shadow: none; }
.preview-card { border-radius: var(--radius-panel); }

/* Logs */
.log-workspace { border-radius: var(--radius-panel); }
.log-workspace .log-table-head { padding: 16px 16px 12px; }
.log-table-head h2 { font-size: 16px; font-weight: 720; }
.log-table-head p { color: var(--muted); font-size: 11px; }
.log-table-stats span,
.log-table-stats em { min-height: 22px; border-radius: 5px; font-size: 10px; }
.log-workspace .log-action-bar { padding: 9px 16px; background: #fff; }
.log-table th,
.log-table td { padding: 9px 10px; }
.log-event-cell { gap: 3px; }
.log-event-cell > strong { font-size: 12px; }
.log-event-cell > p { font-size: 11px; line-height: 1.45; }
.log-event-facts span { font-size: 10px; }
.log-module-stack span,
.log-module-stack em,
.log-context-cell span,
.log-context-cell em,
.log-request-cell span { font-size: 10px; }
.log-workspace .pagination { border-top: 1px solid var(--line); padding: 10px 16px; }

/* Modals, drawers and transient feedback */
.modal { padding: 24px; background: rgba(16, 24, 40, .48); backdrop-filter: blur(3px); }
.modal-panel,
.drawer-panel {
  border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-float);
}
.modal-panel { max-height: min(88vh, 900px); }
.drawer-panel header,
.modal-panel header { padding: 14px 16px; }
.drawer-panel header span,
.modal-panel header span { color: var(--muted); font-size: 10px; font-weight: 650; }
.drawer-panel h2,
.modal-panel h2 { font-size: 18px; font-weight: 730; }
.drawer-body,
.modal-body { padding: 16px; }
.modal-section {
  border-color: var(--line);
  border-radius: var(--radius-panel);
  background: #fff;
}
.modal-section + .modal-section { margin-top: 12px; }
.toast { border-radius: var(--radius-panel); box-shadow: var(--shadow-float); }
.empty {
  min-height: 112px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
}

/* Responsive behavior */
@media (max-width: 1380px) {
  .app { grid-template-columns: 224px minmax(0, 1fr); }
  .app.sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
  .workspace { padding-inline: 18px; }
  .topbar { margin-inline: -18px; padding-inline: 18px; }
  .library-filter-bar,
  .library-filter-bar.list-filter-bar,
  .library-filter-bar.monitor-filter-bar,
  .library-filter-bar.template-filter-bar,
  .library-filter-bar.exception-filter-bar,
  .library-filter-bar.check-filter-bar,
  .library-filter-bar.monitor-history-filter-bar,
  .library-filter-bar.monitor-handled-filter-bar {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }
  .library-filter-bar > .keyword-filter,
  .library-filter-bar > .library-keyword-filter { flex-basis: 250px; min-width: 250px; }
  .library-filter-bar > .compact-filter-select { flex-basis: 112px; min-width: 104px; }
  .library-filter-scroll > .keyword-filter { flex-basis: 270px; min-width: 270px; }
  .library-filter-scroll > .compact-filter-select { flex-basis: 104px; min-width: 104px; }
  .log-filter-scroll > .log-filter-keyword { min-width: 240px; flex-basis: 240px; }
  .ai-provider-create-form { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 980px) {
  .app { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 24;
    width: 100%;
    height: auto;
    min-height: 60px;
    overflow: visible;
  }
  .brand { min-height: 60px; }
  .brand-copy span { display: none; }
  .nav { max-height: calc(100dvh - 60px); display: none; overflow-y: auto; }
  .app.mobile-nav-open .nav { display: grid; }
  .sidebar-footer { display: none; }
  .app.mobile-nav-open .sidebar { width: 100%; min-width: 100%; }
  .app.mobile-nav-open .sidebar {
    position: fixed;
    inset: 0;
    z-index: 40;
    height: 100dvh;
    overflow: hidden;
  }
  .app.mobile-nav-open .nav {
    max-height: calc(100dvh - 60px);
    padding-bottom: 28px;
  }
  .mobile-nav-open .brand { justify-content: flex-start; padding-inline: 15px 12px; }
  .mobile-nav-open .brand-mark { display: grid !important; }
  .mobile-nav-open .brand-copy,
  .mobile-nav-open .nav-label,
  .mobile-nav-open .nav-chevron,
  .mobile-nav-open .nav-group.expanded .nav-children {
    display: block !important;
  }
  .mobile-nav-open .nav-group { display: grid; }
  .mobile-nav-open .nav-dashboard,
  .mobile-nav-open .nav-parent {
    min-height: 44px;
    justify-content: flex-start;
    padding: 0 15px;
    gap: 11px;
  }
  .mobile-nav-open .nav-children button {
    width: 100%;
    min-height: 36px;
    display: flex !important;
    padding: 0 14px 0 43px;
  }
  .mobile-nav-open .sidebar-toggle {
    position: absolute;
    top: 14px;
    right: 12px;
    display: grid !important;
    margin-left: 0;
    color: #dbe4f2;
    background: rgba(255,255,255,.08);
  }
  .mobile-nav-open .brand-copy { padding-right: 48px; }
  .workspace { padding: 0 14px 24px; }
  .topbar { position: static; min-height: 52px; margin-inline: -14px; padding-inline: 14px; }
  .page-head { min-height: 96px; padding: 14px 0; }
  .page-head h1 { font-size: 21px; }
  .page-head > div > span { font-size: 12px; }
  .page-actions { align-self: flex-end; }
  .dashboard-hero,
  .dashboard-filter-panel,
  .dashboard-activity-grid,
  .task-stage-grid { grid-template-columns: 1fr; }
  .dashboard-filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .task-stage-side { border-left: 0; border-top: 1px solid var(--line); }
  .log-filter-scroll > .log-filter-keyword { min-width: 230px; flex-basis: 230px; }
  .ai-console-head,
  .ai-route-table-head,
  .ai-route-config-row,
  .ai-resource-body.provider,
  .ai-resource-body.model { grid-template-columns: 1fr; }
  .ai-route-table-head { display: none; }
  .ai-route-config-row { gap: 8px; }
  .ai-provider-create-form { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .status-pill { display: none; }
  .topbar-account-cluster {
    width: auto;
    min-height: 40px;
    align-self: flex-end;
    padding: 2px;
  }
  .topbar-account-divider { display: none; }
  .user-switch { width: auto; min-height: 34px; }
  .profile-button { width: 34px; min-height: 34px; justify-content: center; padding: 2px; }
  .profile-avatar { width: 30px; height: 30px; }
  .profile-copy { display: none; }
  .profile-chevron { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .page-actions > button { flex: 1 1 auto; }
  .panel { padding: 12px; }
  .dashboard-filter-grid,
  .dashboard-metric-grid,
  .metric-grid,
  .admin-summary,
  .grid-2,
  .grid-3,
  .card-grid,
  .form-grid,
  .form-grid.three,
  .settings-section-grid { grid-template-columns: 1fr; }
  .stepper button { min-height: 60px; padding: 9px; }
  .stepper small { display: none; }
  .table-context,
  .pagination { align-items: stretch; flex-direction: column; }
  .bulk-bar { align-items: stretch; }
  .bulk-spacer { display: none; }
  .bulk-bar > button,
  .bulk-bar > label { flex: 1 1 calc(50% - 6px); }
  .log-workspace .log-filter-panel,
  .log-filter-panel { align-items: flex-end; flex-direction: row; }
  .log-filter-actions > button { flex: 0 0 auto; padding-inline: 10px; }
  .modal { padding: 10px; }
  .modal-panel { max-height: 94dvh; }
  .modal-grid { grid-template-columns: 1fr; }
  .monitor-config-panel {
    max-width: 100%;
    min-width: 0;
  }
  .monitor-config-panel > .panel-head,
  .monitor-config-head,
  .monitor-config-switch,
  .monitor-config-summary,
  .monitor-session-view,
  .amazon-engine-card,
  .amazon-session-card,
  .monitor-config-panel > .footer-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .monitor-config-panel > .panel-head,
  .monitor-config-head,
  .monitor-config-switch,
  .monitor-config-summary,
  .monitor-session-view,
  .monitor-config-panel > .footer-actions {
    margin-inline: 0;
  }
  .monitor-config-switch { padding: 10px; }
  .monitor-config-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .monitor-config-summary,
  .amazon-engine-card,
  .amazon-engine-stats,
  .amazon-engine-settings,
  .amazon-session-meta,
  .amazon-session-action-grid { grid-template-columns: 1fr; }
  .mini-stat strong,
  .amazon-engine-card strong,
  .amazon-session-card strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
