/* Shared additions on top of each portal's original "Botanical Earth & Living Sage" styles:
   live-data states, sign-in gate, forms in modals, toasts, preview banner and phone layouts. */
:root {
  --cc-primary: #1D351C; --cc-accent: #DAE066; --cc-olive: #6C7C37; --cc-canvas: #F9FAF5;
  --cc-surface: #FFFFFF; --cc-soft: #F3F5EC; --cc-ink: #142213; --cc-muted: #4A5646; --cc-light: #71806D;
  --cc-border: #E2E8D8; --cc-border-strong: #CAD4BE;
  --cc-bad-bg: #FDECEC; --cc-bad: #991B1B;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid #6C7C37; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Ecosystem bar: scrolls sideways on phones instead of wrapping into a tall block */
.ecosystem-pills { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.ecosystem-pills::-webkit-scrollbar { display: none; }
.ecosystem-pill { white-space: nowrap; }
.ecosystem-session { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #CAD4BE; }
.ecosystem-session button { background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 9999px; padding: 3px 10px; font: inherit; cursor: pointer; }

/* Status badges used across portals (fills gaps where a page's own CSS lacks one) */
.status-badge { display: inline-flex; align-items: center; gap: 5px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 9999px; border: 1px solid transparent; line-height: 1.3; }
.status-badge.locked { background: #EAF7EC; color: #1B5E20; border-color: #A3D9A5; }
.status-badge.pool { background: #EBF5F0; color: #1E5631; border-color: #A8D5BA; }
.status-badge.queued { background: #FDF6E7; color: #8A5311; border-color: #F3D19E; }
.status-badge.requested { background: #EEF2FF; color: #3730A3; border-color: #C7D2FE; }
.status-badge.unassigned { background: #F3F4F6; color: #374151; border-color: #D1D5DB; }
.status-badge.bad { background: var(--cc-bad-bg); color: var(--cc-bad); border-color: #F5B5B5; }

/* Notices and empty states */
.cc-notice { border-radius: 10px; padding: 14px 16px; font-size: 13.5px; line-height: 1.55; background: var(--cc-soft); border: 1px solid var(--cc-border); color: var(--cc-ink); }
.cc-notice.bad { background: var(--cc-bad-bg); border-color: #F5B5B5; color: var(--cc-bad); }
.cc-notice.ok { background: #EAF7EC; border-color: #A3D9A5; color: #1B5E20; }
.cc-empty { text-align: center; padding: 36px 20px; color: var(--cc-muted); font-size: 14px; border: 1px dashed var(--cc-border-strong); border-radius: 12px; background: var(--cc-soft); }
.cc-empty strong { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 18px; color: var(--cc-primary); margin-bottom: 6px; }
.cc-loading { color: var(--cc-light); font-size: 13px; padding: 18px 0; }
.mono, .serial { font-family: 'JetBrains Mono', monospace; }
.serial { font-size: 12px; font-weight: 700; color: var(--cc-primary); background: var(--cc-soft); border: 1px solid var(--cc-border); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.cc-muted { color: var(--cc-muted); }
.cc-small { font-size: 12px; }
.cc-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cc-spacer { flex: 1; }

/* Generic buttons for pages whose CSS doesn't define them */
.cc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 13.5px 'Plus Jakarta Sans', system-ui, sans-serif; padding: 11px 20px; border-radius: 9999px; border: 1px solid var(--cc-primary); background: var(--cc-primary); color: #fff; cursor: pointer; text-decoration: none; min-height: 44px; }
.cc-btn:hover { background: #142614; }
.cc-btn.secondary { background: #fff; color: var(--cc-primary); border-color: var(--cc-border-strong); }
.cc-btn.secondary:hover { background: var(--cc-soft); }
.cc-btn.accent { background: var(--cc-accent); color: var(--cc-primary); border-color: var(--cc-accent); }
.cc-btn.small { padding: 6px 14px; min-height: 34px; font-size: 12.5px; }
.cc-btn.link { background: none; border: none; color: var(--cc-primary); text-decoration: underline; padding: 0; min-height: 0; }
.cc-btn[disabled] { opacity: .55; cursor: not-allowed; }
button.btn-primary[disabled], button.btn-secondary[disabled], button.action-btn-sm[disabled] { opacity: .55; cursor: not-allowed; }

/* Modal forms (uses the portals' .modal-backdrop / .modal-box look) */
.cc-modal.modal-backdrop { display: flex; position: fixed; inset: 0; background: rgba(20, 34, 19, 0.72); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.cc-modal .modal-box { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px; box-shadow: 0 20px 45px -10px rgba(20,34,19,.25); }
.cc-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.cc-modal-head h3 { font-family: 'Playfair Display', Georgia, serif; font-size: 21px; color: var(--cc-primary); line-height: 1.25; }
.cc-modal-close { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--cc-muted); padding: 4px 8px; min-width: 44px; min-height: 44px; }
.cc-modal-intro { font-size: 13px; color: var(--cc-muted); margin-bottom: 14px; }
.cc-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.cc-field { margin-bottom: 12px; }
.cc-field > label { font-size: 12px; font-weight: 700; display: block; margin-bottom: 5px; color: var(--cc-ink); }
.cc-field .hint { font-size: 11.5px; color: var(--cc-light); margin-top: 4px; }
.cc-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.text-input, .cc-field input:not([type=checkbox]):not([type=radio]), .cc-field select, .cc-field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--cc-border-strong); border-radius: 8px; font: 500 14px 'Plus Jakarta Sans', system-ui, sans-serif; background: #fff; color: var(--cc-ink); min-height: 44px; }
.cc-field textarea { min-height: 90px; resize: vertical; }
.cc-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; font-weight: 500 !important; }
.cc-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--cc-primary); }

/* Toast */
.cc-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--cc-primary); color: #fff; padding: 12px 20px; border-radius: 9999px; font-size: 13.5px; font-weight: 600; z-index: 2000; box-shadow: 0 10px 30px rgba(20,34,19,.3); max-width: calc(100vw - 32px); }

/* Preview banner */
.cc-demo-banner { background: var(--cc-accent); color: var(--cc-primary); text-align: center; font-size: 12.5px; font-weight: 700; padding: 7px 16px; }
.cc-demo-banner a { color: inherit; }

/* Sign-in gate shown inside a portal when nobody is signed in */
.cc-gate { max-width: 460px; margin: 48px auto; background: #fff; border: 1px solid var(--cc-border); border-radius: 18px; padding: 30px; box-shadow: 0 10px 30px -5px rgba(20,34,19,.07); }
.cc-gate h2 { font-family: 'Playfair Display', Georgia, serif; font-size: 26px; color: var(--cc-primary); margin-bottom: 6px; }
.cc-gate p { font-size: 14px; color: var(--cc-muted); margin-bottom: 18px; }
.cc-gate .cc-btn { width: 100%; }

/* Photos with the co-brand watermark */
.cc-photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--cc-soft); border: 1px solid var(--cc-border-strong); }
.cc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-photo .wm { position: absolute; right: 8px; bottom: 8px; background: rgba(20,34,19,.86); color: var(--cc-accent); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 5px; letter-spacing: .02em; }
.cc-photo-empty { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--cc-light); font-size: 12.5px; padding: 12px; min-height: 115px; }

/* Explainers that work in every browser */
details.cc-explain { display: inline-block; position: relative; }
details.cc-explain > summary { list-style: none; cursor: pointer; }
details.cc-explain > summary::-webkit-details-marker { display: none; }
details.cc-explain .cc-explain-body { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(300px, 80vw); background: #142213; color: #fff; font-size: 12.5px; line-height: 1.5; padding: 12px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
details.cc-explain .cc-explain-body strong { color: var(--cc-accent); display: block; margin-bottom: 4px; }

/* Data tables stack into cards on phones (each cell carries data-label) */
@media (max-width: 760px) {
  table.data-table.cc-stack, table.data-table.cc-stack thead, table.data-table.cc-stack tbody, table.data-table.cc-stack tr, table.data-table.cc-stack th, table.data-table.cc-stack td { display: block; width: 100%; }
  table.data-table.cc-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  table.data-table.cc-stack tr { border-bottom: 1px solid var(--cc-border); padding: 12px 14px; }
  table.data-table.cc-stack th, table.data-table.cc-stack td { border: none !important; padding: 4px 0 !important; }
  table.data-table.cc-stack td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--cc-light); margin-bottom: 2px; }
  .table-wrapper { overflow-x: visible; }
}

/* Phone layouts for the portal headers and grids */
/* Dashboards: KPI tiles and chart cards (charts.js) */
.dash-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.dash-kpi { background: var(--cc-surface); border: 1px solid var(--cc-border); border-radius: 12px; padding: 16px; }
.dash-kpi .k { font-size: 12px; font-weight: 700; color: var(--cc-muted); }
.dash-kpi .v { font-family: 'Playfair Display', Georgia, serif; font-size: 30px; font-weight: 700; color: var(--cc-primary); line-height: 1.15; margin: 6px 0 4px; }
.dash-kpi .s { font-size: 12px; color: var(--cc-muted); }
.dash-kpi .up { color: #1B5E20; font-weight: 700; } .dash-kpi .down { color: #8A5311; font-weight: 700; }
.dash-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.dash-card { background: var(--cc-surface); border: 1px solid var(--cc-border); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.dash-card.wide { margin-bottom: 18px; }
.dash-card h4 { font-family: 'Playfair Display', Georgia, serif; font-size: 17px; color: var(--cc-primary); margin: 0 0 2px !important; }
.dash-card .sub { font-size: 12.5px; color: var(--cc-muted); margin: 0 0 12px; }
.dash-chart { position: relative; }
.dash-plot { width: 100%; overflow: hidden; }
.dash-plot svg { display: block; max-width: 100%; height: auto; }
.dash-grid { stroke: #EEF1E8; stroke-width: 1; } .dash-axis { stroke: #CAD4BE; stroke-width: 1; }
.dash-tick { font: 11px 'Plus Jakarta Sans', system-ui, sans-serif; fill: #71806D; }
.dash-rowlabel { font: 600 12.5px 'Plus Jakarta Sans', system-ui, sans-serif; fill: #142213; }
.dash-value { font: 600 11.5px 'JetBrains Mono', monospace; fill: #4A5646; }
.dash-track { fill: #F3F5EC; }
.dash-legend { list-style: none; display: flex; gap: 16px; flex-wrap: wrap; padding: 0; margin: 0 0 10px; font-size: 12.5px; color: var(--cc-muted); }
.dash-legend li { display: inline-flex; align-items: center; gap: 6px; }
.dash-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.dash-tip { position: absolute; z-index: 5; pointer-events: none; background: #142213; color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 8px; box-shadow: 0 8px 24px rgba(29,53,28,.18); min-width: 140px; }
.dash-tip strong { display: block; margin-bottom: 4px; } .dash-tip b { font-family: 'JetBrains Mono', monospace; }
.dash-table summary { cursor: pointer; font-size: 12px; color: var(--cc-olive); margin-top: 8px; }
.dash-table table { margin-top: 8px; font-size: 12.5px; }
.dash-card .chain-ok { color: #1B5E20; font-weight: 700; }
.dash-note { font-size: 12px; color: var(--cc-light); margin-top: 6px; }
@media (max-width: 1100px) { .dash-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  .dash-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-kpi .v { font-size: 24px; }
  .dash-grid2 { grid-template-columns: 1fr; }
  .dash-card { padding: 14px; }
}

@media (max-width: 760px) {
  .ecosystem-nav { padding: 8px 16px !important; }
  .ecosystem-brand { display: none !important; }
  .portal-header, .portal-nav { padding: 14px 16px !important; flex-direction: column; align-items: flex-start !important; gap: 12px !important; }
  .portal-header > div:last-child, .header-actions { flex-wrap: wrap; width: 100%; }
  .container { padding-left: 16px !important; padding-right: 16px !important; }
  .cc-field-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .kpi-val { font-size: 22px !important; }
  .command-pool-grid { grid-template-columns: 1fr 1fr !important; }
  .admin-module-tabs { overflow-x: auto; flex-wrap: nowrap !important; }
  .module-tab-btn { white-space: nowrap; flex: 0 0 auto !important; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap !important; max-width: 100%; }
  .filter-tab { white-space: nowrap; }
  .table-toolbar, .section-toolbar { flex-direction: column; align-items: flex-start !important; gap: 12px; }
  .cc-modal .modal-box { padding: 20px; border-radius: 14px; }
}
@media (max-width: 420px) {
  .kpi-grid, .command-pool-grid { grid-template-columns: 1fr !important; }
}
