<?php
$root = dirname(__DIR__);
$css = file_get_contents($root . '/public/assets/css/dashboard-executive-command.css');
$version = json_decode(file_get_contents($root . '/DDB_VERSION.json'), true);
$tests = [];
$check = function($name,$ok,$detail='') use (&$tests){$tests[]=['name'=>$name,'status'=>$ok?'PASS':'FAIL','detail'=>$detail];};
$check('phase_r441', ($version['phase'] ?? '') === 'H11.0-P11.1-R44.1');
$check('release_11_0_11_54', ($version['release'] ?? '') === '11.0.11.54');
$check('desktop_2x2_rule_present', preg_match('/@media\s*\(min-width:\s*1480px\)[\s\S]*?command139-decision-grid[\s\S]*?grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\)/', $css) === 1);
$wideBlock = ''; if (preg_match('/@media\s*\(min-width:\s*1480px\)\s*\{([\s\S]*?)\n\}/', $css, $m)) { $wideBlock = $m[1]; }
$check('desktop_four_column_rule_absent', preg_match('/command139-decision-grid\s*\{[^}]*grid-template-columns:\s*repeat\(4,/', $css) === 0);
$check('wide_internal_patient_metrics_four_up', preg_match('/@media\s*\(min-width:\s*1480px\)[\s\S]*?command139-metric-grid\.four-up[\s\S]*?repeat\(4,/', $css) === 1);
$check('tablet_single_column_preserved', strpos($css, '@media (max-width: 1180px)') !== false && strpos($css, '.command139-decision-grid { grid-template-columns: 1fr; }') !== false);
$check('calculation_rules_unchanged', ($version['calculation_rules_changed'] ?? true) === false);
$check('oracle_writes_none', ($version['oracle_write_operations'] ?? '') === 'NONE');
$pass=count(array_filter($tests,fn($t)=>$t['status']==='PASS'));$fail=count($tests)-$pass;
echo json_encode(['phase'=>'H11.0-P11.1-R44.1','pass'=>$pass,'fail'=>$fail,'tests'=>$tests],JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES),PHP_EOL;
exit($fail===0?0:1);
