/* ============================================================
   Omnivoltaic Workspace Scanner — oves.css
   Design system: dark slate, Syne + JetBrains Mono
   Works with index.html inline overrides; #appPage.auth-in /
   #appPage.auth-out driven by app.js
   ============================================================ */

/* ── TOKENS ── */
:root {
  --bg:        #0d0f14;
  --surface:   #13161e;
  --panel:     #181c26;
  --border:    #232838;
  --border-hi: #2e3548;
  --text:      #e8eaf0;
  --muted:     #6b7491;
  --dim:       #3d4561;
  --accent:    #5b8df6;
  --accent-lo: rgba(91,141,246,.12);
  --green:     #3ecf8e;
  --green-lo:  rgba(62,207,142,.10);
  --amber:     #f5a623;
  --amber-lo:  rgba(245,166,35,.10);
  --red:       #f26b6b;
  --font:      'Syne', sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --r:         10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  scrollbar-gutter: stable; /* prevent width jump when scrollbar appears */
}

/* ── TOP BAR ── */
.ov-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.ov-topbar-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.ov-topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11.5px;
  color: var(--dim);
  font-family: var(--mono);
}
.ov-topbar-path {
  font-size: 11.5px;
  color: var(--dim);
  font-family: var(--mono);
}

/* ── LANGUAGE SWITCHER ── */
.ov-lang-switcher {
  position: relative;
}
.ov-lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1;
  transition: color .15s, border-color .15s, background .15s;
}
.ov-lang-btn:hover {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--panel);
}
.ov-lang-btn svg {
  flex-shrink: 0;
  opacity: .7;
}
.ov-lang-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  min-width: 154px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  padding: 4px;
}
.ov-lang-switcher.open .ov-lang-dropdown {
  display: block;
}
.ov-lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--muted);
  text-align: left;
  transition: background .12s, color .12s;
}
.ov-lang-option:hover {
  background: var(--border);
  color: var(--text);
}
.ov-lang-option.active {
  color: var(--accent);
}
.ov-lang-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  min-width: 28px;
}
.ov-lang-name {
  font-size: 12.5px;
  font-family: var(--font);
}

/* ── SHELL ── */
.ov-shell {
  display: flex;
  min-height: calc(100vh - 48px);
}

/* ── SIDEBAR ── */
.ov-sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  position: sticky;
  top: 48px;
  height: calc(100vh - 48px);
  overflow-y: auto;
}

.ov-brand-block {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
}
.ov-brand-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}

.ov-user-card {
  margin: 16px 14px 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.ov-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.ov-user-email {
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
}

.ov-sidebar-account-block { margin-top: 12px; }

.ov-sidebar-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 20px;
  margin-bottom: 6px;
  margin-top: 20px;
}

/* ── STATUS PILLS ── */
.ov-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  width: 100%;
  border: 1px solid transparent;
  animation: ovStatusIn 220ms ease-out;
}
.ov-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--dim);
}
.ov-status.warn {
  background: var(--amber-lo);
  color: var(--amber);
  border-color: rgba(245,166,35,.2);
}
.ov-status.warn::before { background: var(--amber); }
.ov-status.ok {
  background: var(--green-lo);
  color: var(--green);
  border-color: rgba(62,207,142,.2);
}
.ov-status.ok::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ov-status.err,
.ov-status.error {
  background: rgba(242,107,107,.08);
  color: var(--red);
  border-color: rgba(242,107,107,.2);
}
.ov-status.err::before,
.ov-status.error::before { background: var(--red); }

@keyframes ovStatusIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── NAV ── */
.ov-nav-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.ov-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}
.ov-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--muted);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.ov-nav-item::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .5;
  flex-shrink: 0;
}
.ov-nav-item:hover {
  background: var(--panel);
  color: var(--text);
}
.ov-nav-item.active {
  background: var(--accent-lo);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}

/* ── SIDEBAR ACTIONS ── */
#sidebarActions {
  margin-top: auto;
  padding: 0 14px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── BUTTONS ── */
.ov-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: opacity .15s, transform .1s;
  width: 100%;
}
.ov-btn:hover { opacity: .88; transform: translateY(-1px); }
.ov-btn:active { transform: translateY(0); }

.ov-btn-secondary {
  background: transparent !important;
  color: var(--muted) !important;
  border: 1px solid var(--border) !important;
}
.ov-btn-secondary:hover {
  border-color: var(--border-hi) !important;
  color: var(--text) !important;
  opacity: 1 !important;
  transform: none !important;
  box-shadow: none !important;
}

.ov-btn-inline {
  width: 100% !important;
  padding: 8px 12px !important;
  font-size: 12.5px !important;
  margin-top: 0 !important;
  margin-right: 0 !important;
}

