/* Glowbal Contrast & Readability Patch, v1. Visual-only: no business logic.
   Load LAST, after styles.css, grn.css, operations.css and any glass layout add-ons.
   Philosophy: red/black surfaces, readable WHITE text, red controls, soft pink labels. */
:root{
  --gcr-canvas:#120409;--gcr-panel:#280811;--gcr-panel-hi:#390d1a;
  --gcr-crimson:#da183a;--gcr-crimson-bright:#f43e60;
  --gcr-text:#fff5f7;--gcr-soft:#ead0d6;--gcr-border:rgba(255,116,147,.30);
  --gcr-focus:#ffd3dd;--gcr-shadow:0 8px 24px rgba(0,0,0,.19);
}
/* Keep readability consistent with the existing Crimson theme */
#app{color:var(--gcr-text)}
#app .view,#operations-panel,.operation-report-page{color:var(--gcr-text)}
#app .view h1,#app .view h2,#app .view h3,#app .view h4,
#operations-panel h1,#operations-panel h2,#operations-panel h3,#operations-panel h4,
.operation-card h3,.operation-card-head h3,.report-head h3,
.grn-report-section>h3,.grn-analytics-v2 h3,
#app .view .operation-card>h3{
  color:var(--gcr-text)!important;text-shadow:none;
}
/* Target specifically the older WHITE operational cards that clash with dark glass */
#app .operation-card,#operations-panel .operation-card,
#app .operation-report-page .operation-card{
  background:linear-gradient(145deg,rgba(67,13,29,.93),rgba(27,6,13,.96))!important;
  border:1px solid var(--gcr-border)!important;
  border-left:4px solid var(--gcr-crimson-bright)!important;
  color:var(--gcr-text)!important;
  box-shadow:var(--gcr-shadow);border-radius:14px;
}
#app .operation-card p,#operations-panel .operation-card p{
  color:var(--gcr-soft)!important;
}
/* Existing report summary uses white tiles and dark text. Replace on all pages. */
#app .operation-metrics>div,#app .report-summary>span,
#operations-panel .operation-metrics>div,#operations-panel .report-summary>span,
#app .grn-analytics-metrics>div,
#app .view .metric,#app .view .stats-card{
  background:linear-gradient(145deg,rgba(86,21,39,.90),rgba(43,10,20,.96))!important;
  border:1px solid var(--gcr-border)!important;
  border-radius:12px;color:var(--gcr-text)!important;
  box-shadow:0 2px 12px rgba(0,0,0,.12);
}
#app .operation-metrics strong,#app .report-summary strong,
#operations-panel .operation-metrics strong,#operations-panel .report-summary strong,
#app .grn-analytics-metrics strong,
#app .view .metric strong,#app .view .stats-card strong{
  color:#fff!important;opacity:1;font-weight:800;
  font-variant-numeric:tabular-nums;
}
#app .operation-metrics span,#app .report-summary>span,
#operations-panel .operation-metrics span,
#app .grn-analytics-metrics span,
#app .view .metric small,#app .view .stats-card small{
  color:var(--gcr-soft)!important;
}
/* Avoid the previous generic span rule undoing the metric's strong text */
#app .report-summary>span strong{color:#fff!important}
/* Shipment titles and related links must not be dark red on dark red. */
#app .operation-card-head h3,#app .report-head h3,
#app .grn-report-shipment-info strong,#app .grn-analytics-shipment strong,
#app .operation-report-page .report-head h3,
#app .operation-report-page .operation-card-head h3{
  color:#fff!important;opacity:1;
}
#app .operation-card .operation-state,#app .operation-card .device-status{
  font-weight:750;
}
#app .operation-state.open,#app .operation-state.posted{
  background:rgba(218,24,58,.28)!important;color:#fff!important;
  border:1px solid rgba(255,134,157,.36);
}
#app .operation-report-page .report-summary,
#app .operation-report-page .operation-metrics{gap:10px}
/* Standalone cards, panels and tables. Do not change semantics or add data. */
#app .view .panel,#app .view .card,
#app .grn-report-section,#app .grn-carton-filter,#app .grn-bulk-toolbar{
  border-color:var(--gcr-border);
}
#app .grn-compact-table thead th,#app .view table thead th{
  background:#420f20!important;color:#ffe8ee!important;
}
#app .view table td{color:#f9edf0}
#app .view table tbody tr:hover{background:rgba(236,39,76,.13)}
/* Form controls remain strongly readable on dark surfaces */
#app .view input:not([type="checkbox"]):not([type="radio"]),
#app .view select,#app .view textarea,
#operations-panel input:not([type="checkbox"]):not([type="radio"]),
#operations-panel select,#operations-panel textarea{
  background-color:rgba(15,2,7,.88);border-color:rgba(255,150,171,.37);
  color:#fff!important;
}
#app .view input::placeholder,#app .view textarea::placeholder,
#operations-panel input::placeholder{color:#d6b7c0;opacity:1}
#app input[type="checkbox"],#app input[type="radio"]{accent-color:var(--gcr-crimson-bright)}
#app .view button:not(:disabled):hover{filter:brightness(1.12)}
#app .view :is(button,a,input,select,textarea):focus-visible{
  outline:2px solid var(--gcr-focus)!important;outline-offset:2px;
}
/* Explicitly styled states: green means success; crimson means an error.
   Do not force these all to red, because users must distinguish statuses. */
#app .device-status.online{background:#163a29!important;color:#a3f1c5!important}
#app .device-status.offline{background:#303036!important;color:#e9dce0!important}
#app .latest-result{background:#122a20!important;border-left-color:#29b779!important}
#app .latest-result strong{color:#b6f2d0!important}
#app .latest-result span{color:#d8ebdf!important}
#app .result-done .result-pill,#app .result-found .result-pill{
  background:#153824!important;color:#bdf8d4!important;
}
#app .result-missing .result-pill,#app .result-duplicate .result-pill,
#app .result-excess .result-pill,#app .result-removed .result-pill{
  background:#4a1020!important;color:#ffd4dc!important;
}
/* Retina/short screens: keep values visible without introducing horizontal scrolling */
@media(max-width:760px){
 #app .operation-metrics,#app .report-summary{grid-template-columns:repeat(auto-fit,minmax(130px,1fr))}
 #app .operation-card{padding:12px}
 #app .operation-metrics strong,#app .report-summary strong{font-size:clamp(19px,4vw,24px)}
}
@media(prefers-reduced-motion:reduce){#app .view button{transition:none!important}}
