/* Presentation only. Keep DOM, navigation, permissions and business state intact. */
:root {
  --erp-canvas: #fafafc;
  --erp-paper: #fff;
  --erp-graphite: #1d1d1f;
  --erp-caption: #616167;
  --erp-silver: #e5e5e9;
  --erp-control-line: #c8c8ce;
  --erp-action: #0066cc;
  --erp-selection: #e8f1fc;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--erp-graphite);
  background: var(--erp-canvas);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

body, .content, .filing-footer { background: var(--erp-canvas); }
body { font-size: 14px; line-height: 1.5; }
button, input, select, textarea { accent-color: var(--erp-action); }
button {
  border-color: var(--erp-action);
  background: var(--erp-action);
  border-radius: 8px;
  font-weight: 500;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
button:hover:not(:disabled) { filter: brightness(.96); }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #8ab9ed;
  outline-offset: 3px;
}
.secondary {
  background: var(--erp-paper);
  border-color: var(--erp-control-line);
  color: var(--erp-graphite);
}
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  border-color: var(--erp-control-line);
  border-radius: 8px;
  color: var(--erp-graphite);
  background-color: var(--erp-paper);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #bdd7f5;
  outline-offset: 1px;
  border-color: var(--erp-action);
}
input::placeholder, textarea::placeholder { color: #76767d; }
label, .field-control { color: var(--erp-caption); font-weight: 500; }
table, .metric strong, .pager { font-variant-numeric: tabular-nums; }

/* A quiet macOS-like sidebar; the existing hierarchy and hit targets remain. */
.sidebar {
  background: #f5f5f7;
  border-color: #ddddE2;
  padding: 24px 14px 16px;
  gap: 24px;
}
.brand-lockup { gap: 9px; padding: 0 4px; }
.brand-mark { width: 36px; height: 36px; }
.brand-lockup h1 { font-size: 16px; letter-spacing: -.4px; font-weight: 650; }
.brand-lockup p { font-size: 11px; color: var(--erp-caption); }
.sidebar nav { gap: 6px; }
.sidebar-icon { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -2px; pointer-events: none; }
.sidebar .nav-item {
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #48484d;
  background: transparent;
}
.sidebar .nav-item:not(.nav-group-title):not(.active):hover:not(:disabled) { background: #e2e2e7; filter: none; }
.sidebar .nav-item.main-nav { font-size: 15px; font-weight: 600; color: var(--erp-graphite); }
.sidebar .nav-item.main-nav:not(:first-child):not(:disabled) { margin-top: 8px; }
.sidebar .nav-item.main-nav.active { color: var(--erp-graphite); background: #e2e2e7; }
.sidebar .nav-item.sub-nav { padding-left: 28px; font-size: 14px; }
.sidebar .nav-item.sub-nav.active {
  color: #fff;
  background: var(--erp-action);
  border-color: transparent;
  font-weight: 600;
}
.sidebar .nav-item.main-nav:not([data-section]).active { background: var(--erp-action); color: #fff; }
.sidebar .nav-item.disabled { color: #6e6e75; background: transparent; }
.sidebar-footer { border-top: 1px solid #d9d9df; padding-top: 12px; gap: 8px; }
.sidebar .release-version-link { padding: 8px 10px; }
.release-version-link strong { font-size: 12px; color: var(--erp-graphite); }
.release-version-link span { font-size: 11px; color: var(--erp-caption); }
#logoutButton { min-height: 32px; font-size: 14px; background: transparent; border-color: #cccCd3; }

.content {
  padding: 28px 32px;
  gap: 16px;
  grid-template-rows: none;
  grid-auto-rows: max-content;
  align-content: start;
}
/* Keep the live-status node present, without an empty row and two grid gaps. */
.content > #statusText:empty {
  position: absolute;
  min-height: 0;
  width: 0;
  height: 0;
  margin: 0;
  overflow: hidden;
}
.topbar { padding: 0 0 18px; border-bottom: 1px solid var(--erp-silver); }
.topbar > div:first-child { min-width: 0; }
.topbar-actions { flex-shrink: 0; }
.topbar h2 { font-size: 29px; font-weight: 650; letter-spacing: -.8px; line-height: 1.25; }
/* These two pages use their content heading; retain the bar only for network recovery. */
.content:has(> :is(#costConfigPage, #marginDailyPage).active) > .topbar > div:first-child {
  display: none;
}
.content:has(> :is(#costConfigPage, #marginDailyPage).active) > .topbar:has(.network-recovery-notice.hidden) {
  display: none;
}
.topbar p, .section-header p, .detail-header p { color: var(--erp-caption); font-size: 12px; line-height: 1.65; }
#refreshButton { background: var(--erp-paper); color: var(--erp-action); border-color: var(--erp-control-line); white-space: nowrap; }
.section-header h3 { font-size: 19px; letter-spacing: -.35px; font-weight: 650; }
.section-header h4 { font-size: 15px; font-weight: 600; }
.section-header { align-items: flex-start; }
/* These page headings repeat the visible topbar verbatim. Keep their notes/actions. */
:is(#competitorPage, #operationDailyPage, #toolsPage) > .section-header:first-child > div > h3 {
  display: none;
}
:is(#competitorPage, #operationDailyPage, #toolsPage) > .section-header:first-child > div > p {
  margin-top: 0;
}
.page-panel.active { row-gap: 18px; }
#hourlyPage, .home-trend {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* Filters keep their original columns, order and responsive breakpoints. */
.hourly-filters, .trend-filters, .margin-daily-filters, .operation-daily-filters, .filters {
  background: var(--erp-paper);
  padding: 16px;
  border: 1px solid var(--erp-silver);
  border-radius: 12px;
}
.hourly-trend-panel, .hourly-card, .table-wrap, .cost-card, .tool-card,
.ai-workspace, .operation-registration-panel {
  border-color: var(--erp-silver);
  border-radius: 12px;
  background: var(--erp-paper);
}
.hourly-trend-panel { padding: 20px; gap: 12px; border-radius: 16px; }
.hourly-trend-filters { grid-template-columns: 180px auto; justify-content: start; }
.hourly-trend-legend { display: flex; gap: 20px; flex-wrap: wrap; padding: 0; border: 0; background: transparent; }
.hourly-trend-chart-area { margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.hourly-grid { gap: 18px; }
.hourly-card header { padding: 14px 18px; justify-content: flex-start; background: #fafafa; border-color: var(--erp-silver); }
.hourly-card header strong { color: var(--erp-graphite); font-weight: 650; }
.hourly-card header span { color: var(--erp-caption); font-weight: 500; }
th { background: #fafafa; color: var(--erp-caption); }
th, td { border-bottom-color: #eeeef0; }
.hourly-matrix thead th { background: #fafafa; color: var(--erp-caption); font-weight: 500; }
.hourly-matrix td strong { color: var(--erp-graphite); font-weight: 600; }
tbody tr:hover { background: #f3f7fc; }
.metric { border-color: var(--erp-silver); border-radius: 12px; background: var(--erp-paper); }
.metric strong { color: var(--erp-graphite); letter-spacing: -.5px; }
.metric-toggle { border-color: var(--erp-control-line); border-radius: 7px; color: #48484d; }
.metric-toggle:has(input:checked) { border-color: #a8c9ed; background: var(--erp-selection); }
.chart-area { border-color: var(--erp-silver); border-radius: 10px; background: var(--erp-paper); }
.pager { color: var(--erp-caption); }
.detail-panel { border-color: var(--erp-silver); padding: 24px; box-shadow: -6px 0 24px rgb(0 0 0 / 8%); }
.operation-modal-panel, .release-upgrade-panel { border-radius: 16px; border-color: var(--erp-silver); box-shadow: 0 8px 32px rgb(0 0 0 / 12%); }
.ai-history { background: #f7f7f9; border-color: var(--erp-silver); }
.finance-page {
  --ledger-ink: var(--erp-graphite);
  --ledger-secondary: #515157;
  --ledger-faint: var(--erp-caption);
  --ledger-wash: var(--erp-canvas);
  --ledger-line: var(--erp-silver);
  --ledger-action: var(--erp-action);
}
.finance-heading h3 { font-size: 24px; letter-spacing: -.6px; }
.finance-filter-rail, .finance-schedule-panel { border-radius: 10px; }
.finance-workspace-tabs { flex-wrap: wrap; }
.finance-page tbody tr:hover { background: #f3f7fc; }
.automation-health-page { --console-ink: var(--erp-graphite); --console-mist: var(--erp-canvas); }
.filing-footer { font-size: 11px; color: var(--erp-caption); }

.login-panel { padding: 40px 36px; border-radius: 20px; border-color: var(--erp-silver); gap: 14px; box-shadow: 0 4px 20px rgb(0 0 0 / 4%); }
.login-panel h1 { font-size: 27px; letter-spacing: -.8px; margin-bottom: 12px; text-align: center; }
.login-panel button { margin-top: 10px; min-height: 42px; }

/* Selected option A: spacious, continuous reading order. */
#hourlyPage.active { gap: 20px; }
.hourly-filters { padding: 18px; border-radius: 14px; }
.hourly-trend-panel > .section-header { display: block; }
.hourly-trend-panel > .section-header .status { margin-top: 4px; }
.hourly-trend-chart-layout { grid-template-columns: minmax(0, 1fr); }
.hourly-trend-chart-area svg { height: 220px; }
.hourly-trend-panel > .metric-controls { margin-top: 0; }
.hourly-trend-panel .metric-toggle { padding: 7px 10px; }
.hourly-card { border-radius: 14px; }
.hourly-matrix { min-width: 0; }
.hourly-matrix tbody th { width: auto; }
.hourly-matrix th, .hourly-matrix td { padding: 10px 8px; font-size: 13px; }
@media (max-width: 1099px) { .hourly-matrix { min-width: 940px; } }

@media (min-width: 761px) { .app-view { grid-template-columns: 210px minmax(0, 1fr); } }
@media (min-width: 1100px) {
  .hourly-filters { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
}
@media (min-width: 761px) and (max-width: 1400px) {
  .content { padding: 28px 32px; }
  .sidebar { padding-inline: 12px; }
}
@media (max-width: 760px) {
  .sidebar { padding: 16px; gap: 14px; }
  .sidebar .brand-lockup { grid-column: 1; grid-row: 1; }
  .sidebar .sidebar-footer { grid-column: 2; grid-row: 1; }
  .sidebar nav { grid-row: 2; }
  .sidebar-footer { border-top: 0; padding-top: 0; }
  .sidebar nav { gap: 6px; }
  .sidebar .nav-item.sub-nav { padding-left: 12px; }
  .content { padding: 20px 14px; gap: 18px; }
  .topbar { padding-bottom: 16px; }
  .topbar h2 { font-size: 23px; }
  .hourly-filters, .trend-filters, .margin-daily-filters, .operation-daily-filters, .filters { padding: 14px; }
  .hourly-trend-panel { padding: 14px; }
  .section-header { flex-wrap: wrap; gap: 8px; }
  .finance-heading, .finance-detail-heading { flex-wrap: wrap; }
  .finance-workspace-tabs button { min-width: 0; flex: 1 1 140px; }
  .login-panel { padding: 32px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
@media (prefers-contrast: more) {
  :root { --erp-silver: #9c9ca4; --erp-control-line: #76767d; --erp-caption: #414147; }
}

/* Group labels have no navigation action; child buttons remain the entry points. */
.sidebar .nav-group-title { min-height: 38px; padding: 6.75px 14px; cursor: default; }