/* ── MAIN WRAP ── */
.ov-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ov-doc {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
  max-width: 100%;
  position: relative;
}

/* ── LOGIN PILL (hidden — status shown in sidebar) ── */
.ov-login-pill { display: none !important; }

/* ── AUTH STATE SWITCHING (driven by app.js adding .auth-in/.auth-out to #appPage) ── */

/* default: show signed-out, hide signed-in */
#signedOutView  { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 120px); }
#signedInView   { display: none; }

/* logged in */
#appPage.auth-in  #signedOutView { display: none; }
#appPage.auth-in  #signedInView  { display: block; }

/* logged out */
#appPage.auth-out #signedOutView { display: flex; }
#appPage.auth-out #signedInView  { display: none; }

/* dim sidebar nav when logged out */
#appPage.auth-out .ov-nav-item       { opacity: .35; pointer-events: none; }
#appPage.auth-out #btnRefreshAuth,
#appPage.auth-out #btnLogout         { opacity: .45; }
#appPage.auth-out #sidebarAccountBlock,
#appPage.auth-out #sidebarActions    { display: none; }
#appPage.auth-out .ov-user-card      { border-color: rgba(245,166,35,.2); background: rgba(245,166,35,.04); }
#appPage.auth-out .ov-user-name      { color: var(--amber); }
#appPage.auth-out .ov-user-email     { color: var(--dim); }

/* ── SIGN-IN CARD ── */
.ov-signin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 44px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 22px 55px rgba(0,0,0,.35);
}
.ov-ms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  width: 52px; height: 52px;
  margin: 0 auto 24px;
}
.ov-ms-grid span { border-radius: 4px; display: block; }
.ov-ms-grid span:nth-child(1) { background: #f25022; }
.ov-ms-grid span:nth-child(2) { background: #7fba00; }
.ov-ms-grid span:nth-child(3) { background: #00a4ef; }
.ov-ms-grid span:nth-child(4) { background: #ffb900; }

.ov-signin-card h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.ov-signin-card p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 28px;
}
.ov-signin-footnote {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.6;
}

/* ── MICROSOFT SIGN-IN BUTTON ── */
.ov-ms-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  margin: 0;
  min-height: 48px;
}
.ov-ms-button-light {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.ov-ms-button-light:hover {
  opacity: .92;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
/* MS 4-square logo via SVG data URI */
.ov-ms-button::before {
  content: '';
  display: inline-block;
  width: 20px; height: 20px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 21 21'%3E%3Crect x='1' y='1' width='9' height='9' fill='%23f25022'/%3E%3Crect x='11' y='1' width='9' height='9' fill='%237fba00'/%3E%3Crect x='1' y='11' width='9' height='9' fill='%2300a4ef'/%3E%3Crect x='11' y='11' width='9' height='9' fill='%23ffb900'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* ── PAGE HEADER ── */
.ov-main-header-row { margin-bottom: 28px; }
.ov-breadcrumb {
  font-size: 11.5px;
  color: var(--dim);
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.ov-doc-h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.ov-doc-lead {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── SIGNED-IN STATUS BANNER ── */
.ov-banner-status { display: none; }
.ov-banner-status.visible { display: flex; }

.ov-auth-signedin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--green-lo);
  border: 1px solid rgba(62,207,142,.2);
  border-radius: var(--r);
  margin-bottom: 24px;
  font-size: 13px;
}
.ov-auth-signedin::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}
.ov-auth-signedin-msg { color: var(--green); font-weight: 600; }

/* ── PANELS ── */
.ov-panel { display: none; }
.ov-panel.active { display: block; }

/* ── TEAMS TWO-COLUMN LAYOUT ── */
.ov-teams-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
.ov-teams-right {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;  /* prevent flex child from blowing out past grid column */
  width: 100%;
}

/* ── CARD ── */
.ov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  /* no padding here — sections handle their own internal spacing */
}

/* ── SECTION TITLE (card header row) ── */
.ov-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.ov-section-title[data-icon]::before {
  content: attr(data-icon);
  font-size: 14px;
}

/* ── FORM FIELDS (scoped to .ov-card) ── */
.ov-card label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 5px;
  margin-top: 14px;
  padding: 0 20px;
}
/* checkbox labels — override uppercase */
.ov-card label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 20px;
}
.ov-card label:has(input[type="checkbox"]) input {
  width: 14px; height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin: 0;
}

/* inputs / selects / textareas inside cards */
.ov-card select,
.ov-card input[type="text"],
.ov-card input[type="number"],
.ov-card input[type="url"],
.ov-card textarea {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  /* reset any inherited width:100% from global rules */
  box-sizing: border-box;
}
.ov-card select:focus,
.ov-card input:focus,
.ov-card textarea:focus { border-color: var(--accent); box-shadow: none; }
.ov-card textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* two-col grid inside card */
.ov-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px;
}
.ov-grid-2 label { padding: 0; margin-top: 0; }
.ov-grid-2 input { width: 100%; margin: 0; }

