:root {
  --erp-blue: #2490ef;
  --erp-blue-dark: #1676c5;
  --erp-blue-pale: #eaf4fe;
  --erp-ink: #36414c;
  --erp-muted: #74808d;
  --erp-border: #e2e7ec;
  --erp-page: #f5f7fa;
}

html { background: var(--erp-page); }
body { color: var(--erp-ink); background: var(--erp-page); }
.sidebar {
  width: 252px;
  padding: 18px 13px;
  color: var(--erp-ink);
  background: #fff;
  border-right: 1px solid var(--erp-border);
  transition: width .18s ease, transform .18s ease;
}
.brand { padding: 0 9px 24px; color: var(--erp-ink); letter-spacing: 0; }
.brand small { color: var(--erp-muted); letter-spacing: .1em; }
.brand-mark { background: var(--erp-blue); color: #fff; border-radius: 7px; }
.side-label { color: #8a95a2; letter-spacing: .08em; }
.nav-item {
  color: #536171;
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 0;
  padding: 10px 12px;
  font-size: 13px;
  transition: background-color .12s ease, color .12s ease;
}
.nav-item:hover { color: var(--erp-blue-dark); background: #f4f8fc; }
.nav-item.active { color: var(--erp-blue-dark); background: var(--erp-blue-pale); box-shadow: inset 3px 0 var(--erp-blue); }
.sidebar-bottom { color: #5c6976; border-color: var(--erp-border); }
.sidebar-bottom small { color: var(--erp-muted); }
.main-area { margin-left: 252px; transition: margin-left .18s ease; }
.topbar { border-color: var(--erp-border); padding: 0 25px; }
.topbar-leading { display: flex; align-items: center; gap: 13px; }
.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--erp-border);
  border-radius: 5px;
  background: #fff;
  color: #637180;
  cursor: pointer;
  font-size: 16px;
}
.sidebar-toggle:hover { color: var(--erp-blue-dark); border-color: #b7d8f5; background: #f7fbff; }
.breadcrumb { color: #97a1ac; }
.content { max-width: 1600px; }
.page-heading h1 { color: #273541; }
.stat-card, .panel { border-color: var(--erp-border); border-radius: 6px; box-shadow: 0 1px 2px #1f293308; }
.stat-card strong { color: #273541; }
.panel h2, .panel h3 { color: #34404d; }
th { color: #788491; border-color: var(--erp-border); }
td { color: #465362; border-color: #edf0f3; }
tbody tr:hover { background: #f7faff; }
.primary { background: var(--erp-blue); border-radius: 5px; }
.primary:hover { background: var(--erp-blue-dark); }
.secondary, .table-action { border-color: #d8e0e8; color: #536171; border-radius: 5px; }
.table-action:hover, .secondary:hover { background: #f6faff; border-color: #b7d8f5; color: var(--erp-blue-dark); }
.link-button { color: var(--erp-blue-dark); }
.mode-badge { border-radius: 5px; }
.form-dialog { border-radius: 7px; }
.login-page { background: var(--erp-page); }
.login-shell { background: linear-gradient(135deg, #f4f8fc, #fff 70%); }
.login-card { border-color: var(--erp-border); border-radius: 7px; box-shadow: 0 8px 28px #25486b12; }
.login-card input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid #2490ef33;
  border-color: var(--erp-blue);
}
.tech-menu-grid { grid-template-columns: 1fr; max-width: 760px; margin-bottom: 20px; }
.tech-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 45px;
  text-decoration: none;
  font-size: 12px;
}
.tech-menu-link::after { content: "›"; color: #8b98a5; font-size: 18px; font-weight: 400; }
.tech-back-link { display: inline-block; margin-top: 9px; color: var(--erp-blue-dark); font-size: 12px; text-decoration: none; }
.tech-back-link:hover { text-decoration: underline; }
.system-config-content > * + * { margin-top: 16px; }
.system-health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.system-health-card { display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 15px; border: 1px solid var(--erp-border); border-radius: 7px; background: #fff; }
.system-health-dot { display: inline-block; flex: 0 0 9px; width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: #94a0aa; }
.system-health-dot.good, .system-health-card.good .system-health-dot { background: #2f9b69; box-shadow: 0 0 0 4px #2f9b6917; }
.system-health-dot.warn, .system-health-card.warn .system-health-dot { background: #d39b28; box-shadow: 0 0 0 4px #d39b2817; }
.system-health-dot.bad, .system-health-card.bad .system-health-dot { background: #c84e4e; box-shadow: 0 0 0 4px #c84e4e17; }
.system-health-dot.info, .system-health-card.info .system-health-dot { background: var(--erp-blue); box-shadow: 0 0 0 4px #2490ef17; }
.system-health-label, .system-health-note { display: block; color: var(--erp-muted); font-size: 10px; }
.system-health-value { display: block; margin: 5px 0 3px; color: var(--erp-ink); font-size: 14px; }
.system-health-card.bad .system-health-value { color: #b84444; }
.system-health-card.good .system-health-value { color: #267c56; }
.system-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.system-overview-card { min-width: 0; padding: 14px; border: 1px solid var(--erp-border); border-radius: 6px; background: #fff; }
.system-overview-label, .system-overview-note { display: block; color: var(--erp-muted); font-size: 10px; line-height: 1.45; }
.system-overview-value { display: block; margin: 8px 0 4px; overflow-wrap: anywhere; color: var(--erp-ink); font-size: 20px; }
.system-overview-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 16px; }
.system-overview-grid > .panel { min-width: 0; }
.system-activity-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 12px; height: 190px; padding: 8px 4px 0; }
.system-chart-column { display: grid; grid-template-rows: 18px 1fr 20px; align-items: end; justify-items: center; height: 100%; min-width: 0; }
.system-chart-count, .system-chart-day { color: var(--erp-muted); font-size: 10px; }
.system-chart-bar-wrap { display: flex; align-items: end; justify-content: center; width: 100%; height: 100%; border-bottom: 1px solid var(--erp-border); }
.system-chart-bar { width: min(34px, 65%); min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #54a8ed, #2486d3); transition: height .25s ease; }
.system-chart-day { padding-top: 6px; text-transform: capitalize; }
.system-settlement-list { display: grid; gap: 17px; padding-top: 3px; }
.system-settlement-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--erp-muted); font-size: 10px; }
.system-settlement-heading strong { color: var(--erp-ink); font-size: 11px; white-space: nowrap; }
.system-settlement-track { height: 7px; overflow: hidden; border-radius: 8px; background: #edf1f5; }
.system-settlement-fill { height: 100%; border-radius: inherit; background: var(--erp-blue); }
.system-settlement-row:nth-child(2) .system-settlement-fill { background: #319b6a; }
.system-settlement-row:nth-child(3) .system-settlement-fill { background: #d49a2d; }
.system-settlement-row:nth-child(4) .system-settlement-fill { background: #7589a0; }
.system-integration-list { display: grid; gap: 11px; }
.system-integration-row { display: grid; grid-template-columns: 11px 1fr auto; align-items: center; gap: 9px; min-height: 30px; }
.system-integration-row strong { color: var(--erp-ink); font-size: 11px; }
.system-integration-state { font-size: 10px; }
.system-integration-state.good { color: #267c56; }
.system-integration-state.warn { color: #a87816; }
.system-integration-state.neutral { color: var(--erp-muted); }
.system-inventory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.system-inventory-grid .system-overview-card { padding: 11px; }
.system-inventory-grid .system-overview-value { font-size: 17px; }
.system-log-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.system-log-summary .system-overview-card { background: #f8fafc; }
.system-overview-grid .panel-heading { gap: 12px; }
.system-overview-grid .panel-heading > .tech-back-link { flex: 0 0 auto; margin-top: 0; }
.system-overview-refresh { display: flex; align-items: center; gap: 9px; }
.system-overview-refresh .secondary { padding: 6px 9px; font-size: 10px; }
.system-overview-grid + .panel { margin-top: 0; }
.system-config-content > .panel { margin-bottom: 0; }
.system-config-content .table-wrap { max-height: 320px; overflow: auto; }
.system-overview-content > .notice-card { margin-bottom: 14px; }
.system-health-card.bad .system-health-value { color: #b84444; }
.system-health-card.info .system-health-value { color: var(--erp-blue-dark); }
body[data-theme="dark"] .system-health-card,
body[data-theme="dark"] .system-overview-card { background: #1a2530; border-color: #344352; }
body[data-theme="dark"] .system-health-value,
body[data-theme="dark"] .system-overview-value,
body[data-theme="dark"] .system-settlement-heading strong,
body[data-theme="dark"] .system-integration-row strong { color: #dce5ee; }
body[data-theme="dark"] .system-settlement-track { background: #2d3945; }
body[data-theme="dark"] .system-chart-bar-wrap { border-color: #344352; }
body[data-theme="dark"] .system-log-summary .system-overview-card { background: #1a2530; }
@media (max-width: 1050px) {
  .system-health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-overview-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 560px) {
  .system-health-grid, .system-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .system-health-card { padding: 11px; }
  .system-health-value { font-size: 12px; }
  .system-overview-card { padding: 11px; }
  .system-overview-value { font-size: 17px; }
  .system-activity-chart { gap: 5px; }
  .system-chart-day, .system-chart-count { font-size: 8px; }
  .system-log-summary { grid-template-columns: 1fr; }
  .system-overview-grid .panel-heading { align-items: flex-start; flex-direction: column; }
}
.theme-toggle {
  border: 1px solid var(--erp-border);
  border-radius: 5px;
  background: #fff;
  color: #536171;
  padding: 7px 9px;
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--erp-blue-dark); border-color: #b7d8f5; background: #f7fbff; }
.theme-toggle:disabled { opacity: .6; cursor: wait; }

body[data-theme="dark"] {
  --erp-blue-pale: #183550;
  --erp-ink: #dce5ee;
  --erp-muted: #a4b0bc;
  --erp-border: #344352;
  --erp-page: #111922;
  color-scheme: dark;
  color: var(--erp-ink);
  background: var(--erp-page);
}
body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .topbar { background: #17212b; border-color: #2d3a47; }
body[data-theme="dark"] .sidebar { color: #dce5ee; }
body[data-theme="dark"] .brand,
body[data-theme="dark"] .page-heading h1,
body[data-theme="dark"] .stat-card strong,
body[data-theme="dark"] .panel h2,
body[data-theme="dark"] .panel h3,
body[data-theme="dark"] .user-box b { color: #e7edf3; }
body[data-theme="dark"] .brand small,
body[data-theme="dark"] .side-label,
body[data-theme="dark"] .breadcrumb,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .user-box small { color: #a4b0bc; }
body[data-theme="dark"] .nav-item { color: #bac6d2; }
body[data-theme="dark"] .nav-item:hover { background: #202d39; color: #e8f3fd; }
body[data-theme="dark"] .nav-item.active { background: #1d3850; color: #8dc8ff; box-shadow: inset 3px 0 #4ca7f2; }
body[data-theme="dark"] .sidebar-bottom { color: #b7c2cd; border-color: #344352; }
body[data-theme="dark"] .sidebar-bottom small { color: #8e9ca9; }
body[data-theme="dark"] .topbar { box-shadow: 0 1px #ffffff04; }
body[data-theme="dark"] .sidebar-toggle,
body[data-theme="dark"] .theme-toggle,
body[data-theme="dark"] .secondary,
body[data-theme="dark"] .table-action,
body[data-theme="dark"] .tech-menu-link {
  background: #202c37;
  border-color: #3a4a59;
  color: #d1dbe4;
}
body[data-theme="dark"] .sidebar-toggle:hover,
body[data-theme="dark"] .theme-toggle:hover,
body[data-theme="dark"] .secondary:hover,
body[data-theme="dark"] .table-action:hover,
body[data-theme="dark"] .tech-menu-link:hover { background: #293846; border-color: #4b91c8; color: #c4e4ff; }
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .panel,
body[data-theme="dark"] .integration,
body[data-theme="dark"] .setting,
body[data-theme="dark"] .notice-card,
body[data-theme="dark"] .security-note,
body[data-theme="dark"] .safe-box,
body[data-theme="dark"] .stream-event,
body[data-theme="dark"] .package-source-row { background: #1a2530; border-color: #344352; color: #d4dee7; }
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .panel { box-shadow: 0 1px 3px #0003; }
body[data-theme="dark"] th { color: #9eacb9; border-color: #344352; }
body[data-theme="dark"] td { color: #c7d1db; border-color: #2c3945; }
body[data-theme="dark"] tbody tr:hover { background: #202c37; }
body[data-theme="dark"] .status,
body[data-theme="dark"] .pill.neutral { background: #263642; color: #b6d9f5; }
body[data-theme="dark"] .status.pending { background: #46391f; color: #f0cb78; }
body[data-theme="dark"] .status.declined { background: #46272a; color: #ffb0b0; }
body[data-theme="dark"] .test-pill { background: #44371f; color: #f0cb78; }
body[data-theme="dark"] input:not([type="checkbox"]),
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background-color: #121b24;
  border-color: #42515f;
  color: #e0e8ef;
}
body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder { color: #7f8d99; }
body[data-theme="dark"] .form-dialog,
body[data-theme="dark"] .inspector { background: #18232d; border-color: #344352; color: #dce5ee; }
body[data-theme="dark"] .inspector-head,
body[data-theme="dark"] .inspect-section { border-color: #344352; }
body[data-theme="dark"] .inspect-row span:first-child { color: #9eacb9; }
body[data-theme="dark"] .form-dialog::backdrop { background: #05090dcc; }
body[data-theme="dark"] .mode-badge.sandbox { background: #352f23; border-color: #685634; color: #f0d28c; }
body[data-theme="dark"] .mode-badge.sandbox small { color: #c2ad7c; }
body[data-theme="dark"] .mode-badge.live { background: #1e352b; border-color: #345a47; color: #9bddb6; }
body[data-theme="dark"] .mode-badge.live small { color: #93b8a1; }
body[data-theme="dark"] .online-dot { box-shadow: 0 0 0 3px #54ba8b22; }
body[data-theme="dark"] .link-button,
body[data-theme="dark"] .tech-back-link { color: #82c4ff; }
body[data-theme="dark"] .eyebrow,
body[data-theme="dark"] .stat-card span,
body[data-theme="dark"] .stat-card small,
body[data-theme="dark"] .setting span,
body[data-theme="dark"] .integration small,
body[data-theme="dark"] .inspect-section h3,
body[data-theme="dark"] .form-dialog label,
body[data-theme="dark"] .tech-form-grid > label,
body[data-theme="dark"] .tech-section > label:not(.checkbox-label) { color: #b2bfca; }
body[data-theme="dark"] .account-form label { color: #b2bfca; }
body[data-theme="dark"] .error { color: #ff9b9b; }
body[data-theme="dark"] .empty-state { color: #8e9ca9; }
body[data-theme="dark"] .closing-actions select,
body[data-theme="dark"] .tech-form-grid input:not([type="checkbox"]),
body[data-theme="dark"] .tech-form-grid select,
body[data-theme="dark"] .package-source-row input:not([type="checkbox"]) { background: #121b24; border-color: #42515f; color: #e0e8ef; }
body[data-theme="dark"] .account-form input { background: #121b24; border-color: #42515f; color: #e0e8ef; }
@media (max-width: 560px) {
  .theme-toggle { padding: 6px 7px; font-size: 10px; }
  .user-box { gap: 7px; }
}

@media (min-width: 761px) {
  body.sidebar-collapsed .sidebar { width: 70px; padding-right: 9px; padding-left: 9px; }
  body.sidebar-collapsed .main-area { margin-left: 70px; }
  body.sidebar-collapsed .brand { justify-content: center; padding-right: 0; padding-left: 0; }
  body.sidebar-collapsed .brand > span:last-child,
  body.sidebar-collapsed .side-label,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .sidebar-bottom small { display: none; }
  body.sidebar-collapsed .nav-item { justify-content: center; padding-right: 5px; padding-left: 5px; font-size: 17px; }
  body.sidebar-collapsed .sidebar-bottom { text-align: center; padding-right: 0; padding-left: 0; }
}

@media (max-width: 760px) {
  .sidebar {
    width: 252px;
    padding: 18px 13px;
    transform: translateX(-102%);
    box-shadow: 8px 0 26px #172b3b20;
    z-index: 4;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 3;
    background: #182b3b55;
  }
  .brand { justify-content: flex-start; padding: 0 9px 24px; }
  .brand > span:last-child, .side-label, .nav-item span, .sidebar-bottom { display: initial; }
  .side-label { display: block; }
  .nav-item { justify-content: flex-start; padding: 10px 12px; font-size: 13px; }
  .nav-item span { font-size: 13px; }
  .sidebar-bottom { margin-top: auto; padding: 17px 9px 2px; text-align: left; }
  .sidebar-bottom small { display: block; }
  .main-area { margin-left: 0; }
  .topbar { padding: 0 12px; }
  .content { padding: 20px 13px 42px; }
}

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

/* Use the full content width for the settings landing pages. */
.tech-menu-grid {
  width: 100%;
  max-width: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.tech-menu-link {
  min-height: 68px;
  padding: 15px 17px;
  border-radius: 8px;
  line-height: 1.4;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tech-menu-link:hover { transform: translateY(-1px); box-shadow: 0 3px 10px #173a390d; }
.tech-menu-link:focus-visible { outline: 3px solid var(--erp-blue); outline-offset: 2px; }
@media (max-width: 1100px) {
  .tech-menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .tech-menu-grid { grid-template-columns: 1fr; }
  .tech-menu-link { min-height: 58px; }
}
