/* Procurement module styles (spec 003, FR-027b). Every selector starts with .proc- (checks/procurement/module.js),
   except the token blocks on :root and the base rules. Tokens, borders, shadows, the slanted accent, hover lift, logos,
   header and home hub copy the IMPACT DC page template (DC/App/src/app.html, read only). Light / dark / system follow
   _shared/DESIGN.md. */

:root {
  --brand: #193FF9;
  --brand-strong: #0F2FD0;
  --brand-soft: #E3E8FF;
  --on-brand: #FFFFFF;
  --ink: #272727;
  --ink-secondary: #3D3D3D;
  --ink-muted: #5C5C5C;
  --surface: #FFFFFF;
  --surface-sunk: #EFEFEF;
  --surface-raised: #F6F6F6;
  --border: #E4E4E4;
  --border-strong: #8E8E8E;
  --ok: #1E7B46;
  --risk: #9A5B00;
  --late: #B42318;
  --shear: -16.7deg;
  --radius-sm: 2px;
  --radius-md: 4px;
  --font-sans: "Inter", "Segoe UI", system-ui, Arial, sans-serif;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #5C7BFF;
    --brand-strong: #3F63FF;
    --brand-soft: #1D2547;
    --on-brand: #0F1226;
    --ink: #F2F2F2;
    --ink-secondary: #D4D4D4;
    --ink-muted: #A3A3A3;
    --surface: #171717;
    --surface-sunk: #1B1B1B;
    --surface-raised: #212121;
    --border: #333333;
    --border-strong: #6B6B6B;
    --ok: #5BD197;
    --risk: #F5B94A;
    --late: #FF8A80;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #5C7BFF;
  --brand-strong: #3F63FF;
  --brand-soft: #1D2547;
  --on-brand: #0F1226;
  --ink: #F2F2F2;
  --ink-secondary: #D4D4D4;
  --ink-muted: #A3A3A3;
  --surface: #171717;
  --surface-sunk: #1B1B1B;
  --surface-raised: #212121;
  --border: #333333;
  --border-strong: #6B6B6B;
  --ok: #5BD197;
  --risk: #F5B94A;
  --late: #FF8A80;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

:root:lang(ar) {
  --font-sans: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 22px;
}

.proc-hide {
  display: none !important;
}

.proc-busy[hidden] {
  display: none;
}

.proc-logo-dark {
  display: none;
}

:root[data-theme="dark"] .proc-logo-light {
  display: none;
}

:root[data-theme="dark"] .proc-logo-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .proc-logo-light {
    display: none;
  }
  :root:not([data-theme="light"]) .proc-logo-dark {
    display: block;
  }
}

.proc-prof-btn:hover,
.proc-prof-btn[aria-expanded="true"] {
  border-color: var(--brand);
}

@media (prefers-reduced-motion: reduce) {
  .proc-busy {
    animation: none;
    background: var(--brand);
    opacity: .6;
  }
}

/* ---------- Main area and footer ---------- */

.proc-main {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
}

.proc-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-muted);
}

.proc-section-t::before,
.proc-card > h2::before {
  content: "";
  position: absolute;
  bottom: -1px;
  inset-inline-start: 0;
  width: 30px;
  height: 3px;
  background: var(--brand);
  transform: skewX(var(--shear));
}

/* ---------- Cards and forms: 1 px border, raised surface, shadow (DC .card / .mod) ---------- */

.proc-card {
  border: 1px solid var(--border);
}

.proc-card p {
  margin: 0 0 8px;
  color: var(--ink-secondary);
}

.proc-form {
  display: grid;
  gap: 12px;
}

.proc-field {
  display: grid;
  gap: 4px;
  font-size: 14px;
  color: var(--ink-secondary);
}

.proc-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.proc-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}

.proc-input:disabled {
  background: var(--surface-sunk);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.proc-error {
  border: 1px solid var(--late);
}

.proc-error h2 {
  color: var(--late);
}

.proc-msg {
  margin: 0;
  font-size: 14px;
  color: var(--late);
}

.proc-status {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: var(--ink-muted);
}

/* ---------- Sign-in: DC login layout (brand panel and form box) ---------- */

.proc-login {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 24px;
  align-items: center;
  min-height: calc(100vh - 160px);
}

.proc-login-brand {
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 24px;
}

.proc-login-brand .proc-logo {
  height: 96px;
}

.proc-welcome {
  margin: 0;
  font-size: 22px;
  line-height: 30px;
  font-weight: 800;
  text-align: center;
}

.proc-login-hint {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
}

.proc-login-box {
  margin: 0;
  padding: 32px;
}

.proc-login-box > .proc-logo {
  height: 30px;
  justify-self: start;
}

@media (max-width: 760px) {
  .proc-login {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .proc-login-brand {
    display: none;
  }
}

/* Wide tables scroll inside their own frame, never the page (FR-027). */

.proc-scroll {
  max-width: 100%;
  overflow-x: auto;
}

/* Tables inside a scroll frame fill its width, so empty columns keep a usable size (a click on a row
   must land on a cell, and the label column must not collapse). */

.proc-scroll table {
  width: 100%;
  border-collapse: collapse;
}

.proc-scroll th,
.proc-scroll td {
  padding: 4px 8px;
  vertical-align: middle;
}

.proc-scroll th {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  text-align: start;
  border-bottom: 1px solid var(--border-strong);
}

.proc-scroll td {
  border-bottom: 1px solid var(--border);
}

.proc-scroll td:first-child {
  min-width: 160px;
}

/* ---------- Tree (registry) and small controls ---------- */

.proc-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.proc-tree .proc-tree {
  margin-inline-start: 12px;
  padding-inline-start: 16px;
  border-inline-start: 2px solid var(--brand-soft);
}

.proc-node {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 0;
}

.proc-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: var(--brand);
}

.proc-chip {
  padding: 2px 8px;
  font-size: 12px;
  color: var(--ink-secondary);
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
}

.proc-toggle {
  min-width: 44px;
  padding: 4px 8px;
}

/* Import preview KPIs. */

.proc-kpi {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  padding: 8px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}

.proc-kpi b {
  font-size: 18px;
}

/* Rows that open a detail panel, and numbers aligned to the end of the cell. */

.proc-pick {
  cursor: pointer;
}

.proc-pick:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.proc-num {
  text-align: end;
  font-family: ui-monospace, Consolas, monospace;
  white-space: nowrap;
}

/* ---------- Small screens: the profile name gives way to the avatar and the controls fit ---------- */

@media (max-width: 720px) {
  .proc-main {
    padding: 12px;
  }
}

/* DC's phone rule stops .tools from wrapping; the forms use .proc-tools too, so they wrap on phones (FR-027). */
@media (max-width: 720px) {
  .proc-tools {
    flex-wrap: wrap;
  }
}

/* DC's buttons never wrap (white-space: nowrap). On phones a long label wraps instead of widening the page (FR-027). */
@media (max-width: 720px) {
  .proc-btn {
    white-space: normal;
  }
}

/* Touch: DC's coarse-pointer rule only (DC app.html:464-466): buttons 44 px, switch buttons 38 px. */

@media (pointer: coarse) {
  .proc-btn {
    min-height: 44px;
  }
  .proc-switch {
    height: auto;
  }
  .proc-switch button {
    height: 38px;
    min-width: 40px;
  }
}

/* ---------- Print: logos greyscale, the controls and the loading bar are not printed ---------- */

@media print {
  .proc-logo {
    filter: grayscale(1);
  }
  .proc-tools,
  .proc-busy,
  .proc-foot {
    display: none !important;
  }
}