/* card primary action button */
.ov-card > .ov-btn,
.ov-card .ov-teams-left > .ov-btn {
  margin: 16px 20px 0 !important;
  width: calc(100% - 40px) !important;
}

/* workflow status inside card */
.ov-card #workflowStatus {
  margin: 10px 20px 16px !important;
  width: calc(100% - 40px) !important;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12.5px;
}

/* spacer at bottom of left card */
.ov-card .ov-btn + * { margin-bottom: 0; }
.ov-card > :last-child { margin-bottom: 20px; }

/* ── KPI ROW ── */
.ov-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;          /* never wider than the card */
  box-sizing: border-box;
}
.ov-kpi {
  padding: 20px;
  border-right: 1px solid var(--border);
  background: transparent;
  border-radius: 0;
  border-top: none;
  border-bottom: none;
  border-left: none;
}
.ov-kpi:last-child { border-right: none; }
.ov-kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 4px;
}
.ov-kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
}
.ov-kpi:nth-child(2) .ov-kpi-value { color: var(--accent); }
.ov-kpi:nth-child(3) .ov-kpi-value { color: var(--green); }

/* screen-reader-only labels (paired with visible filter inputs) */
.ov-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* team / channel filter sits directly above each <select> */
.ov-form-section #wfTeamSearch,
.ov-form-section #wfChannelSearch {
  margin-bottom: 8px;
}
.ov-form-section #wfChannelSearch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── ACTIVITY LOG ── */
.ov-flow-status { display: none !important; }

.ov-activity { padding: 16px 20px; }
.ov-activity-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
}
.ov-activity-log {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

/* ── SUMMARY PRE ── */
#teamsSummaryPre {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 16px 20px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;   /* no horizontal scroll — content wraps */
  overflow-y: auto;     /* scroll vertically inside card */
  max-height: 380px;    /* hard cap — content never stretches siblings */
  background: transparent;
  border: none;
  border-radius: 0;
  box-sizing: border-box;
  width: 100%;
}

/* ── RAW RESULTS ── */
.ov-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 20px;
}
.ov-results-head .ov-section-title {
  border-bottom: none;
  flex: 1;
}
.ov-results-head .ov-btn-secondary {
  width: auto !important;
  padding: 7px 12px !important;
  font-size: 12px !important;
  flex-shrink: 0;
}

#resultPre {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 14px 20px;
  line-height: 1.7;
  overflow-x: auto;     /* horizontal scroll for wide JSON */
  overflow-y: auto;     /* vertical scroll inside card */
  white-space: pre;
  max-height: 380px;    /* hard cap — never pushes KPIs out of alignment */
  background: transparent;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  width: 100%;
}

/* ── MUTED TEXT ── */
p.ov-muted,
.ov-muted {
  color: var(--muted);
  font-size: 13.5px;
  padding: 16px 20px;
  line-height: 1.6;
  margin: 0;
}

/* ── SHAREPOINT / FORMS PANELS ── */
.ov-row { padding: 0 20px; }
.ov-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  margin-top: 0;
  padding: 0;
}

/* ── FOOTER ── */
.ov-footer {
  text-align: center;
  padding: 14px;
  font-size: 11px;
  color: var(--dim);
  border-top: 1px solid var(--border);
  letter-spacing: .04em;
}

/* ── GLOBAL INPUT RESET (prevent leaking into cards) ── */
/* Only apply generic styling outside of .ov-card */
input[type="text"]:not(.ov-card *),
input[type="number"]:not(.ov-card *),
input[type="url"]:not(.ov-card *),
select:not(.ov-card *),
textarea:not(.ov-card *) {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
}
input:not(.ov-card *):focus,
select:not(.ov-card *):focus,
textarea:not(.ov-card *):focus {
  border-color: var(--accent);
  box-shadow: none;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .ov-teams-layout {
    grid-template-columns: 1fr;
  }
  .ov-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .ov-kpi:nth-child(2) { border-right: none; }
  .ov-kpi:nth-child(3) { border-top: 1px solid var(--border); }
}

@media (max-width: 720px) {
  .ov-sidebar { display: none; }
  .ov-doc { padding: 20px 16px; }
  .ov-kpi-row { grid-template-columns: 1fr 1fr; }
}