/* Payrexx Migrations: additions on top of the shared intranet styles (styles.css). */

/* Phase kinds */
.kind-expand   { background: var(--primary-soft); color: var(--primary-dark); }
.kind-switch   { background: #E6E9FB; color: var(--dark-blue); }
.kind-backfill { background: #EFFDE0; color: var(--pass-text); }
.kind-contract { background: var(--fail-soft); color: var(--fail-text); }

/* Phase status */
.ph-planned { background: var(--skipped-soft); color: var(--muted); }
.ph-merged  { background: var(--primary-soft); color: var(--primary-dark); }
.ph-stage   { background: var(--blocked-soft); color: var(--blocked-text); }
.ph-prod    { background: var(--pass-soft); color: var(--pass-text); }
.ph-skipped { background: var(--skipped-soft); color: var(--muted); text-decoration: line-through; }

/* Change status */
.cs-planned     { background: var(--skipped-soft); color: var(--muted); }
.cs-in_progress { background: var(--primary-soft); color: var(--primary-dark); }
.cs-done        { background: var(--pass-soft); color: var(--pass-text); }
.cs-cancelled   { background: var(--fail-soft); color: var(--fail-text); }
.badge-lg { font-size: 13px; padding: 6px 14px; background-color: #fff; }

/* CI outcome, environment */
.out-ok   { background: var(--pass-soft); color: var(--pass-text); }
.out-warn { background: var(--blocked-soft); color: var(--blocked-text); }
.out-fail { background: var(--fail-soft); color: var(--fail-text); }
.env-stage { background: var(--blocked-soft); color: var(--blocked-text); }
.env-prod  { background: var(--pass-soft); color: var(--pass-text); }
.tag-fail { background: var(--fail-soft); color: var(--fail-text); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); text-decoration: none; color: var(--text); }
.kpi:hover { box-shadow: 0 0 0 2px var(--primary-soft-hover), var(--shadow-lg); }
.kpi-n { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.kpi-l { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-warn .kpi-n { color: var(--blocked-text); }
.kpi-fail .kpi-n { color: var(--fail-text); }

.block { margin-bottom: 24px; }
.sub-h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.sub-h a { color: var(--text); text-decoration: none; }
.sub-h a:hover { color: var(--primary-dark); }
.empty.slim { padding: 16px; font-size: 14px; }
.dl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.pre { white-space: pre-wrap; }
.on-sky { color: #fff; font-weight: 700; }
.flush { padding: 4px 8px; }

/* Rows */
.ph-row, .ch-row, .rl-row {
  display: grid; align-items: center; gap: 14px; padding: 12px 18px;
  text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border);
}
.ph-row:last-child, .ch-row:last-child, .rl-row:last-child { border-bottom: 0; }
.ph-row:hover, .ch-row:hover { background: var(--primary-soft); }
.ph-row { grid-template-columns: 230px minmax(0, 1fr) auto; }
.ch-row { grid-template-columns: 100px minmax(0, 1fr) auto 120px; }
.rl-row { grid-template-columns: minmax(0, 1fr) 150px 150px auto; }
.ph-row-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.ph-row-title { display: flex; flex-direction: column; min-width: 0; }
.ph-row-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-main { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.rl-main:hover b { color: var(--primary-dark); }
.rl-actions { display: inline-flex; gap: 6px; }

/* Phase track (compact) */
.track { display: inline-flex; gap: 3px; }
.track-step { display: inline-flex; flex-direction: column; align-items: center; min-width: 46px; padding: 3px 6px; border-radius: 8px; font-size: 10px; line-height: 1.2; }
.track-kind { font-weight: 800; font-size: 12px; }
.track-step.is-overdue { box-shadow: inset 0 0 0 2px var(--blocked); }
.mywork .track-step { min-width: 36px; }

/* Lists in the rail */
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.check-list li { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; align-items: start; }
.check-list .badge { justify-self: start; }
.check { border-bottom: 1px solid var(--border); padding: 8px 0; }
.check:last-child { border-bottom: 0; }
.check summary { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; cursor: pointer; list-style: none; }
.check summary::-webkit-details-marker { display: none; }
.check-results { list-style: none; padding: 8px 0 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.check-results ul { margin: 4px 0; padding-left: 18px; }

/* Change detail: phases */
.phases { display: flex; flex-direction: column; gap: 14px; }
.phase { position: relative; padding: 18px 22px; }
.phase-head { display: flex; align-items: flex-start; gap: 14px; }
.phase-no { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg); color: var(--muted); }
.ph-card-prod .phase-no { background: var(--pass-soft); color: var(--pass-text); }
.ph-card-stage .phase-no { background: var(--blocked-soft); color: var(--blocked-text); }
.ph-card-merged .phase-no { background: var(--primary-soft); color: var(--primary-dark); }
.phase-title { flex: 1; min-width: 0; }
.phase-title h2 { margin: 4px 0 2px; font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.phase-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.phase-hint { margin: 10px 0 6px; }
.phase-notes { white-space: pre-wrap; margin: 6px 0; }
.status-form select, .attach-phase select, .filters .search, .inline select {
  font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.filters .search { min-width: 260px; padding: 8px 14px; }
.phase-more { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.phase-more summary, .phase-add summary, details.rail-card > summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.phase-more .form, .phase-add .form { margin-top: 12px; }
.form-wide { max-width: none; }
.mig-table code { font-size: 12px; word-break: break-all; }
.mig-table td { vertical-align: top; }
.rail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* New change: pattern picker */
.patterns { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.patterns legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.form .pattern-opt { display: block; cursor: pointer; }
.pattern-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pattern-card { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; font-weight: 400; }
.pattern-opt:hover .pattern-card { border-color: var(--primary-soft-hover); }
.pattern-opt input:checked + .pattern-card { border-color: var(--primary); box-shadow: var(--ring); background: var(--primary-soft); }
.pattern-opt input:focus-visible + .pattern-card { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.pattern-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pattern-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.plan-preview { background: var(--bg); border-radius: 14px; padding: 12px 16px; }
.plan-preview:empty { display: none; }
.plan { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* New change: custom phases */
.form [hidden] { display: none; }
.custom-phases { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.custom-phases-head { display: flex; flex-direction: column; gap: 2px; }
.custom-phase-rows { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.custom-phase { display: grid; grid-template-columns: 24px 170px minmax(0, 1fr) 190px auto; gap: 8px; align-items: center; }
.custom-phase-n { font-weight: 700; color: var(--muted); text-align: right; }
.field-error { margin: 0; color: var(--fail-text); font-size: 13px; font-weight: 600; }
@media (max-width: 720px) {
  .custom-phase { grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) auto; }
  .custom-phase input[name=phase_title] { grid-column: 2 / -1; grid-row: 2; }
}

/* Patterns page */
.rules { margin-bottom: 18px; }
.rules ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.pattern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.pattern-doc { display: flex; flex-direction: column; gap: 8px; }
.pattern-doc .btn { align-self: flex-start; margin-top: auto; }

/* Register migration */
.file-card { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.file-card > .ti { font-size: 28px; color: var(--primary-dark); }
.file-card p { margin: 2px 0 0; }
.file-card .tag { margin-left: auto; }
.choose-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; align-items: start; }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.attach summary { cursor: pointer; }
.attach-phase { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); margin-top: 8px; }

.copy { cursor: pointer; }
.copy.copied { outline: 2px solid var(--pass); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choose-grid { grid-template-columns: 1fr; }
  .ph-row, .ch-row, .rl-row { grid-template-columns: 1fr; gap: 6px; }
  .wb.wb-right { grid-template-columns: 1fr; }
  .wb-rail { position: static; max-height: none; }
}

/* Rail: title above the phase track */
.wb-rail .mywork { flex-direction: column; align-items: flex-start; gap: 6px; }
.wb-rail .track { flex-wrap: wrap; }

/* Seven nav entries: tighter below desktop width */
@media (max-width: 1180px) {
  .nav a { padding: 7px 9px; font-size: 13px; }
  .topbar .user-meta { display: none; }
}
.attach-phase.is-closed { grid-template-columns: minmax(0, 1fr) auto; opacity: 0.6; }
.tool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tool-list li { display: flex; flex-direction: column; }
.tool-list code { font-size: 12px; }
.rl-row.is-archived { opacity: 0.55; }

/* Filter bar (like the Roadmap planner): pill search + pill selects, instant filtering */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.fsearch { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 14px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); min-width: 280px; flex: 0 1 340px; }
.fsearch:focus-within { box-shadow: var(--ring), var(--shadow); }
.fsearch .ti { color: var(--muted); font-size: 16px; }
.fsearch input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 14px; outline: none; color: var(--text); }
.fsearch input::-webkit-search-cancel-button { display: none; }
.fsearch kbd { font: inherit; font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; }
.fselect { height: 38px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface); border: 0; border-radius: 999px; padding: 0 30px 0 14px; box-shadow: var(--shadow); cursor: pointer;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2365696B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.fselect:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow); }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); font-size: 13px; font-weight: 600; cursor: pointer; }
.fchip:has(input:checked) { background: var(--btn-secondary); color: var(--btn-secondary-label); }
.fclear { height: 38px; border: 0; background: transparent; color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 999px; padding: 0 10px; }
.fclear:hover { background: rgba(255, 255, 255, 0.2); }
.fcount { margin-left: auto; color: rgba(255, 255, 255, 0.9); font-weight: 600; }
.ch-row[hidden] { display: none; }

/* Patterns: decision guide */
.guide { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.guide-nav { position: sticky; top: 16px; padding: 10px; display: flex; flex-direction: column; }
.guide-group { margin: 12px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.guide-group:first-child { margin-top: 4px; }
.guide-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.guide-item:hover { background: var(--bg); }
.guide-item.active { background: var(--primary-soft); color: var(--primary-dark); }
.guide-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.guide-span { display: inline-flex; gap: 3px; }
.guide-span i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); opacity: 0.55; }
.guide-item.active .guide-span i { opacity: 1; }
.guide-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.guide-panel { padding: 22px 24px; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.guide-head h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.guide-head p { margin: 0; }
.lanes { display: grid; grid-template-columns: 82px repeat(var(--cols), minmax(0, 1fr)); gap: 8px; margin: 20px 0 14px; }
.lane-rel { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 4px; }
.lane-label { font-size: 12px; font-weight: 700; color: var(--muted); align-self: center; display: inline-flex; align-items: center; gap: 4px; }
.lane-cell { display: flex; flex-direction: column; gap: 6px; }
.cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 600; line-height: 1.35; height: 100%; }
.cell .badge { font-size: 10px; }
.cell.kind-expand { background: var(--primary-soft); color: var(--primary-dark); }
.cell.kind-switch { background: #E6E9FB; color: var(--dark-blue); }
.cell.kind-backfill { background: #EFFDE0; color: var(--pass-text); }
.cell.kind-contract { background: var(--fail-soft); color: var(--fail-text); }
.cell.kind-expand .badge, .cell.kind-switch .badge, .cell.kind-backfill .badge, .cell.kind-contract .badge { background: rgba(255, 255, 255, 0.7); }
.cell-none { background: var(--bg); color: var(--muted); font-weight: 500; }
.cell-code { background: var(--surface); border: 1px solid var(--border); font-weight: 500; }
.cell-code.cell-none { border-color: transparent; }
.cell-ci { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; padding: 8px 12px; }
.ci-ok { background: var(--pass-soft); color: var(--pass-text); }
.ci-lock { background: var(--blocked-soft); color: var(--blocked-text); }
.trap { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--blocked-soft); color: var(--blocked-text); font-size: 14px; }
.trap .ti { margin-top: 2px; }
.examples { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.examples summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--primary-dark); }
pre.code { margin: 8px 0 0; padding: 12px 14px; border-radius: 12px; background: #1E2427; color: #E6EDF0; font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre; }
.guide-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); }
.rules summary { cursor: pointer; font-weight: 800; font-size: 16px; }
.rules ol { margin-top: 12px; }
@media (max-width: 900px) {
  .guide { grid-template-columns: 1fr; }
  .guide-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .guide-group { width: 100%; margin: 6px 6px 0; }
  .lanes { grid-template-columns: 1fr; }
  .lanes > span:empty, .lane-rel { display: none; }
}

.fchip-danger:has(input:checked) { background: var(--fail-soft); color: var(--fail-text); }

/* Phase environments: read-only, set by CI */
.phase-env { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.env-step { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.env-step small { font-weight: 500; margin-left: 4px; }
.env-step.is-on { background: var(--pass-soft); color: var(--pass-text); }
.env-by { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }

/* DDL mode explanation next to the select */
.ddl-help { margin: 4px 0 8px; font-size: 13px; }
.ddl-help summary { cursor: pointer; color: var(--primary-dark); font-weight: 600; }
.ddl-help dl { margin: 8px 0 0; display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 6px 12px; }
.ddl-help dt { font-weight: 700; }
.ddl-help dd { margin: 0; color: var(--muted, #555); line-height: 1.45; }
@media (max-width: 640px) { .ddl-help dl { grid-template-columns: 1fr; } .ddl-help dd { margin-bottom: 6px; } }
